Mercurial > zrpn
changeset 83:0683012417ec
extra points for killing more than five at once
| author | Michael Rochseter <m.rochester93@googlemail.com> |
|---|---|
| date | Sun, 08 Jul 2012 13:57:27 +0200 |
| parents | 3f05c9bd5ad0 |
| children | 5f4c71bedf21 35f4c26609fc |
| files | zrpn/board.py zrpn/main.py zrpn/server.py |
| diffstat | 3 files changed, 18 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/zrpn/board.py Sun Jul 08 13:16:05 2012 +0200 +++ b/zrpn/board.py Sun Jul 08 13:57:27 2012 +0200 @@ -13,15 +13,17 @@ def update(self): animations = [] + extra = [] turns = 0 animations.extend(self.apply_gravity(turns)) while True: turns += 1 - killed = self.kill_groups(turns) + killed, ex = self.kill_groups(turns) + extra.extend(ex) animations.extend(killed) animations.extend(self.apply_gravity(turns)) if not killed: - return animations + return animations, extra def apply_gravity(self, turn): @@ -59,6 +61,7 @@ def kill_groups(self, turn): animations = [] + extra = [] GROUP_SIZE = 5 killed = 0 for y, line in enumerate(self.board): @@ -74,6 +77,7 @@ self.die((i, y), turn, animations) killed += 1 animations.append(('collumn_row', None, turn)) + extra.append(((count+1) - GROUP_SIZE)) count = 1 last_cell = cell @@ -99,10 +103,10 @@ self.die((x, i), turn, animations) killed += 1 animations.append(('collumn_row', None, turn)) - + extra.append(((count+1) - GROUP_SIZE)) count = 1 last_cell = cell - return animations + return animations, extra def check_neighbours(self, y, x, checked=None, mons=None, points=None,):
--- a/zrpn/main.py Sun Jul 08 13:16:05 2012 +0200 +++ b/zrpn/main.py Sun Jul 08 13:57:27 2012 +0200 @@ -22,7 +22,7 @@ self.display.load_board(self.board.board, self.board.cells) def run(self): - animations = self.board.update() + animations, extra = self.board.update() self.display.do_animations(animations) while True: for event in pygame.event.get(): @@ -32,7 +32,8 @@ x, y = event.pos[0] // 24, event.pos[1] // 24 animations = [] animations.extend(self.board.kill_one((x, y))) - animations.extend(self.board.update()) + ans, extra = self.board.update() + animations.extend(ans) self.display.do_animations(animations) self.display.frame()
--- a/zrpn/server.py Sun Jul 08 13:16:05 2012 +0200 +++ b/zrpn/server.py Sun Jul 08 13:57:27 2012 +0200 @@ -18,20 +18,23 @@ return self.click_time = t animations = self.board.kill_one(packet) - animations.extend(self.board.update()) + ans, extra = self.board.update() + animations.extend(ans) #TODO: scoring. check for animations of kind == 'collumn_row' collumn_rows = [a for a in animations if a[0] == 'collumn_row'] #TODO: who gets the points? + print collumn_rows + print extra if collumn_rows: - for cr in collumn_rows: - self.scores[self] += 20 + for x, cr in enumerate(collumn_rows): + self.scores[self] += 20 + (10*extra[x]) else: self.scores[self] -= 1 - self.connection.net_score(self.scores[self], max(self.scores.values())) for connection in self.server.peers.values(): connection.net_animations(animations) + connection.net_score(self.scores[connection._receivers[0]], max(self.scores.values())) def on_connect(self): self.connection.net_init(self.board.board, self.board.cells)
