Skip to content

Instantly share code, notes, and snippets.

@andrzejkrzywda
Created September 24, 2011 18:38
Show Gist options
  • Save andrzejkrzywda/1239676 to your computer and use it in GitHub Desktop.
Save andrzejkrzywda/1239676 to your computer and use it in GitHub Desktop.
class Monopoly
constructor: (serverSide, popupsManager) ->
player = new Player(PlayerAttributes)
playerView = new PlayerView
playerController = new PlayerController(player, playerView)
(..)
class PlayerView
update: (player) ->
$("#player_score").text(player.points)
$("#player_ranking_position").text(player.rankingPosition)
$("#player_rank").text(player.rank)
class PlayerController
constructor: (@player, @view) ->
@player.bind("player:updated", view.update)
class Player
constructor: (attributes) ->
_.extend(this, Backbone.Events)
_.extend(this, attributes)
addPoints: (delta) ->
@points += delta
@trigger("player:updated", this)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment