shogi-server source
Revision | f4486250c63e92156665bff7b1bcd2c98b6f7e95 (tree) |
---|---|
Zeit | 2013-09-08 11:02:41 |
Autor | Daigo Moriwaki <beatles@user...> |
Commiter | Daigo Moriwaki |
[shogi-server] - shogi_server/{game,time_clock}.rb:
@@ -1,3 +1,10 @@ | ||
1 | +2013-09-08 Daigo Moriwaki <daigo at debian dot org> | |
2 | + | |
3 | + * [shogi-server] | |
4 | + - shogi_server/{game,time_clock}.rb: | |
5 | + When StopWatchClock is used, "Time_Unit:" of starting messages | |
6 | + in CSA protocol supplies "1min". | |
7 | + | |
1 | 8 | 2013-04-07 Daigo Moriwaki <daigo at debian dot org> |
2 | 9 | |
3 | 10 | * [shogi-server] |
@@ -364,7 +364,7 @@ Name-:#{@gote.name} | ||
364 | 364 | Rematch_On_Draw:NO |
365 | 365 | To_Move:+ |
366 | 366 | BEGIN Time |
367 | -Time_Unit:1sec | |
367 | +Time_Unit:#{@time_clock.time_unit} | |
368 | 368 | Total_Time:#{@total_time} |
369 | 369 | Byoyomi:#{@byoyomi} |
370 | 370 | Least_Time_Per_Move:#{Least_Time_Per_Move} |
@@ -398,7 +398,7 @@ Your_Turn:#{sg_flag} | ||
398 | 398 | Rematch_On_Draw:NO |
399 | 399 | To_Move:#{@board.teban ? "+" : "-"} |
400 | 400 | BEGIN Time |
401 | -Time_Unit:1sec | |
401 | +Time_Unit:#{@time_clock.time_unit} | |
402 | 402 | Total_Time:#{@total_time} |
403 | 403 | Byoyomi:#{@byoyomi} |
404 | 404 | Least_Time_Per_Move:#{Least_Time_Per_Move} |
@@ -53,6 +53,12 @@ class TimeClock | ||
53 | 53 | return 9999999 |
54 | 54 | end |
55 | 55 | |
56 | + # Returns what "Time_Unit:" in CSA protocol should provide. | |
57 | + # | |
58 | + def time_unit | |
59 | + return "1sec" | |
60 | + end | |
61 | + | |
56 | 62 | # If thinking time runs out, returns true; false otherwise. |
57 | 63 | # |
58 | 64 | def timeout?(player, start_time, end_time) |
@@ -106,6 +112,10 @@ class StopWatchClock < TimeClock | ||
106 | 112 | super |
107 | 113 | end |
108 | 114 | |
115 | + def time_unit | |
116 | + return "1min" | |
117 | + end | |
118 | + | |
109 | 119 | def time_duration(start_time, end_time) |
110 | 120 | t = [(end_time - start_time).floor, @least_time_per_move].max |
111 | 121 | return (t / @byoyomi) * @byoyomi |