GithubHelp home page GithubHelp logo

marlatte / battleship Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 0.0 573 KB

A classic board game built with TDD.

Home Page: https://marlatte.github.io/battleship/

HTML 4.80% CSS 10.15% JavaScript 85.05%

battleship's Introduction

Hi there ๐Ÿ‘‹

I'm a front-end developer educated through The Odin Project who also enjoys:

  • Making music ๐ŸŽธ ๐Ÿฅ ๐ŸŽค
  • Designing logos and layouts ๐Ÿ–ผ๏ธ ๐Ÿ–๏ธ
  • Tearing my hair out over soccer โšฝ๏ธ ๐Ÿ›ก๏ธ

Skilled with

My Skills

battleship's People

Contributors

marlatte avatar

Watchers

 avatar

battleship's Issues

End game!

  • Write conditions for game over
  • Write checker fn
  • Publish GAME_OVER event

De-pubsubify

Too many messages getting passed back and forth. Code is getting convoluted when trying to return info from a fn call. playRound, checkCompTurn, and checkGameOver could all be one fn if I use import instead of PubSub.

Also, having the game-controller decide where to place comp ships will take too many steps/msgs with PubSub.

Write simple HTML

No more than is necessary to capture main elements for visualizing and attacking ships.
Do not get fancy yet!!!

Bug: multiple turns firing

Rapid clicking on squares fires computer turns that can also shoot at its own board.

Could be solved by a universal setTimeout var that removes the event listener for the same amount of time comp decision takes, though I suspect there's a better way.

Fill out the skeleton

Problem-solving time!

Iterate over the pseudo outline, getting more specific with each pass.

If you don't know how to solve a specific challenge, mark it for the next pass or get to googling, but DO NOT skip things without making a note. That leaves unpleasant surprises for later.

This step should take a while, since it's actually several rolled into one. It ends when you run out of abstract ways to describe the steps and the pseudo is half JS anyway.

Lessons from past projects:

  • Event delegation can solve issues with dynamically created elements like buttons
  • Template literals are great for element.innerHTML; you don't have to create and append so many things.

PubSubify!

Decouple modules by switching fn calls to event publications

Logical flow

Logical flow:
A few sentences on general functionality and the steps necessary to do all those things.

Write 30k ft pseudo outline

Bottom Up

  • What are the building blocks of your program? What units will it have?
  • List out any tools, methods, or patterns you want to use (e.g. Pubsub)
  • Mark places where you'll use Unit Tests.

Top Down

Walking through logical flow from first task, write out the top-level steps necessary to get this done. Don't worry about details or specific properties/methods, just finish the prompt, "Okay, then I'll need a function to do ___" for every step. Focus on what information is being passed from unit to unit. In the end, you'll have a skeleton to flesh out in the next steps.

VERY basic CSS

Black / white only, basically just do the borders and minimally acceptable spacing to make it useful.

Don't get fancy, and DO NOT make any big design decisions yet!!

Let computer take a turn automatically

Currently, only mouse clicks trigger playRound()

  • Start by switching the preset computer attack btns to fire randomly.
  • Then trigger this capability automatically in playRound()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.