-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
80 lines (60 loc) · 2.2 KB
/
main.py
File metadata and controls
80 lines (60 loc) · 2.2 KB
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
from kivy.app import App
from CalendarPage import *
from kivy.uix.screenmanager import ScreenManager, Screen
from Player import *
from kivy.uix.floatlayout import FloatLayout
from NavBar import *
from NewEventPage import *
from Quest import *
from Shop import *
from Journal import *
from string import digits
class Character(Screen): #should be merged with player.py either by having the player as an object or something else.
def sheet_from_json(self):
with open('player.json') as json_file:
stats = json.load(json_file)
return stats
def fetch_stat(self,stat):
stats = self.sheet_from_json()
str_val = stats[stat]
return str(str_val)
def refresh_widget(self,obj):
print(self.ids)
for i in self.ids.keys():
old_text = self.ids[i].text
remove_digits = str.maketrans('','',digits)
res = old_text.translate(remove_digits) + str(self.fetch_stat(i))
self.ids[i].text = res
print(res,i,self.fetch_stat(i))
class Application(App):
def init(self, kwargs):
super().init(kwargs)
self.sm = ScreenManager()
player = Player() #move l8r
def fetch_character_sheet(self): #move l8r
player.read_from_json() #update char.
return player
##template for property change ##
#def on_property(self,obj,value):
# print("property change?")
##template for event##
#def on_event(self, obj):
# print("Typical event from", obj)
def on_character_event(self,obj):
print(obj, " was pressend and the character sheet in app was updated.")
player.read_from_json()
player.x
sm = ScreenManager()
def build(self):
nav_bars = NavBar(self.sm)
new_event_page = NewEventPage()
lst = [CalendarPage(nav_bars.calender_navbar(new_event_page),self.player),Character(),Journal(),Quest(self.player),Shop(self.player)]
main_box = BoxLayout(orientation="vertical")
self.sm.switch_to(lst[0])
main_box.add_widget(nav_bars.main_navbar(lst))
main_box.add_widget(self.sm)
return main_box
def main():
Application().run()
if __name__ == '__main__':
main()