OSDN Git Service

- shogi-server, shogi_server/league/floodgate.rb: Changed the argument of Floodgate...
authorbeatles <beatles@b8c68f68-1e22-0410-b08e-880e1f8202b4>
Sat, 26 Dec 2009 01:40:18 +0000 (01:40 +0000)
committerbeatles <beatles@b8c68f68-1e22-0410-b08e-880e1f8202b4>
Sat, 26 Dec 2009 01:40:18 +0000 (01:40 +0000)
changelog
shogi-server
shogi_server/league/floodgate.rb

index 61140dc..4ab7a46 100644 (file)
--- a/changelog
+++ b/changelog
@@ -9,6 +9,8 @@
            StartGameWithoutHumans, which tries to make pairs trying to
            avoid a human-human match. This is now enabled instread of the
            previous class: StartGame.
            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>
 
 
 2009-12-04 Daigo Moriwaki <daigo at debian dot org>
 
index e65c9f0..54c4342 100755 (executable)
@@ -307,10 +307,12 @@ def setup_watchdog_for_giant_lock
   end
 end
 
   end
 end
 
-def setup_floodgate
+def setup_floodgate_900
   return Thread.start do 
     Thread.pass
   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("Flooddgate reloaded. The next match will start at %s." % 
                 [floodgate.next_time])
 
@@ -329,7 +331,9 @@ def setup_floodgate
           log_message("Reloading source...")
           ShogiServer.reload
         end
           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 
         log_message("Floodgate: The next match will start at %s." % 
                     [floodgate.next_time])
       rescue Exception => ex 
@@ -370,7 +374,7 @@ def main
     end
     setup_watchdog_for_giant_lock
     $league.setup_players_database
     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
   end
 
   config[:StopCallback] = Proc.new do
index aeab05c..4f6ac2b 100644 (file)
@@ -16,12 +16,17 @@ class League
 
     attr_reader :next_time, :league
 
 
     attr_reader :next_time, :league
 
-    def initialize(league, next_time=nil)
+    def initialize(league, hash={})
       @league = league
       @league = league
-      @next_time = next_time
+      @next_time = hash[:next_time] || nil
+      @game_name = hash[:game_name] || "floodgate-900-0"
       charge
     end
 
       charge
     end
 
+    def game_name?(str)
+      return Regexp.new(@game_name).match(str) ? true : false
+    end
+
     def charge
       now = Time.now
       unless $DEBUG
     def charge
       now = Time.now
       unless $DEBUG
@@ -44,7 +49,7 @@ class League
     def match_game
       players = @league.find_all_players do |pl|
         pl.status == "game_waiting" &&
     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)
         pl.sente == nil
       end
       Pairing.match(players)