require 'shogi_server/league/floodgate'
require 'shogi_server/game_result'
+require 'shogi_server/util'
module ShogiServer # for a namespace
@prepared_time.strftime("%Y"),
@prepared_time.strftime("%m"),
@prepared_time.strftime("%d"))
- FileUtils.mkdir_p(log_dir_name) unless File.exist?(log_dir_name)
@logfile = File.join(log_dir_name, @game_id + ".csa")
+ Mkdir.mkdir_for(@logfile)
$league.games[@game_id] = self
end
# class Game
- def handle_one_move(str, player)
+ def handle_one_move(str, player, end_time)
unless turn?(player)
return false if str == :timeout
end
finish_flag = true
- @end_time = Time::new
+ @end_time = end_time
t = [(@end_time - @start_time).floor, Least_Time_Per_Move].max
move_status = nil
@result.process if @result
finish() if finish_flag
@current_player, @next_player = @next_player, @current_player
- @start_time = Time::new
+ @start_time = Time.now
return finish_flag
end
@gote.write_safe(sprintf("START:%s\n", @game_id))
@sente.mytime = @total_time
@gote.mytime = @total_time
- @start_time = Time::new
+ @start_time = Time.now
end
def propose
@sente.write_safe(propose_message("+"))
@gote.write_safe(propose_message("-"))
- now = Time::new.strftime("%Y/%m/%d %H:%M:%S")
+ now = Time.now.strftime("%Y/%m/%d %H:%M:%S")
@fh.puts("$START_TIME:#{now}")
@fh.print <<EOM
P1-KY-KE-GI-KI-OU-KI-GI-KE-KY
private
def issue_current_time
- time = Time::new.strftime("%Y%m%d%H%M%S").to_i
+ time = Time.now.strftime("%Y%m%d%H%M%S").to_i
@@mutex.synchronize do
while time <= @@time do
time += 1