From fc1b9096951b968102eeba4b93f1e717be2b756c Mon Sep 17 00:00:00 2001 From: Paolo Capriotti Date: Tue, 16 Jun 2009 19:23:59 +0200 Subject: [PATCH] Moving opponent pieces is now forbidden. --- lib/board/board.rb | 5 ++++- lib/board/user.rb | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/board/board.rb b/lib/board/board.rb index b5ebc4e..94fef0f 100644 --- a/lib/board/board.rb +++ b/lib/board/board.rb @@ -14,6 +14,7 @@ class Board < Qt::GraphicsItemGroup include ItemBag attr_reader :scene, :items, :state, :unit, :theme + attr_accessor :movable square_tag :selection square_tag :last_move_src, :highlight square_tag :last_move_dst, :highlight @@ -37,6 +38,7 @@ class Board < Qt::GraphicsItemGroup @field = AnimationField.new(20) @flipped = false + @movable = lambda { true } end def flipped? @@ -115,7 +117,8 @@ class Board < Qt::GraphicsItemGroup end self.selection = nil - elsif @game.policy.movable?(@state, p) + elsif @game.policy.movable?(@state, p) and + @movable[@state, p] self.selection = p end end diff --git a/lib/board/user.rb b/lib/board/user.rb index 5f3b50f..9674779 100644 --- a/lib/board/user.rb +++ b/lib/board/user.rb @@ -16,6 +16,9 @@ class User def reset(match) @board.flip!(color != :white) @board.warp(match.state) + @board.movable = lambda do |state, p| + state.board[p].color == color + end user = self @board.observe :new_move do |data| -- 2.11.4.GIT