shogi-server source
Révision | 7499643a877678403aff293b55568ecf25130ab5 (tree) |
---|---|
l'heure | 2015-01-17 09:39:29 |
Auteur | Daigo Moriwaki <daigo@debi...> |
Commiter | Daigo Moriwaki |
Refactor ChessClockWithLeastZero
@@ -127,19 +127,7 @@ class ChessClockWithLeastZero < ChessClock | ||
127 | 127 | |
128 | 128 | def time_duration(mytime, start_time, end_time) |
129 | 129 | t = end_time - start_time |
130 | - if @byoyomi > 0 | |
131 | - # If the remaining thinking time covers the duration t, floor it. | |
132 | - if mytime + @byoyomi - t > 0 | |
133 | - t = t.floor | |
134 | - else | |
135 | - t = t.ceil | |
136 | - end | |
137 | - else | |
138 | - # Thinking time only | |
139 | - t = t.floor | |
140 | - end | |
141 | - | |
142 | - return t | |
130 | + return t.floor | |
143 | 131 | end |
144 | 132 | |
145 | 133 | def to_s |
@@ -76,7 +76,7 @@ class TestChessClockWithLeastZero < Test::Unit::TestCase | ||
76 | 76 | assert_equal(0, tc.time_duration(100, 100.1, 100.9)) # 0.8 |
77 | 77 | assert_equal(1, tc.time_duration(100, 100, 101)) # 1 |
78 | 78 | assert_equal(1, tc.time_duration(100, 100.1, 101.9)) # 1.8 |
79 | - assert_equal(1, tc.time_duration(1, 100, 101)) # 1 | |
79 | + assert_equal(1, tc.time_duration(1, 100, 101)) # 1 | |
80 | 80 | assert_equal(2, tc.time_duration(100, 100.1, 102.9)) # 2.8 |
81 | 81 | assert_equal(2, tc.time_duration(100, 100, 102)) # 2 |
82 | 82 | end |