changeset 80:fd7545415b98

starting on scoring.
author Rene Dudfield <renesd@gmail.com>
date Sun, 08 Jul 2012 13:13:58 +0200
parents 502d90179d56
children c291f10cb3de
files README.rst zrpn/board.py zrpn/server.py
diffstat 3 files changed, 15 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/README.rst	Sun Jul 08 13:02:32 2012 +0200
+++ b/README.rst	Sun Jul 08 13:13:58 2012 +0200
@@ -95,6 +95,8 @@
 
 
 
+scoring
+~~~~~~~
 
 Lose points when remove a piece.
 Gain points when you create a connection.
--- a/zrpn/board.py	Sun Jul 08 13:02:32 2012 +0200
+++ b/zrpn/board.py	Sun Jul 08 13:13:58 2012 +0200
@@ -73,6 +73,7 @@
                             self.board[y][i] = 0
                             self.die((i, y), turn, animations)
                         killed += 1
+                        animations.append(('collumn_row', None, turn))
                     count = 1
                 last_cell = cell
             
@@ -97,6 +98,8 @@
                             self.board[i][x] = 0
                             self.die((x, i), turn, animations)
                         killed += 1
+                        animations.append(('collumn_row', None, turn))
+                        
                     count = 1
                 last_cell = cell
         return animations
--- a/zrpn/server.py	Sun Jul 08 13:02:32 2012 +0200
+++ b/zrpn/server.py	Sun Jul 08 13:13:58 2012 +0200
@@ -20,6 +20,16 @@
         animations = self.board.kill_one(packet)
         animations.extend(self.board.update())
         self.connection.net_score(self.scores[self], max(self.scores.values()))
+        #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?
+        if collumn_rows:
+            for cr in collumn_rows:
+                self.scores[self] += 20
+        else:
+            self.scores[self] -= 1
+
         for connection in self.server.peers.values():
             connection.net_animations(animations)