OSDN Git Service

The 'test' directory has been moved under 'shogi-server'
[shogi-server/shogi-server.git] / pairing.rb
index b922aa4..6a922d8 100644 (file)
@@ -4,8 +4,8 @@ module ShogiServer
 
     class << self
       def default_pairing
-        return SwissPairing.new
-        #return ExcludeSacrifice.new(SwissPairing.new)
+        #return SwissPairing.new
+        return ExcludeSacrifice.new(SwissPairing.new)
         #return RandomPairing.new
         #return ExcludeSacrifice.new(RandomPairing.new)
       end
@@ -27,6 +27,10 @@ module ShogiServer
       Game.new(p1.game_name, p1, p2)
     end
 
+    def include_newbie?(players)
+      return players.find{|a| a.rate == 0} == nil ? false : true
+    end
+
     def delete_player_at_random(players)
       return players.delete_at(rand(players.size))
     end
@@ -90,7 +94,11 @@ module ShogiServer
       remains     = players - win_players
       if win_players.size >= 2
         if win_players.size % 2 == 1
-          remains << delete_least_rate_player(win_players)
+#          if include_newbie?(win_players)
+            remains << delete_player_at_random(win_players)
+#          else
+#            remains << delete_least_rate_player(win_players)
+#          end
         end         
         pairing_and_start_game(win_players)
       else
@@ -116,9 +124,9 @@ module ShogiServer
     def match(players)
       if @sacrifice && 
          players.size % 2 == 1 && 
-         players.find{|a| a.id == @sacrifice}
+         players.find{|a| a.player_id == @sacrifice}
         log_message("Floodgate: first, exclude %s" % [@sacrifice])
-        players.delete_if{|a| a.id == @sacrifice}
+        players.delete_if{|a| a.player_id == @sacrifice}
       end
       @pairing.match(players)
     end