• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

shogi-server source


Commit MetaInfo

修订版326856b66214cc6e2dccfb8f9121255148ca4a90 (tree)
时间2014-12-27 23:32:58
作者Daigo Moriwaki <daigo@debi...>
CommiterDaigo Moriwaki

Log Message

Merge remote-tracking branch 'origin/wdoor-stable' into wdoor-stable

Conflicts:
changelog

更改概述

差异

--- a/changelog
+++ b/changelog
@@ -1,3 +1,16 @@
1+2014-12-27 Daigo Moriwaki <daigo at debian dot org>
2+
3+ * [shogi-server]
4+ - When a non-rated player participates in Floodgate, the following exception
5+ was thrown and a Floodgate game would not start:
6+ undefined method `[]' for nil:NilClass
7+ ["/home/shogi-server/www/x/shogi_server/pairing.rb:499:in `block
8+ in calculate_diff_with_penalty'"
9+ This issue has been resolved. Only players who have player ID
10+ (i.e. those who log in with valid password) are now allowed to
11+ participate in Floodgate as the spec web page
12+ [http://shogi-server.sourceforge.jp/rating.html] describes.
13+
114 2014-11-30 Daigo Moriwaki <daigo at debian dot org>
215
316 * [mk_html]
--- a/shogi_server/league/floodgate.rb
+++ b/shogi_server/league/floodgate.rb
@@ -64,15 +64,23 @@ class League
6464 end
6565 end
6666
67- def match_game
68- log_message("Starting Floodgate games...: %s, %s" % [@game_name, @options])
67+ # Returns an array of players who are allowed to participate in this
68+ # Floodgate match
69+ #
70+ def select_players
6971 players = @league.find_all_players do |pl|
7072 pl.status == "game_waiting" &&
7173 game_name?(pl.game_name) &&
72- pl.sente == nil
74+ pl.sente == nil &&
75+ pl.rated? # Only players who have player ID can participate in Floodgate (rating match)
7376 end
77+ return players
78+ end
79+
80+ def match_game
81+ log_message("Starting Floodgate games...: %s, %s" % [@game_name, @options])
7482 logics = Pairing.send(@options[:pairing_factory], @options)
75- Pairing.match(players, logics)
83+ Pairing.match(select_players(), logics)
7684 end
7785
7886 #
--- a/test/TC_floodgate.rb
+++ b/test/TC_floodgate.rb
@@ -8,6 +8,15 @@ require 'test/mock_log_message'
88
99 $topdir = File.expand_path File.dirname(__FILE__)
1010
11+class SimplePlayer < ShogiServer::BasicPlayer
12+ attr_accessor :status
13+ def initialize
14+ super
15+ @status = "game_waiting"
16+ @game_name = "floodgate-900-0"
17+ end
18+end
19+
1120 class TestFloodgate < Test::Unit::TestCase
1221 def setup
1322 @fg = ShogiServer::League::Floodgate.new(nil)
@@ -32,6 +41,37 @@ class TestFloodgate < Test::Unit::TestCase
3241 assert(fg.game_name?("floodgate-3600-0"))
3342 end
3443
44+ def test_select_players
45+ league = ShogiServer::League.new(File.dirname(__FILE__))
46+ league.event = "test"
47+ league.setup_players_database
48+
49+ a = SimplePlayer.new
50+ a.win = 1
51+ a.loss = 2
52+ a.rate = 0
53+ a.name = "a"
54+ a.player_id = "a+123"
55+ b = SimplePlayer.new
56+ b.win = 10
57+ b.loss = 20
58+ b.rate = 1500
59+ b.name = "b"
60+ b.player_id = "b+456"
61+ c = SimplePlayer.new
62+ c.win = 100
63+ c.loss = 200
64+ c.rate = 1000
65+ c.name = "c"
66+
67+ league.add a
68+ league.add b
69+ league.add c
70+
71+ fg = ShogiServer::League::Floodgate.new(league, {:game_name => "floodgate-900-0"})
72+
73+ assert_equal([a,b], fg.select_players)
74+ end
3575 end
3676
3777 class TestDeleteMostPlayingPlayer < Test::Unit::TestCase