|
|
@ -250,7 +250,9 @@ class TestTtrsPlayer(TtrsPlayer): |
|
|
|
self.__process_events() |
|
|
|
self.__process_events() |
|
|
|
return self.__quit |
|
|
|
return self.__quit |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def reset_rotate(self): |
|
|
|
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|
class BalanceTtrsPlayer(TtrsPlayer): |
|
|
|
class BalanceTtrsPlayer(TtrsPlayer): |
|
|
|
def __init__(self, playground, addr, player_id): |
|
|
|
def __init__(self, playground, addr, player_id): |
|
|
|
self.playground = playground |
|
|
|
self.playground = playground |
|
|
@ -355,16 +357,32 @@ class TtrsGame(): |
|
|
|
to_remove.add(y) |
|
|
|
to_remove.add(y) |
|
|
|
|
|
|
|
|
|
|
|
if len(to_remove) > 0: |
|
|
|
if len(to_remove) > 0: |
|
|
|
|
|
|
|
to_delete = set() |
|
|
|
for b in list(self.playground.blocks): |
|
|
|
for b in list(self.playground.blocks): |
|
|
|
if b.pos.y in to_remove: |
|
|
|
if b.pos.y in to_remove: |
|
|
|
|
|
|
|
to_delete.add(Block(b.pos, (255, 255, 255))) |
|
|
|
self.playground.blocks.remove(b) |
|
|
|
self.playground.blocks.remove(b) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for i in range(2): |
|
|
|
|
|
|
|
for b in to_delete: |
|
|
|
|
|
|
|
self.playground.blocks.add(b) |
|
|
|
|
|
|
|
for cb in self.tick_callbacks: |
|
|
|
|
|
|
|
cb() |
|
|
|
|
|
|
|
time.sleep(0.2) |
|
|
|
|
|
|
|
for b in to_delete: |
|
|
|
|
|
|
|
self.playground.blocks.remove(b) |
|
|
|
|
|
|
|
for cb in self.tick_callbacks: |
|
|
|
|
|
|
|
cb() |
|
|
|
|
|
|
|
time.sleep(0.2) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
to_add = set() |
|
|
|
for b in list(self.playground.blocks): |
|
|
|
for b in list(self.playground.blocks): |
|
|
|
o = len(list(filter(lambda y: y > b.pos.y, to_remove))) |
|
|
|
o = len(list(filter(lambda y: y > b.pos.y, to_remove))) |
|
|
|
if o > 0: |
|
|
|
if o > 0: |
|
|
|
self.playground.blocks.remove(b) |
|
|
|
self.playground.blocks.remove(b) |
|
|
|
newb = Block(b.pos + Point(0, o), b.color) |
|
|
|
newb = Block(b.pos + Point(0, o), b.color) |
|
|
|
self.playground.blocks.add(newb) |
|
|
|
to_add.add(newb) |
|
|
|
|
|
|
|
self.playground.blocks.update(to_add) |
|
|
|
|
|
|
|
|
|
|
|
if ticks - lastfall >= FALL_INTERVAL or self.player.get_drop(): |
|
|
|
if ticks - lastfall >= FALL_INTERVAL or self.player.get_drop(): |
|
|
|
lastfall = ticks |
|
|
|
lastfall = ticks |
|
|
@ -390,13 +408,6 @@ class TtrsGame(): |
|
|
|
self.player.reset_rotate() |
|
|
|
self.player.reset_rotate() |
|
|
|
except InvalidMoveError: |
|
|
|
except InvalidMoveError: |
|
|
|
pass |
|
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__': |
|
|
|
if __name__ == '__main__': |
|
|
|