StartGameWithoutHumans, which tries to make pairs trying to
avoid a human-human match. This is now enabled instread of the
previous class: StartGame.
+ - shogi-server, shogi_server/league/floodgate.rb:
+ Changed the argument of Floodgate.new.
2009-12-04 Daigo Moriwaki <daigo at debian dot org>
end
end
-def setup_floodgate
+def setup_floodgate_900
return Thread.start do
Thread.pass
- floodgate = ShogiServer::League::Floodgate.new($league)
+ game_name = "floodgate-900-0"
+ floodgate = ShogiServer::League::Floodgate.new($league,
+ {:game_name => game_name})
log_message("Flooddgate reloaded. The next match will start at %s." %
[floodgate.next_time])
log_message("Reloading source...")
ShogiServer.reload
end
- floodgate = ShogiServer::League::Floodgate.new($league, next_time)
+ floodgate = ShogiServer::League::Floodgate.new($league,
+ {:game_name => game_name,
+ :next_time => next_time})
log_message("Floodgate: The next match will start at %s." %
[floodgate.next_time])
rescue Exception => ex
end
setup_watchdog_for_giant_lock
$league.setup_players_database
- fg_thread = setup_floodgate
+ fg_thread = setup_floodgate_900
end
config[:StopCallback] = Proc.new do
attr_reader :next_time, :league
- def initialize(league, next_time=nil)
+ def initialize(league, hash={})
@league = league
- @next_time = next_time
+ @next_time = hash[:next_time] || nil
+ @game_name = hash[:game_name] || "floodgate-900-0"
charge
end
+ def game_name?(str)
+ return Regexp.new(@game_name).match(str) ? true : false
+ end
+
def charge
now = Time.now
unless $DEBUG
def match_game
players = @league.find_all_players do |pl|
pl.status == "game_waiting" &&
- Floodgate.game_name?(pl.game_name) &&
+ game_name?(pl.game_name) &&
pl.sente == nil
end
Pairing.match(players)