Skip to content

Instantly share code, notes, and snippets.

@timcash
Created August 13, 2010 03:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save timcash/522200 to your computer and use it in GitHub Desktop.
Save timcash/522200 to your computer and use it in GitHub Desktop.
class Planet
constructor: (@name,@size,@x,@y) ->
# I want an empty object to store ship in later
@ships = {}
battle: ->
#if more then one player has ships at this planet run the battle simulation
for p of @ships
damage = randint(@ships[p])
# todo, remove ships based on damage here
add_ships: (player,amount) ->
#add ships to an array based on the player how owns them
if @ships[player]?
@ships[player] += amount
else
@ships[player] = amount
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment