changeset 247:0bad554d0926

More tests, some cryo room fixes and docs in the build.
author Jeremy Thurgood <firxen@gmail.com>
date Fri, 27 Aug 2010 13:32:27 +0200
parents b6cfaad7deee
children 37f892b59c4b
files gamelib/scenes/cryo.py gamelib/tests/game_logic_utils.py gamelib/tests/test_scene_interactions_cryo.py scripts/build_unix.sh
diffstat 4 files changed, 71 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/gamelib/scenes/cryo.py	Fri Aug 27 13:25:42 2010 +0200
+++ b/gamelib/scenes/cryo.py	Fri Aug 27 13:32:27 2010 +0200
@@ -164,20 +164,27 @@
         }
 
     def interact_with_machete(self, item):
-        self.set_data('fixed', False)
-        pipe = CryoPipe('cryopipe')
-        self.state.add_item(pipe)
-        self.state.add_inventory_item(pipe.name)
-        self.set_interact("chopped")
+        if self.get_data('fixed'):
+            self.set_data('fixed', False)
+            pipe = CryoPipe('cryo_pipe')
+            self.state.add_item(pipe)
+            self.state.add_inventory_item(pipe.name)
+            self.set_interact("chopped")
+            return Result("It takes more effort than one would expect, but "
+                          "eventually the pipe is separated from the wall.")
 
     def is_interactive(self):
         return self.get_data('fixed')
 
+    def interact_without(self):
+        if self.get_data('fixed'):
+            return Result("These pipes aren't attached to the wall very solidly.")
+        return None
+
     def get_description(self):
         if self.get_data('fixed'):
             return "These pipes carry cooling fluid to the cryo units."
-        else:
-            return "There used to be a pipe carrying cooling fuild here"
+        return "There used to be a pipe carrying cooling fluid here"
 
 
 class CryoPipe(CloneableItem):
--- a/gamelib/tests/game_logic_utils.py	Fri Aug 27 13:25:42 2010 +0200
+++ b/gamelib/tests/game_logic_utils.py	Fri Aug 27 13:32:27 2010 +0200
@@ -46,6 +46,9 @@
     def assert_detail_thing(self, thing, in_detail=True):
         self.assertEquals(in_detail, thing in self.state.current_detail.things)
 
+    def assert_item_exists(self, item, exists=True):
+        self.assertEquals(exists, item in self.state.items)
+
     def interact_thing(self, thing, item=None, detail=False):
         item_obj = None
         if item is not None:
--- a/gamelib/tests/test_scene_interactions_cryo.py	Fri Aug 27 13:25:42 2010 +0200
+++ b/gamelib/tests/test_scene_interactions_cryo.py	Fri Aug 27 13:32:27 2010 +0200
@@ -86,3 +86,56 @@
 
         self.assertEquals('cryo_detail', resp.detail_view)
 
+    def test_pipes_unchopped_hand(self):
+        "Touch the unchopped cryopipes with the hand. No change."
+
+        self.assert_game_data('fixed', True, 'cryo.pipe.left')
+        self.assert_game_data('fixed', True, 'cryo.pipe.right')
+
+        self.assertNotEquals(None, self.interact_thing('cryo.pipe.left'))
+        self.assertNotEquals(None, self.interact_thing('cryo.pipe.right'))
+
+        self.assert_game_data('fixed', True, 'cryo.pipe.left')
+        self.assert_game_data('fixed', True, 'cryo.pipe.right')
+
+    def test_pipes_chopped_hand(self):
+        "Touch the chopped cryopipes with the hand. No change."
+
+        self.set_game_data('fixed', False, 'cryo.pipe.left')
+        self.set_game_data('fixed', False, 'cryo.pipe.right')
+
+        self.assertEquals(None, self.interact_thing('cryo.pipe.left'))
+        self.assertEquals(None, self.interact_thing('cryo.pipe.right'))
+
+        self.assert_game_data('fixed', False, 'cryo.pipe.left')
+        self.assert_game_data('fixed', False, 'cryo.pipe.right')
+
+    def test_pipes_unchopped_machete(self):
+        "Touch the unchopped cryopipes with the machete. They chop."
+
+        self.assert_game_data('fixed', True, 'cryo.pipe.left')
+        self.assert_game_data('fixed', True, 'cryo.pipe.right')
+        self.assert_item_exists('cryo_pipe.0', False)
+        self.assert_item_exists('cryo_pipe.1', False)
+
+        self.assertNotEquals(None, self.interact_thing('cryo.pipe.left', 'machete'))
+        self.assertNotEquals(None, self.interact_thing('cryo.pipe.right', 'machete'))
+
+        self.assert_game_data('fixed', False, 'cryo.pipe.left')
+        self.assert_game_data('fixed', False, 'cryo.pipe.right')
+        self.assert_item_exists('cryo_pipe.0')
+        self.assert_item_exists('cryo_pipe.1')
+        self.assert_inventory_item('cryo_pipe.0', True)
+        self.assert_inventory_item('cryo_pipe.1', True)
+
+    def test_pipes_chopped_machete(self):
+        "Touch the chopped cryopipes with the machete. No change."
+
+        self.set_game_data('fixed', False, 'cryo.pipe.left')
+        self.set_game_data('fixed', False, 'cryo.pipe.right')
+
+        self.assertEquals(None, self.interact_thing('cryo.pipe.left', 'machete'))
+        self.assertEquals(None, self.interact_thing('cryo.pipe.right', 'machete'))
+
+        self.assert_game_data('fixed', False, 'cryo.pipe.left')
+        self.assert_game_data('fixed', False, 'cryo.pipe.right')
--- a/scripts/build_unix.sh	Fri Aug 27 13:25:42 2010 +0200
+++ b/scripts/build_unix.sh	Fri Aug 27 13:32:27 2010 +0200
@@ -10,7 +10,7 @@
 rm -rf ${BUILD_FOLDER}
 mkdir -p ${BUILD_FOLDER} dist
 
-cp -r COPYING README.txt run_game.py setup.py gamelib Resources ${BUILD_FOLDER}/
+cp -r COPYING README.txt run_game.py setup.py docs gamelib Resources ${BUILD_FOLDER}/
 
 cd build