repo.or.cz
/
kaya.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
history
|
raw
|
HEAD
Implemented drag and drop.
[kaya.git]
/
lib
/
games
/
chess
/
policy.rb
blob
8ddc51d2dc978d93b5218b517282688f7917f91c
1
module Chess
2
class Policy
3
def initialize(move_factory)
4
@move_factory = move_factory
5
end
6
7
def movable?(state, p)
8
piece = state.board[p]
9
piece && piece.color == state.turn
10
end
11
12
def droppable?(state, color, index)
13
color == state.turn
14
end
15
16
def new_move(state, src, dst, opts = {})
17
@move_factory.new(src, dst, opts.merge(:promotion => :queen))
18
end
19
end
20
end