• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
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

Revisão32adcedbca9b794239ae0d2c63fb248dc8102372 (tree)
Hora2013-12-26 23:52:35
AutorDaigo Moriwaki <daigo@debi...>
CommiterDaigo Moriwaki

Mensagem de Log

[shogi-server] - Previously, parameters in Floodgate time configuration file were not applied to actual instances. This issue has been fixed.

Mudança Sumário

Diff

--- a/changelog
+++ b/changelog
@@ -1,3 +1,9 @@
1+2013-12-26 Daigo Moriwaki <daigo at debian dot org>
2+
3+ * [shogi-server]
4+ - Previously, parameters in Floodgate time configuration file were
5+ not applied to actual instances. This issue has been fixed.
6+
17 2013-12-21 Daigo Moriwaki <daigo at debian dot org>
28
39 * [shogi-server]
--- a/shogi_server/league/floodgate.rb
+++ b/shogi_server/league/floodgate.rb
@@ -27,16 +27,17 @@ class League
2727 #
2828 attr_reader :next_time
2929 attr_reader :league, :game_name
30- attr_reader :pairing_factory
30+ attr_reader :pairing_factory, :sacrifice
3131 attr_reader :options
3232
3333 def initialize(league, hash={})
3434 @league = league
35- @next_time = hash[:next_time] || nil
36- @game_name = hash[:game_name] || "floodgate-900-0"
37- @pairing_factory = "default_factory" # will be updated by NextTimeGenerator
38- # Options will be updated by NextTimeGenerator
39- @options = {:sacrifice => "gps500+e293220e3f8a3e59f79f6b0efffaa931"}
35+ @next_time = hash[:next_time] || nil
36+ @game_name = hash[:game_name] || "floodgate-900-0"
37+ @pairing_factory = hash[:pairing_factory] || "default_factory" # will be updated by NextTimeGenerator
38+ @sacrifice = hash[:sacrifice] || "gps500+e293220e3f8a3e59f79f6b0efffaa931"
39+ # @options is passed to a pairing factory
40+ @options = {:sacrifice => @sacrifice}
4041 charge if @next_time.nil?
4142 end
4243
--- a/shogi_server/league/floodgate_thread.rb
+++ b/shogi_server/league/floodgate_thread.rb
@@ -68,15 +68,16 @@ module ShogiServer
6868 floodgate.match_game
6969 end
7070
71- # Regenerate floodgate instances from next_array for the next matches.
72- # @param next_array array of [game_name, next_time]
71+ # Regenerate floodgate instances from next_instances for the next matches.
72+ # @param next_instances array of [game_name, next_time]
7373 #
74- def regenerate_leagues(next_array)
75- leagues = next_array.collect do |game_name, next_time|
76- log_message("Regenerating a floodgate league...: %s %s" % [game_name, next_time])
74+ def regenerate_leagues(next_instances)
75+ leagues = next_instances.collect do |prev|
76+ log_message("Regenerating a floodgate league...: %s %s %s" %
77+ [prev.game_name, prev.next_time, prev.sacrifice])
7778 floodgate = ShogiServer::League::Floodgate.new($league,
78- {:game_name => game_name,
79- :next_time => next_time})
79+ {:game_name => prev.game_name, :next_time => prev.next_time,
80+ :pairing_factory => prev.pairing_factory, :sacrifice => prev.sacrifice})
8081 end
8182 floodgate_reload_log(leagues)
8283 return leagues
@@ -98,20 +99,18 @@ module ShogiServer
9899 floodgate = next_league(leagues)
99100 next if wait_next_floodgate(floodgate)
100101
101- next_array = leagues.collect do |floodgate|
102- if (floodgate.next_time - Time.now) > 0
103- [floodgate.game_name, floodgate.next_time]
104- else
102+ next_instances = leagues.collect do |floodgate|
103+ unless (floodgate.next_time - Time.now) > 0
105104 start_games(floodgate)
106105 floodgate.charge # updates next_time
107- [floodgate.game_name, floodgate.next_time]
108106 end
107+ floodgate
109108 end
110109
111110 reload_shogi_server
112111
113112 # Regenerate floodgate instances after ShogiServer.realod
114- leagues = regenerate_leagues(next_array)
113+ leagues = regenerate_leagues(next_instances)
115114 rescue Exception => ex
116115 # ignore errors
117116 log_error("[in Floodgate's thread] #{ex} #{ex.backtrace}")
--- a/test/TC_floodgate_thread.rb
+++ b/test/TC_floodgate_thread.rb
@@ -65,7 +65,13 @@ class TestSetupFloodgate < Test::Unit::TestCase
6565 def test_regenerate_leagues
6666 game_names = %w(floodgate-900-0 floodgate-3600-0)
6767 now = Time.now
68- next_array = [["floodgate-900-0", now+100], ["floodgate-3600-0", now+200]]
68+ next_array = []
69+ next_array << ShogiServer::League::Floodgate.new($league,
70+ {:game_name => "floodgate-900-0",
71+ :next_time => (now+100)})
72+ next_array << ShogiServer::League::Floodgate.new($league,
73+ {:game_name => "floodgate-3600-0",
74+ :next_time => (now+200)})
6975 objs = @sf.regenerate_leagues(next_array)
7076 assert_equal 2, objs.size
7177 assert_instance_of ShogiServer::League::Floodgate, objs[0]