This repository has been archived by the owner on Sep 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
105 lines (85 loc) · 3.6 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
from kivy.properties import BooleanProperty, ObjectProperty
from kivy.logger import Logger
from kivy.resources import resource_add_path
import os
from functools import partial
from ELiDE.game import GameScreen, GameApp
from ELiDE.board import Pawn
resource_add_path(os.path.join(os.path.dirname(__file__), 'LPC_city_inside'))
resource_add_path(os.path.join(os.path.dirname(__file__), 'LPC_house_interior'))
class TravellingPawn(Pawn):
def on_drop(self, spot):
if spot is None:
return super().on_drop(None)
screen = GameApp.get_running_app().screen_manager.get_screen('play')
if screen.player.name != self.name:
return super().on_drop(None)
screen.wait_travel_pawn(self, spot)
class ImmediatePlayView(GameScreen):
player = ObjectProperty()
character = ObjectProperty()
class_time = BooleanProperty()
sleepy = BooleanProperty()
hungry = BooleanProperty()
people_present = BooleanProperty()
def wait_travel_pawn(self, pawn, dest):
self.wait_travel('physical', pawn.name, dest.name)
def go_to_class(self, *args):
me = self.player.avatar['physical']
clsn = me.user.stat['classroom'].name
if me.location.name == clsn:
Logger.info("DunUniPlayView: already in classroom")
return
self.wait_travel('physical', me.name, clsn)
def go_to_sleep(self, *args):
myroom = self.player.stat['room']
me = self.player.avatar['physical']
if me.location != myroom:
self.wait_travel_command(
'physical', me.name, myroom.name, self.ensleep, 8, self.unsleep
)
else:
self.wait_command(self.ensleep, 8, self.unsleep)
def ensleep(self, *args):
bed = self.player.stat['bed']
self.player.avatar['physical'].location = bed
self.character.stat['conscious'] = False
def unsleep(self, *args):
self.character.stat['conscious'] = True
Logger.debug("DunUniPlayView: finished sleeping")
def eat_food(self, *args):
cafeteria = self.engine.character['physical'].place['cafeteria']
me = self.player.avatar['physical']
if me.location != cafeteria:
self.wait_travel_command('physical', me.name, 'cafeteria', self.eneat, 1, self.uneat)
else:
self.wait_command(self.eneat, 1, self.uneat)
def eneat(self, *args):
self.character.stat['eating'] = True
def uneat(self, *args):
self.character.stat['eating'] = False
Logger.debug("DunUniPlayView: finished eat_food")
def socialize(self, *args):
peeps = [
thing for thing in self.player.avatar['physical'].location.contents()
if 'student_body' in thing.users and thing != self.player.avatar['physical']
]
if not peeps:
Logger.debug("DunUniPlayView: no one to socialize with")
return
peep = self.engine.choice(peeps)
usr = peep.users[peep.name]
Logger.debug("DunUniPlayView: going to talk to {} for a turn".format(usr.name))
self.wait_command(partial(self.ensocialize, usr), 1, self.desocialize)
def ensocialize(self, usr, *args):
self.character.stat['talking_to'] = usr
usr.stat['talking_to'] = self.character
def desocialize(self, *args):
del self.character.stat['talking_to'].stat['talking_to']
del self.character.stat['talking_to']
Logger.debug("DunUniPlayView: finished socialize")
class DunUniApp(GameApp):
modules = ['util', 'emotion', 'world']
inspector = True
loglevel = 'debug'
world_file = ':memory:'