From e74ab8a862b27825b3e4986a2da9cb19c3319c10 Mon Sep 17 00:00:00 2001 From: Paolo Capriotti Date: Sun, 26 Jul 2009 23:53:48 +0200 Subject: [PATCH] Don't overwrite pools when receiving updates from ICS. --- lib/games/state_base.rb | 2 +- lib/plugins/ics/lib/icsapi.rb | 11 +++++++++-- lib/plugins/ics/lib/icsplayer.rb | 4 +++- lib/plugins/ics/lib/protocol.rb | 3 ++- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/lib/games/state_base.rb b/lib/games/state_base.rb index 71c53a0..5ddc8fe 100644 --- a/lib/games/state_base.rb +++ b/lib/games/state_base.rb @@ -7,7 +7,7 @@ class StateBase attr_accessor :turn - attr_reader :board + attr_accessor :board attr_reader :move_factory, :piece_factory def initialize(board, move_factory, piece_factory) diff --git a/lib/plugins/ics/lib/icsapi.rb b/lib/plugins/ics/lib/icsapi.rb index 31684ae..7e5a946 100644 --- a/lib/plugins/ics/lib/icsapi.rb +++ b/lib/plugins/ics/lib/icsapi.rb @@ -44,8 +44,15 @@ class ICSApi end def same_state(state1, state2) - state1.board == state2.board && - state1.turn == state2.turn + (state1.board == state2.board).tap{|x| puts "boards differ" unless x } && + (state1.turn == state2.turn).tap{|x| puts "turns differ" unless x } + end + + def amend_state(state1, state2) + state1.dup.tap do |result| + result.board = state2.board.dup + result.turn = state2.turn + end end end diff --git a/lib/plugins/ics/lib/icsplayer.rb b/lib/plugins/ics/lib/icsplayer.rb index 579cb30..241ec14 100644 --- a/lib/plugins/ics/lib/icsplayer.rb +++ b/lib/plugins/ics/lib/icsplayer.rb @@ -108,7 +108,9 @@ class ICSPlayer style12.last_move_san, @match.history[style12.move_index - 1].state) end - state = style12.state.dup + state = @match_info[:icsapi]. + amend_state(@match.history[style12.move_index].state, + style12.state) if @match.navigable? && (!revert_to) @match.history.go_to(style12.move_index) @match.history.set_item(state, move) diff --git a/lib/plugins/ics/lib/protocol.rb b/lib/plugins/ics/lib/protocol.rb index 6658aa8..7788a39 100644 --- a/lib/plugins/ics/lib/protocol.rb +++ b/lib/plugins/ics/lib/protocol.rb @@ -19,7 +19,8 @@ class Protocol GAME_TYPES = { 'standard' => :chess, 'blitz' => :chess, - 'lightning' => :chess } + 'lightning' => :chess, + 'crazyhouse' => :crazyhouse } attr_reader :connection -- 2.11.4.GIT