Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Tile
- constructor: (@set, @val) ->
- class Tileset
- constructor: (@tiles = []) ->
- shuffle: ->
- for i in [this.tiles.length - 1 ... 0]
- j = Math.floor(Math.random() * (i + 1))
- temp = this.tiles[i]
- this.tiles[i] = this.tiles[j]
- this.tiles[j] = temp
- this.tiles;
- push: (tile) -> this.tiles.push(tile)
- pop: () -> this.tiles.pop()
- class Hand extends Tileset
- constructor: (@tiles = []) ->
- class Wall extends Tileset
- constructor: (@tiles = []) ->
- @populate()
- @shuffle()
- populate: ->
- sets = 'man pin sou honor'.split(' ')
- honors = 'haku hatsu chun e s w n'.split(' ')
- for i in [0...sets.length]
- if sets[i] == 'honor'
- for j in [0...honors.length]
- for k in [0...4]
- @tiles.push new Tile(sets[i], honors[j])
- else
- for j in [1...10]
- for k in [0...4]
- @tiles.push new Tile(sets[i], j)
- class Player
- constructor: ->
- class Game
- constructor: ->
- @wall = new Wall
- @hand = new Hand
- for i in [0...13]
- @hand.push(this.wall.pop())
- game = new Game
- console.log(game.hand.tiles);
Advertisement
Add Comment
Please, Sign In to add comment