shogi-server source
Révision | 756e4372c5b0b439c2b1221ab27c8e763c2bfc6d (tree) |
---|---|
l'heure | 2015-01-12 20:48:51 |
Auteur | Daigo Moriwaki <daigo@debi...> |
Commiter | Daigo Moriwaki |
Merge branch 'wdoor-stable'
Conflicts:
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 | + | |
1 | 14 | 2014-12-23 Daigo Moriwaki <daigo at debian dot org> |
2 | 15 | |
3 | 16 | * [shogi-server] |
@@ -6,6 +19,11 @@ | ||
6 | 19 | has now been fixed. |
7 | 20 | Thanks to Hiraoka-san for debugging. |
8 | 21 | |
22 | +2014-11-30 Daigo Moriwaki <daigo at debian dot org> | |
23 | + | |
24 | + * [mk_html] | |
25 | + - Corrected a url. | |
26 | + | |
9 | 27 | 2014-11-24 Daigo Moriwaki <daigo at debian dot org> |
10 | 28 | |
11 | 29 | * Ruby 2.0: |
@@ -172,7 +172,7 @@ def main | ||
172 | 172 | %> |
173 | 173 | <tr class="<%=player_decoration%>"> |
174 | 174 | <td class="name"> |
175 | - <a id="popup<%=popup_id+=1%>" href="http://wdoor.c.u-tokyo.ac.jp/shogi/tools/view/show-player.cgi?event=LATEST&filter=floodgate&show_self_play=1&user=<%=u key%>"><%= h yaml[key]['name'] %></a> | |
175 | + <a id="popup<%=popup_id+=1%>" href="http://wdoor.c.u-tokyo.ac.jp/shogi/view/show-player.cgi?event=LATEST&filter=floodgate&show_self_play=1&user=<%=u key%>"><%= h yaml[key]['name'] %></a> | |
176 | 176 | <script type="text/javascript"> |
177 | 177 | var tooltip<%=popup_id%> = new YAHOO.widget.Tooltip("myTooltip", { |
178 | 178 | context:"popup<%=popup_id%>", |
@@ -64,15 +64,23 @@ class League | ||
64 | 64 | end |
65 | 65 | end |
66 | 66 | |
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 | |
69 | 71 | players = @league.find_all_players do |pl| |
70 | 72 | pl.status == "game_waiting" && |
71 | 73 | 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) | |
73 | 76 | end |
77 | + return players | |
78 | + end | |
79 | + | |
80 | + def match_game | |
81 | + log_message("Starting Floodgate games...: %s, %s" % [@game_name, @options]) | |
74 | 82 | logics = Pairing.send(@options[:pairing_factory], @options) |
75 | - Pairing.match(players, logics) | |
83 | + Pairing.match(select_players(), logics) | |
76 | 84 | end |
77 | 85 | |
78 | 86 | # |
@@ -8,6 +8,15 @@ require 'test/mock_log_message' | ||
8 | 8 | |
9 | 9 | $topdir = File.expand_path File.dirname(__FILE__) |
10 | 10 | |
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 | + | |
11 | 20 | class TestFloodgate < Test::Unit::TestCase |
12 | 21 | def setup |
13 | 22 | @fg = ShogiServer::League::Floodgate.new(nil) |
@@ -32,6 +41,37 @@ class TestFloodgate < Test::Unit::TestCase | ||
32 | 41 | assert(fg.game_name?("floodgate-3600-0")) |
33 | 42 | end |
34 | 43 | |
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 | |
35 | 75 | end |
36 | 76 | |
37 | 77 | class TestDeleteMostPlayingPlayer < Test::Unit::TestCase |