Mercurial > pyntnclick
comparison gamelib/scenes/machine.py @ 190:30f2308c1efc
Fix tests and add a (currently unhooked) laser welder.
author | Jeremy Thurgood <firxen@gmail.com> |
---|---|
date | Wed, 25 Aug 2010 20:09:19 +0200 |
parents | d00aa26941c4 |
children | 738608e90e9c |
comparison
equal
deleted
inserted
replaced
189:c18ef647ffe6 | 190:30f2308c1efc |
---|---|
35 def interact_without(self): | 35 def interact_without(self): |
36 """Go to map.""" | 36 """Go to map.""" |
37 self.state.set_current_scene("map") | 37 self.state.set_current_scene("map") |
38 | 38 |
39 | 39 |
40 class LaserWelder(Thing): | |
41 | |
42 NAME = "machine.laser_welder" | |
43 | |
44 INTERACTS = { | |
45 "weld": InteractText(200, 200, "Laser welder"), | |
46 } | |
47 | |
48 INITIAL = "weld" | |
49 | |
50 INITIAL_DATA = { | |
51 'cans_in_place': 0, | |
52 } | |
53 | |
54 def interact_without(self): | |
55 if self.get_data('cans_in_place') < 1: | |
56 return Result("The laser welder doesn't currently contain anything weldable.") | |
57 elif self.get_data('cans_in_place') < 3: | |
58 return Result("You'll need more cans than that.") | |
59 else: | |
60 self.set_data('cans_in_place', 0) | |
61 self.state.add_inventory_item('tube_fragments') | |
62 return Result("With high-precision spitzensparken, the cans are welded into a replacement tube.") | |
63 | |
64 def interact_with_dented_can(self, item): | |
65 return self.interact_with_empty_can(item) | |
66 | |
67 def interact_with_empty_can(self, item): | |
68 starting_cans = self.get_data('cans_in_place') | |
69 if starting_cans < 3: | |
70 self.state.remove_inventory_item(item.name) | |
71 self.set_data('cans_in_place', starting_cans + 1) | |
72 return Result({ | |
73 0: "You carefully place the empty can in the area marked 'to weld'.", | |
74 1: "You carefully place the empty can next to the other.", | |
75 2: "You carefully place the empty can next to its mates.", | |
76 }[starting_cans]) | |
77 else: | |
78 return Result("The machine has enough cans to weld for the moment.") | |
79 | |
80 def get_description(self): | |
81 msg = "This is a Smith and Wesson 'zOMG' class high-precision laser welder." | |
82 if self.get_data('cans_in_place') == 1: | |
83 msg += " It currently contains an empty can." | |
84 elif self.get_data('cans_in_place') == 2: | |
85 msg += " It currently contains two empty cans." | |
86 elif self.get_data('cans_in_place') == 3: | |
87 msg += " It currently contains three empty cans." | |
88 return msg | |
89 | |
90 | |
40 SCENES = [Machine] | 91 SCENES = [Machine] |