changeset 65:5c4c67673112

Display available points
author Neil Muller <drnlmuller@gmail.com>
date Tue, 08 May 2012 21:06:08 +0200
parents 24f0707695b4
children 43b34b013462
files gamelib/gamegui.py
diffstat 1 files changed, 23 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/gamelib/gamegui.py	Tue May 08 21:05:54 2012 +0200
+++ b/gamelib/gamegui.py	Tue May 08 21:06:08 2012 +0200
@@ -6,7 +6,7 @@
 from pygame import image
 
 from gamelib.data import filepath
-from gamelib.gui_base import Window, font_small
+from gamelib.gui_base import Window, TextLabel, font_small, font_medium
 from gamelib.gui import BigButton
 from gamelib.engine import PopWindow
 from gamelib.constants import WIDTH
@@ -64,6 +64,7 @@
                     self.science.points, self.points)
             self._draw_text()
             self.parent.game.cur_allocation.append(self.science)
+            self.parent.update_points()
 
     def reset(self):
         while self.points > 0:
@@ -71,6 +72,18 @@
             self.points -= 1
         self.text = '%s: %d' % (self.science.NAME, self.science.points)
         self._draw_text()
+        self.parent.update_points()
+
+
+class PointsLabel(TextLabel):
+
+    def __init__(self):
+        super(PointsLabel, self).__init__((10, 70, 300, 50),
+                'Available Human Resources : 0', font_medium, (255, 255, 0))
+
+    def set_value(self, value):
+        self.text = 'Available Human Resource : %d' % value
+        self._draw_text()
 
 
 class LabWindow(Window):
@@ -86,10 +99,13 @@
         reset = ResetButton(self)
         self.add_child(reset)
 
-        self.game.start_turn()
+        self.points = PointsLabel()
+        self.add_child(self.points)
 
         self._sciences = []
-
+        # Setup for the first turn
+        self.game.start_turn()
+        self.update_points()
         self._make_science_widgets()
 
     def _make_science_widgets(self):
@@ -113,6 +129,10 @@
         self._sciences = []
         self._make_science_widgets()
         self.game.start_turn()
+        self.update_points()
+
+    def update_points(self):
+        self.points.set_value(self.game.get_available_points())
 
     def reset(self):
         for widget in self._sciences: