changeset 539:11530992924a

PEP8 clean-up for engine, machine and mess.
author Simon Cross <hodgestar+bzr@gmail.com>
date Sat, 11 Feb 2012 12:20:12 +0200
parents d1b86d5849a0
children e0d2ec1d9720
files gamelib/scenes/engine.py gamelib/scenes/machine.py gamelib/scenes/mess.py
diffstat 3 files changed, 105 insertions(+), 64 deletions(-) [+]
line wrap: on
line diff
--- a/gamelib/scenes/engine.py	Sat Feb 11 12:15:31 2012 +0200
+++ b/gamelib/scenes/engine.py	Sat Feb 11 12:20:12 2012 +0200
@@ -18,7 +18,7 @@
 
     INITIAL_DATA = {
         'engine online': False,
-        'greet' : True,
+        'greet': True,
         }
 
     def __init__(self, state):
@@ -64,7 +64,8 @@
             )
         ))
         self.add_thing(GenericDescThing('engine.empty_cans', 7,
-            "Empty chocolate-covered bacon cans? Poor guy, he must have found them irresistible.",
+            "Empty chocolate-covered bacon cans? Poor guy, he must have"
+            " found them irresistible.",
             (
                 (562, 422, 30, 31),
             )
@@ -76,7 +77,8 @@
             )
         ))
         self.add_thing(GenericDescThing('engine.laser_cutter', 9,
-            "A burned-out laser cutter. It may be responsible for the hole in the floor.",
+            "A burned-out laser cutter. It may be responsible for the"
+            " hole in the floor.",
             (
                 (120, 466, 115, 67),
             )
@@ -102,7 +104,8 @@
             )
         ))
         self.add_thing(GenericDescThing('engine.spare_fuel_line', 11,
-            "The spare fuel line. If something went wrong with the main one, you would hook that one up.",
+            "The spare fuel line. If something went wrong with the main"
+            " one, you would hook that one up.",
             (
                 (512, 49, 68, 44),
             )
@@ -128,16 +131,19 @@
             self.remove_thing(self.things['engine.engines.8'])
             self.add_thing(Engines())
             return make_jim_dialog("The engines are now operational. You have"
-                                   "done a satisfactory job, Prisoner %s." % PLAYER_ID,
+                                   "done a satisfactory job, Prisoner %s."
+                                   % PLAYER_ID,
                                    self.state)
 
     def enter(self):
         if self.get_data('greet'):
             self.set_data('greet', False)
             return Result(
-                    "With your improvised helmet, the automatic airlock allows you into the engine room. Even if there wasn't a vacuum "
+                    "With your improvised helmet, the automatic airlock allows"
+                    " you into the engine room. Even if there wasn't a vacuum "
                     "it would be eerily quiet.")
 
+
 class Engines(Thing):
     NAME = 'engine.engines'
 
@@ -196,7 +202,8 @@
 
     def get_description(self):
         if self.get_data('present') and not self.get_data('working'):
-            return "That superconductor looks burned out. It's wedged in there pretty firmly."
+            return ("That superconductor looks burned out. It's wedged"
+                    " in there pretty firmly.")
         elif not self.get_data('present'):
             return "An empty superconductor socket"
         else:
@@ -204,20 +211,23 @@
 
     def interact_without(self):
         if self.get_data('present') and not self.get_data('working'):
-            return Result("It's wedged in there pretty firmly, it won't come out.")
+            return Result("It's wedged in there pretty firmly, it won't"
+                          " come out.")
         elif self.get_data('working'):
-            return Result("You decide that working engines are more important than having a shiny superconductor.")
+            return Result("You decide that working engines are more important"
+                          " than having a shiny superconductor.")
 
     def interact_with_machete(self, item):
         if self.get_data('present') and not self.get_data('working'):
             self.set_interact('removed')
             self.set_data('present', False)
-            return Result("With leverage, the burned-out superconductor snaps out. "
-                          "You discard it.")
+            return Result("With leverage, the burned-out superconductor"
+                          " snaps out. You discard it.")
 
     def interact_with_superconductor(self, item):
         if self.get_data('present'):
-            return Result("It might help to remove the broken superconductor first")
+            return Result("It might help to remove the broken"
+                          " superconductor first")
         else:
             return Result("You plug in the superconductor, and feel a hum "
                           "as things kick into life. "
@@ -235,7 +245,8 @@
             results.append(self.scene.engine_online_check())
             return results
         else:
-            return Result("It might help to remove the broken superconductor first.")
+            return Result("It might help to remove the broken superconductor"
+                          " first.")
 
 
 class CryoContainers(Thing):
@@ -269,7 +280,7 @@
             (132, 250, 56, 28),
             (184, 258, 42, 30),
             (219, 267, 42, 24),
-        ))
+        )),
     }
 
     INITIAL = 'containers'
@@ -379,7 +390,7 @@
             'arrow_top_left_1.png', 'arrow_top_left_2.png',
             'arrow_top_left_3.png', 'arrow_top_left_4.png',
             ), 15,
-        )
+        ),
     }
 
     INITIAL = 'arrows'
@@ -396,7 +407,7 @@
             'arrow_bottom_left_1.png', 'arrow_bottom_left_2.png',
             'arrow_bottom_left_3.png', 'arrow_bottom_left_4.png',
             ), 16,
-        )
+        ),
     }
 
     INITIAL = 'arrows'
@@ -413,7 +424,7 @@
             'arrow_right_1.png', 'arrow_right_2.png',
             'arrow_right_3.png', 'arrow_right_4.png',
             ), 17,
-        )
+        ),
     }
 
     INITIAL = 'arrows'
@@ -429,7 +440,7 @@
         'sign': InteractAnimated(299, 341, (
             'danger_dim.png', 'danger_bright.png',
             ), 10,
-        )
+        ),
     }
 
     INITIAL = 'sign'
@@ -443,9 +454,10 @@
 
     INTERACTS = {
         'stars': InteractAnimated(287, 455,
-            ['stars_%d.png' % (i+1) for i in range(5) + range(3,0,-1)],
+            ['stars_%d.png' % (i + 1) for i
+             in range(5) + range(3, 0, -1)],
             30,
-        )
+        ),
     }
 
     INITIAL = 'stars'
@@ -516,9 +528,9 @@
     NAME = "engine_comp_detail"
 
     ALERTS = {
-            'cryo leaking' : 'ec_cryo_leaking.png',
-            'cryo empty' : 'ec_cryo_reservoir_empty.png',
-            'super malfunction' : 'ec_cryo_super_malfunction.png',
+            'cryo leaking': 'ec_cryo_leaking.png',
+            'cryo empty': 'ec_cryo_reservoir_empty.png',
+            'super malfunction': 'ec_cryo_super_malfunction.png',
             }
 
     # Point to start drawing changeable alerts
@@ -534,15 +546,16 @@
 
     def _draw_alerts(self, surface):
         xpos, ypos = self.ALERT_OFFSET
-        if not self.state.scenes['engine'].things['engine.cracked_pipe'].get_data('fixed'):
+        engine = self.state.scenes['engine']
+        if not engine.things['engine.cracked_pipe'].get_data('fixed'):
             image = self._alert_messages['cryo leaking']
             surface.blit(image, (xpos, ypos))
             ypos += image.get_size()[1] + self.ALERT_SPACING
-        if not self.state.scenes['engine'].things['engine.cryo_containers'].get_data('filled'):
+        if not engine.things['engine.cryo_containers'].get_data('filled'):
             image = self._alert_messages['cryo empty']
             surface.blit(image, (xpos, ypos))
             ypos += image.get_size()[1] + self.ALERT_SPACING
-        if not self.state.scenes['engine'].things['engine.superconductor'].get_data('working'):
+        if not engine.things['engine.superconductor'].get_data('working'):
             image = self._alert_messages['super malfunction']
             surface.blit(image, (xpos, ypos))
             ypos += image.get_size()[1] + self.ALERT_SPACING
--- a/gamelib/scenes/machine.py	Sat Feb 11 12:15:31 2012 +0200
+++ b/gamelib/scenes/machine.py	Sat Feb 11 12:20:12 2012 +0200
@@ -69,7 +69,7 @@
                 (605, 304, 26, 8),
             )))
         self.add_thing(GenericDescThing("machine.drill_press_block", 7,
-            "The block for the laser drill press", # TODO: fix description
+            "The block for the laser drill press",  # TODO: fix description
             ((461, 446, 38, 27),)))
 
 
@@ -133,12 +133,14 @@
         self.state.remove_inventory_item(item.name)
         contents.add("tube")
         self.update_contents()
-        return Result("You carefully place the tube fragments in the laser welder.")
+        return Result("You carefully place the tube fragments in the"
+                      " laser welder.")
 
     def get_description(self):
         contents = self.get_data('contents')
         if not contents:
-            return "This is a Smith and Wesson 'zOMG' class high-precision laser welder."
+            return ("This is a Smith and Wesson 'zOMG' class high-precision"
+                    " laser welder.")
         if len(contents) == 1:
             msg = "The laser welder looks hungry, somehow."
             if "can" in contents:
@@ -148,7 +150,8 @@
         elif len(contents) == 2:
             msg = "The laser welder looks expectant. "
             if "can" in contents and "tube" in contents:
-                msg += " It currently contains an empty can and a tube fragment."
+                msg += (" It currently contains an empty can and a"
+                        " tube fragment.")
         return msg
 
 
@@ -163,34 +166,43 @@
     INITIAL = "button"
 
     def interact_without(self):
-        contents = self.scene.things["machine.welder.slot"].get_data("contents")
+        welder_slot = self.scene.things["machine.welder.slot"]
+        contents = welder_slot.get_data("contents")
         if not contents:
-            return Result("The laser welder doesn't currently contain anything weldable.")
+            return Result("The laser welder doesn't currently contain"
+                          " anything weldable.")
         elif len(contents) == 1:
             if "can" in contents:
-                return Result("The laser welder needs something to weld the can to.")
+                return Result("The laser welder needs something to weld the"
+                              " can to.")
             elif "tube" in contents:
-                return Result("The laser welder needs something to weld the tube fragments to.")
+                return Result("The laser welder needs something to weld the"
+                              " tube fragments to.")
         else:
-            self.scene.things["machine.welder.slot"].set_data("contents", set())
-            self.scene.things["machine.welder.slot"].update_contents()
+            welder_slot.set_data("contents", set())
+            welder_slot.update_contents()
             if self.state.items["cryo_pipes_one"] in self.state.inventory:
-                self.state.replace_inventory_item("cryo_pipes_one", "cryo_pipes_two")
+                self.state.replace_inventory_item("cryo_pipes_one",
+                                                  "cryo_pipes_two")
                 return Result("With high-precision spitzensparken, you weld"
-                        " together a second pipe. You bundle the two pipes together.",
+                              " together a second pipe. You bundle the two"
+                              " pipes together.",
                         soundfile='laser.ogg')
             elif self.state.items["cryo_pipes_two"] in self.state.inventory:
-                self.state.replace_inventory_item("cryo_pipes_two", "cryo_pipes_three")
-                return Result("With high-precision spitzensparken, you create yet"
-                        " another pipe. You store it with the other two.",
+                self.state.replace_inventory_item("cryo_pipes_two",
+                                                  "cryo_pipes_three")
+                return Result("With high-precision spitzensparken, you create"
+                              " yet another pipe. You store it with the other"
+                              " two.",
                         soundfile='laser.ogg')
             elif self.state.items["cryo_pipes_three"] in self.state.inventory:
                 # just for safety
                 return None
             else:
                 self.state.add_inventory_item("cryo_pipes_one")
-                return Result("With high-precision spitzensparken, the can and tube are welded"
-                        " into a whole greater than the sum of the parts.",
+                return Result("With high-precision spitzensparken, the can and"
+                              " tube are welded into a whole greater than the"
+                              " sum of the parts.",
                         soundfile='laser.ogg')
 
 
@@ -199,7 +211,9 @@
     NAME = "machine.welder.lights"
 
     INTERACTS = {
-        "lights": InteractAnimated(199, 273, ["power_lights_%d.png" % i for i in range(8) + range(6,0,-1)], 10)
+        "lights": InteractAnimated(199, 273, ["power_lights_%d.png" % i for i
+                                              in range(8) + range(6, 0, -1)],
+                                   10),
     }
 
     INITIAL = 'lights'
@@ -243,7 +257,8 @@
     INITIAL = "grind"
 
     def interact_without(self):
-        return Result("It looks like it eats fingers. Perhaps a different approach is in order?")
+        return Result("It looks like it eats fingers. Perhaps a different"
+                      " approach is in order?")
 
     def interact_with_titanium_leg(self, item):
         self.state.replace_inventory_item(item.name, 'machete')
--- a/gamelib/scenes/mess.py	Sat Feb 11 12:15:31 2012 +0200
+++ b/gamelib/scenes/mess.py	Sat Feb 11 12:20:12 2012 +0200
@@ -20,7 +20,7 @@
     BACKGROUND = "mess_hall.png"
 
     INITIAL_DATA = {
-        'life support status': 'broken', # broken, replaced, fixed
+        'life support status': 'broken',  # broken, replaced, fixed
         }
 
     def __init__(self, state):
@@ -51,7 +51,9 @@
     """Base class for the cans"""
 
     def interact_with_full_can(self, item):
-        return Result("You bang the cans together. It sounds like two cans being banged together.", soundfile="can_hit.ogg")
+        return Result("You bang the cans together. It sounds like two"
+                      " cans being banged together.",
+                      soundfile="can_hit.ogg")
 
     def interact_with_dented_can(self, item):
         return self.interact_with_full_can(item)
@@ -66,7 +68,8 @@
         empty = EmptyCan('empty_can')
         self.state.add_item(empty)
         self.state.replace_inventory_item(self.name, empty.name)
-        return Result("You open both ends of the can, discarding the hideous contents.")
+        return Result("You open both ends of the can, discarding the"
+                      " hideous contents.")
 
 
 class EmptyCan(BaseCan):
@@ -76,7 +79,8 @@
     CURSOR = CursorSprite('empty_can_cursor.png')
 
     def interact_with_titanium_leg(self, item):
-        return Result("Flattening the can doesn't look like a useful thing to do.")
+        return Result("Flattening the can doesn't look like a useful"
+                      " thing to do.")
 
     def interact_with_canopener(self, item):
         return Result("There's nothing left to open on this can")
@@ -92,7 +96,8 @@
         dented = DentedCan("dented_can")
         self.state.add_item(dented)
         self.state.replace_inventory_item(self.name, dented.name)
-        return Result("You club the can with the femur. The can gets dented, but doesn't open.", soundfile="can_hit.ogg")
+        return Result("You club the can with the femur. The can gets dented,"
+                      " but doesn't open.", soundfile="can_hit.ogg")
 
 
 class DentedCan(BaseCan):
@@ -102,7 +107,9 @@
     CURSOR = CursorSprite('dented_can_cursor.png')
 
     def interact_with_titanium_leg(self, item):
-        return Result("You club the can with the femur. The dents shift around, but it still doesn't open.", soundfile="can_hit.ogg")
+        return Result("You club the can with the femur. The dents shift"
+                      " around, but it still doesn't open.",
+                      soundfile="can_hit.ogg")
 
 
 class CansOnShelf(Thing):
@@ -133,7 +140,8 @@
             if starting_cans == 1:
                 self.scene.remove_thing(self)
             return Result({
-                    3: "Best before a long time in the past. Better not eat these.",
+                    3: "Best before a long time in the past."
+                       " Better not eat these.",
                     2: "Mmmm. Nutritious bacteria stew.",
                     1: "Candied silkworms. Who stocked this place?!",
                     }[starting_cans])
@@ -163,11 +171,13 @@
 
     def get_description(self):
         if self.get_data('status') == "blocked":
-            return "The broccoli seems to have become entangled with something."
+            return ("The broccoli seems to have become"
+                    " entangled with something.")
         elif self.get_data("status") == "broken":
             return "These broken pipes look important."
         elif self.get_data("status") == "replaced":
-            return "The pipes have been repaired but are the repairs aren't airtight, yet"
+            return ("The pipes have been repaired but are the repairs"
+                    " aren't airtight, yet")
         else:
             return "Your fix looks like it's holding up well."
 
@@ -196,10 +206,9 @@
             self.set_data('status', 'replaced')
             self.set_interact("replaced")
             self.scene.set_data('life support status', 'replaced')
-            return Result(
-                "The pipes slot neatly into place, but don't make an airtight seal. "
-                "One of the pipes has cracked slightly as well."
-            )
+            return Result("The pipes slot neatly into place, but don't make"
+                          " an airtight seal. One of the pipes has cracked"
+                          " slightly as well.")
 
     def interact_with_duct_tape(self, item):
         if self.get_data("status") == "broken":
@@ -212,9 +221,10 @@
             self.set_interact("fixed")
             self.scene.set_data('life support status', 'fixed')
             # TODO: A less anticlimactic climax?
-            return Result("It takes quite a lot of tape, but eventually everything is"
-                          " airtight and ready to hold pressure. Who'd've thought duct"
-                          " tape could actually be used to tape ducts?")
+            return Result("It takes quite a lot of tape, but eventually"
+                          "everything is airtight and ready to hold pressure."
+                          " Who'd've thought duct tape could actually be used"
+                          " to tape ducts?")
 
     def interact_without(self):
         if self.get_data("status") == "blocked":
@@ -225,7 +235,8 @@
             return Result("Do you really want to hold it together for the "
                           "rest of the voyage?")
         else:
-            return Result("You don't find any leaks. Good job, Prisoner %s." % PLAYER_ID)
+            return Result("You don't find any leaks. Good job, Prisoner %s."
+                          % PLAYER_ID)
 
 
 class Boomslang(Thing):
@@ -272,7 +283,8 @@
     NAME = "mess.detergent"
 
     INTERACTS = {
-        'present': InteractImageRect(581, 424, 'detergent_lid.png', 565, 399, 62, 95),
+        'present': InteractImageRect(581, 424, 'detergent_lid.png',
+                                     565, 399, 62, 95),
         'taken': InteractNoImage(565, 399, 62, 95),
     }
 
@@ -288,7 +300,8 @@
         self.set_data('taken', True)
         self.set_interact('taken')
         self.state.add_inventory_item('detergent_bottle')
-        return Result("You pick up an empty dishwashing liquid bottle. You can't find any sponges.")
+        return Result("You pick up an empty dishwashing liquid bottle. You"
+                      " can't find any sponges.")
 
     def get_description(self):
         return "Empty plastic containers. They used to hold dishwasher soap."