OSDN Git Service

Fix #36230: Support Fischer Time Control
[shogi-server/shogi-server.git] / shogi_server / login.rb
index 4cee31c..54e8c25 100644 (file)
@@ -1,7 +1,7 @@
 ## $Id$
 
 ## Copyright (C) 2004 NABEYA Kenichi (aka nanami@2ch)
-## Copyright (C) 2007-2008 Daigo Moriwaki (daigo at debian dot org)
+## Copyright (C) 2007-2012 Daigo Moriwaki (daigo at debian dot org)
 ##
 ## This program is free software; you can redistribute it and/or modify
 ## it under the terms of the GNU General Public License as published by
@@ -38,7 +38,7 @@ class Login
   end
 
   def Login.good_game_name?(str)
-    if ((str =~ /^(.+)-\d+-\d+$/) && (good_identifier?($1)))
+    if ((str =~ /^(.+)-\d+-\d+F?$/) && (good_identifier?($1)))
       return true
     else
       return false
@@ -79,7 +79,7 @@ class Login
   end
 
   def Login.good_identifier?(str)
-    if str =~ /\A[\w\d_@\-\.]{1,#{Max_Identifier_Length}}\z/
+    if str =~ /\A[\w@\-\.]{1,#{Max_Identifier_Length}}\z/
       return true
     else
       return false
@@ -109,7 +109,8 @@ class Login
 
   def process
     @player.write_safe(sprintf("LOGIN:%s OK\n", @player.name))
-    log_message(sprintf("user %s run in %s mode", @player.name, @player.protocol))
+    log_message("user %s run in %s mode" % [(@player.rated? ? @player.player_id : @player.name),
+                                            @player.protocol])
   end
 
   def incorrect_duplicated_player(str)
@@ -148,7 +149,7 @@ class LoginCSA < Login
   # turn character "+" or "-"; false otherwise
   #
   def parse_gamename_turn(str)
-    if str =~ /^(.+)-\d+-\d+-(\w)$/
+    if str =~ /^(.+)-\d+-\d+F?-(\w)$/
       case $2
       when "b","B"
         return [str[0, str.length-2], "+"]