Notify when a new game is starting.
[kaya.git] / lib / board / user.rb
blob5f3b50fc07c03bcb51a6ba40bd364debb3152ad3
1 require 'interaction/match'
3 # This class represents a local player
4
5 class User
6   include Player
7   
8   attr_accessor :color
9   
10   def initialize(color, board, notify)
11     @color = color
12     @board = board
13     @notify = notify
14   end
15   
16   def reset(match)
17     @board.flip!(color != :white)
18     @board.warp(match.state)
19     
20     user = self
21     @board.observe :new_move do |data|
22       match.move(user, data[:move], data[:state])
23     end
24     
25     @notify[:newGame => 'Starting new game']
26   end
27   
28   def on_move(data)
29     @board.forward(data[:state], data[:move])
30     @notify[:move => "A new move has been played"]
31   end
32 end