comparison gamelib/scenes/game_widgets.py @ 854:3577c51029f1 default tip

Remove Suspended Sentence. pyntnclick is the library we extracted from it
author Stefano Rivera <stefano@rivera.za.net>
date Sat, 21 Jun 2014 22:15:54 +0200
parents f95830b58336
children
comparison
equal deleted inserted replaced
853:f95830b58336 854:3577c51029f1
1 """Generic, game specific widgets"""
2
3
4 from pyntnclick.i18n import _
5 from pyntnclick.state import Thing, Result
6
7 from gamelib.custom_widgets import JimLabel
8
9
10 class Door(Thing):
11 """A door somewhere"""
12
13 DEST = "map"
14 SCENE = None
15
16 def __init__(self):
17 self.NAME = self.SCENE + '.door'
18 Thing.__init__(self)
19
20 def is_interactive(self, tool=None):
21 return True
22
23 def interact_without(self):
24 """Go to map."""
25 self.game.change_scene("map")
26
27 def get_description(self):
28 return _('An open doorway leads to the rest of the ship.')
29
30 def interact_default(self, item):
31 return self.interact_without()
32
33
34 def make_jim_dialog(mesg, game):
35 "Utility helper function"
36 if game.data.get_jim_state() == 'online':
37 return Result(widget=JimLabel(game.gd, mesg))
38 else:
39 return None
40
41
42 def make_sentence_dialog(prisoner, game):
43 return make_jim_dialog(
44 _("Prisoner %(id)s, your total sentence is now %(sen)d years.") % {
45 "id": prisoner, 'sen': game.data.get_total_sentence()}, game)
46
47
48 class BaseCamera(Thing):
49 "Base class for the camera puzzles"
50
51 INITIAL = 'online'
52 INITIAL_DATA = {
53 'state': 'online',
54 }
55
56 def get_description(self):
57 status = self.state.get_jim_state()
58 if status == 'online':
59 return _("A security camera watches over the room")
60 elif status == 'looping':
61 return _("The security camera is currently offline but should be"
62 " working soon")
63 else:
64 return _("The security camera is powered down")
65
66 def is_interactive(self, tool=None):
67 return self.state.get_jim_state() == 'online'
68
69 def interact_with_escher_poster(self, item):
70 # Order matters here, because of helper function
71 if self.state.get_jim_state() == 'online':
72 ai_response = make_jim_dialog(_("3D scene reconstruction failed."
73 " Critical error."
74 " Entering emergency shutdown."),
75 self.game)
76 self.game.data.loop_ai()
77 return ai_response
78
79 def select_interact(self):
80 if 'bridge' not in self.state:
81 # We aren't completely set up yet
82 return self.INITIAL
83 return self.state.get_jim_state()
84
85 def animate(self):
86 ai_status = self.state.get_jim_state()
87 if ai_status != self.get_data('status'):
88 self.set_data('status', ai_status)
89 self.set_interact()
90 super(BaseCamera, self).animate()