From 570323ed8cfdaf1d94bf1cbd78b84c76b2a260f8 Mon Sep 17 00:00:00 2001
From: Paolo Capriotti
Date: Sat, 19 Jun 2010 18:16:02 +0100
Subject: [PATCH] Remove useless match parameters from MatchHelper methods.
---
lib/plugins/ics/lib/match_handler.rb | 2 +-
lib/plugins/ics/lib/match_helper.rb | 17 +++++++++--------
test/plugins/ics/test_match_handler.rb | 2 +-
3 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/lib/plugins/ics/lib/match_handler.rb b/lib/plugins/ics/lib/match_handler.rb
index 288c0e3..abe1269 100644
--- a/lib/plugins/ics/lib/match_handler.rb
+++ b/lib/plugins/ics/lib/match_handler.rb
@@ -116,7 +116,7 @@ class MatchHandler
if match.started?
match_info[:icsplayer].on_style12(style12)
else
- helper.start(@protocol, @user, match, match_info, style12)
+ helper.start(@protocol, @user, match_info, style12)
end
end
end
diff --git a/lib/plugins/ics/lib/match_helper.rb b/lib/plugins/ics/lib/match_helper.rb
index 6097894..64f70d0 100644
--- a/lib/plugins/ics/lib/match_helper.rb
+++ b/lib/plugins/ics/lib/match_helper.rb
@@ -30,9 +30,9 @@ module MatchHelper
# Create the opponent player. By default, create an ICSPlayer that
# will respond to future style12 events.
#
- def create_opponent(protocol, color, match, match_info)
+ def create_opponent(protocol, color, match_info)
send = lambda {|msg| protocol.connection.send_text(msg) }
- opponent = ICSPlayer.new(send, color, match, match_info)
+ opponent = ICSPlayer.new(send, color, match_info[:match], match_info)
match_info[:icsplayer] = opponent
opponent
end
@@ -40,7 +40,7 @@ module MatchHelper
#
# Create a player for this match.
#
- def create_player(user, color, match, match_info)
+ def create_player(user, color, match_info)
raise "not implemented"
end
@@ -76,7 +76,7 @@ module MatchHelper
# Start an existing match. Called when the first style12
# for the given match is received.
#
- def start(protocol, user, match, match_info, style12)
+ def start(protocol, user, match_info, style12)
rel = style12.relation
state = style12.state
turns = [state.turn, state.opposite_turn(state.turn)]
@@ -84,11 +84,12 @@ module MatchHelper
user_color, opponent_color = colors(state, rel)
# create players
- opponent = create_opponent(protocol, opponent_color, match, match_info)
- player = create_player(user, user_color, match, match_info)
+ opponent = create_opponent(protocol, opponent_color, match_info)
+ player = create_player(user, user_color, match_info)
setup_players(user, [player, opponent])
# start match
+ match = match_info[:match]
match.register(player)
match.register(opponent)
match.start(player)
@@ -112,7 +113,7 @@ end
class DefaultMatchHelper
include MatchHelper
- def create_player(user, color, match, match_info)
+ def create_player(user, color, match_info)
# do not create a new player, just return user
user.color = color
user.premove = true
@@ -127,7 +128,7 @@ end
class ExaminingMatchHelper
include MatchHelper
- def create_player(user, color, match, match_info)
+ def create_player(user, color, match_info)
user.color = nil
# create a controlled player
diff --git a/test/plugins/ics/test_match_handler.rb b/test/plugins/ics/test_match_handler.rb
index 8687f71..b180192 100644
--- a/test/plugins/ics/test_match_handler.rb
+++ b/test/plugins/ics/test_match_handler.rb
@@ -60,4 +60,4 @@ class TestMatchHandler < Test::Unit::TestCase
info = handler.matches[37]
assert info[:match].started?
end
-end
\ No newline at end of file
+end
--
2.11.4.GIT