-
Notifications
You must be signed in to change notification settings - Fork 0
/
Character Management.py
executable file
·449 lines (379 loc) · 15.2 KB
/
Character Management.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
"""
Character Management.py - this allows the user to manage all aspects of character information.
"""
#//--------------------------------------------------------------
#//--------------- Modules/Packages to be imported --------------
#//--------------------------------------------------------------
import ui, os
import console
#//--------------------------------------------------------------
#//--------------- Class Modules to be imported -----------------
#//--------------------------------------------------------------
import clsCharacter
import clsCharacterDataSource
reload(clsCharacter)
reload(clsCharacterDataSource)
#import clsCharacterListDelegate
#//---------------------------------------------------------------------------------
#//-----------------------------Class Definitions-----------------------------------
#//---------------------------------------------------------------------------------
"""
This provides the interface for the character mangagement aspects of the app.
"""
class clsCharacterManagement:
"""
Attributes:
Methods:
Exceptions:
"""
def __init__(self, Test = False):
"""
The class initialise function that sets up the view and handles test conditions if requested
Arguments:
Specifics:
"""
global CAMPAIGN_DATA_DIRECTORY
global SKILLS_SELECTED, WEAPONS_SELECTED, EQUIPMENT_SELECTED
global CHARACTERISTICS_SELECTED, ARMOUR_SELECTED, NOTES_SELECTED
global CHARACTERISTIC_ORIGINAL, CHARACTERISTIC_MAX, CHARACTERISTIC_CURRENT, SLIDER_INCREMENT
CHARACTER_DATA_DIRECTORY = '/Data/Character/'
SKILLS_SELECTED = 0
WEAPONS_SELECTED = 1
EQUIPMENT_SELECTED = 2
CHARACTERISTICS_SELECTED = 0
ARMOUR_SELECTED = 1
NOTES_SELECTED = 2
CHARACTERISTIC_ORIGINAL = 0
CHARACTERISTIC_MAX = 1
CHARACTERISTIC_CURRENT = 2
SLIDER_INCREMENT = 20
try:
strViewName = 'Character Management'
self.vwInterface = ui.load_view(strViewName)
self.vwInterface.name = strViewName
self._initialise_control_handlers()
if Test:
self.objCharacter = self._intialising_character_test_data()
self._load_interface_with_character_data()
self._load_interface_with_characteristics()
self.vwInterface['tblSkills'].data_source = self._initialise_character_skills_data_source(self.objCharacter.get_character_skills())
self.objCharacter.save()
except:
pass
#//---------------------------------------------------------------------------------
#//-----------------------------Attribute Defintions--------------------------------
#//---------------------------------------------------------------------------------
#//-----------------------------Method Defintions-----------------------------------
def present_view(self):
"""
Puts the campaign management view on screen.
Arguments:
Specifics:
"""
try:
if ui.get_screen_size()[1] >= 768:
self.vwInterface.present('fullscreen')
else: # iPhone
self.vwInterface.present(orientations=['portrait'])
except:
pass
#// control handler methods------------------------------------------------------
#// -----------------------------------------------------------------------------
#// the tablewiew delegate methods-----------------------------------------------
def tableview_did_select(self, tableview, section, row):
# Called when a row was selected in a tableview.
#print(tableview.name)
if tableview.name == 'tblName1':
pass
elif tableview.name == 'tblName2':
pass
def tableview_accessory_button_tapped(self, tableview, section, row):
# Called when a row was selected.
#print(tableview.name)
if tableview.name == 'tblName1':
pass
elif tableview.name == 'tblName2':
pass
def tableview_did_deselect(self, tableview, section, row):
# Called when a row was de-selected (in multiple selection mode).
pass
def tableview_title_for_delete_button(self, tableview, section, row):
# Return the title for the 'swipe-to-***' button.
return 'Delete'
#//---------------------------------------------------------------------------------
#//-----------------------------Internal Method Defintions--------------------------
#// simple control handlers ----------------------------------------------
def _typeControlName_handler(self, sender):
"""
handles taps on the button for date control to display date picker.
Arguments:
Specifics:
"""
try:
pass
except:
pass
def segCharacter2_handler(self, sender):
"""
handles taps on the segment control to display different views.
Arguments:
Specifics:
"""
try:
tblSkills = self.vwInterface['tblSkills']
if sender.selected_index == SKILLS_SELECTED:
tblSkills.hidden = False
tblSkills.data_source = self._initialise_character_skills_data_source(self.objCharacter.get_character_skills())
tblSkills.reload()
elif sender.selected_index == WEAPONS_SELECTED:
tblSkills.hidden = False
tblSkills.data_source = self._initialise_character_weapons_data_source(self.objCharacter.get_character_weapons())
tblSkills.reload()
elif sender.selected_index == EQUIPMENT_SELECTED:
tblSkills.hidden = False
tblSkills.data_source = self._initialise_character_equipment_data_source(self.objCharacter.get_character_equipment())
tblSkills.reload()
else:
pass
except:
pass
def segCharacter1_handler(self, sender):
"""
handles taps on the segment control to display different views.
Arguments:
Specifics:
"""
try:
vwInterface = sender.superview
scrCharacteristics = vwInterface['scrCharacteristics']
txtCharacter = vwInterface['txtCharacterNotes']
if sender.selected_index == CHARACTERISTICS_SELECTED:
scrCharacteristics.hidden = False
txtCharacter.hidden = True
elif sender.selected_index == ARMOUR_SELECTED:
scrCharacteristics.hidden = True
txtCharacter.hidden = True
elif sender.selected_index == NOTES_SELECTED:
scrCharacteristics.hidden = True
txtCharacter.hidden = False
else:
pass
except:
pass
def _initialise_name_interface(self):
"""
sets up the basics of the interface at launch.
Arguments:
Specifics:
"""
try:
self._disable_campaign_controls()
except:
pass
def _disable_campaign_controls(self):
"""
Disables the campaign content controls so they cannot be used.
Arguments:
Specifics:
"""
try:
pass
except:
pass
def _enable_campaign_controls(self):
"""
Enables the campaign content controls so they can be used
Arguments:
Specifics:
"""
try:
pass
except:
pass
def _initialise_control_handlers(self):
"""
Loads campaign data from file.
Arguments:
Specifics:
"""
try:
self.vwInterface['segCharacter1'].action = self.segCharacter1_handler
self.vwInterface['segCharacter2'].action = self.segCharacter2_handler
#self.vwInterface['tblCampaigns'].delegate = self
#self.vwInterface['btnCampaignStart'].action = self._typeControlName_handler
pass
except:
pass
def _intialising_character_test_data(self):
"""
To do whatever the method does.
Arguments:
Specifics:
"""
try:
objAndrewFletcher = clsCharacter.clsCharacter('Andrew Fletcher', '38', 'Human', 'Rhylanor/Rhylanor')
CharacterSkills = [['Slug Rifle', '4']]
CharacterSkills.append(['Streetwise', '2'])
CharacterSkills.append(['Jack of All Trades', '1'])
objAndrewFletcher.set_character_skills(CharacterSkills)
CharacterWeapons = [['Blade', '4']]
CharacterWeapons.append(['Gauss Pistol', '2'])
CharacterWeapons.append(['Body Pistol', '1'])
objAndrewFletcher.set_character_weapons(CharacterWeapons)
CharacterEquipment = [['Comm', '4']]
CharacterEquipment.append(['Smart Rope', '2'])
CharacterEquipment.append(['Watch', '1'])
objAndrewFletcher.set_character_equipment(CharacterEquipment)
CharacterStrength = [7, 7, 1]
objAndrewFletcher.set_character_strength(CharacterStrength)
CharacterDexterity = [14, 14, 14]
objAndrewFletcher.set_character_dexterity(CharacterDexterity)
CharacterEndurance = [11, 11, 6]
objAndrewFletcher.set_character_endurance(CharacterEndurance)
CharacterIntelligence = [9, 9, 9]
objAndrewFletcher.set_character_intelligence(CharacterIntelligence)
CharacterEducation = [8, 8, 8]
objAndrewFletcher.set_character_education(CharacterEducation)
CharacterSocial = [5, 5, 5]
objAndrewFletcher.set_character_social(CharacterSocial)
return objAndrewFletcher
except:
pass
def _load_data(self, strCampaignName):
"""
Loads campaign data from file.
Arguments:
Specifics:
"""
try:
pass
except:
pass
def _load_interface_with_character_data(self):
"""
To do whatever the method does.
Arguments:
Specifics:
"""
try:
self.vwInterface['txtAge'].text = self.objCharacter.get_character_age()
self.vwInterface['txtRace'].text = self.objCharacter.get_character_race()
self.vwInterface['txtHomeWorld'].text = self.objCharacter.get_character_home_world()
except:
pass
def _load_interface_with_characteristics(self):
"""
To do whatever the method does.
Arguments:
Specifics:
"""
try:
lstStrength = self.objCharacter.get_character_strength()
self.vwInterface['scrCharacteristics']['btnStrengthOriginal'].title = str(lstStrength[CHARACTERISTIC_ORIGINAL])
self.vwInterface['scrCharacteristics']['btnStrengthMax'].title = str(lstStrength[CHARACTERISTIC_MAX])
self.vwInterface['scrCharacteristics']['btnStrengthCurrent'].title = str(lstStrength[CHARACTERISTIC_CURRENT])
self.vwInterface['scrCharacteristics']['sldStrength'].value = (float(lstStrength[CHARACTERISTIC_CURRENT]) / SLIDER_INCREMENT)
lstDexterity = self.objCharacter.get_character_dexterity()
self.vwInterface['scrCharacteristics']['btnDexterityOriginal'].title = str(lstDexterity[CHARACTERISTIC_ORIGINAL])
self.vwInterface['scrCharacteristics']['btnDexterityMax'].title = str(lstDexterity[CHARACTERISTIC_MAX])
self.vwInterface['scrCharacteristics']['btnDexterityCurrent'].title = str(lstDexterity[CHARACTERISTIC_CURRENT])
self.vwInterface['scrCharacteristics']['sldDexterity'].value = (float(lstDexterity[CHARACTERISTIC_CURRENT]) / SLIDER_INCREMENT)
lstEndurance = self.objCharacter.get_character_endurance()
self.vwInterface['scrCharacteristics']['btnEnduranceOriginal'].title = str(lstEndurance[CHARACTERISTIC_ORIGINAL])
self.vwInterface['scrCharacteristics']['btnEnduranceMax'].title = str(lstEndurance[CHARACTERISTIC_MAX])
self.vwInterface['scrCharacteristics']['btnEnduranceCurrent'].title = str(lstEndurance[CHARACTERISTIC_CURRENT])
self.vwInterface['scrCharacteristics']['sldEndurance'].value = (float(lstEndurance[CHARACTERISTIC_CURRENT]) / SLIDER_INCREMENT)
lstIntelligence = self.objCharacter.get_character_intelligence()
self.vwInterface['scrCharacteristics']['btnIntelligenceOriginal'].title = str(lstIntelligence[CHARACTERISTIC_ORIGINAL])
self.vwInterface['scrCharacteristics']['btnIntelligenceMax'].title = str(lstIntelligence[CHARACTERISTIC_MAX])
self.vwInterface['scrCharacteristics']['btnIntelligenceCurrent'].title = str(lstIntelligence[CHARACTERISTIC_CURRENT])
self.vwInterface['scrCharacteristics']['sldIntelligence'].value = (float(lstIntelligence[CHARACTERISTIC_CURRENT]) / SLIDER_INCREMENT)
lstEducation = self.objCharacter.get_character_education()
self.vwInterface['scrCharacteristics']['btnEducationOriginal'].title = str(lstEducation[CHARACTERISTIC_ORIGINAL])
self.vwInterface['scrCharacteristics']['btnEducationMax'].title = str(lstEducation[CHARACTERISTIC_MAX])
self.vwInterface['scrCharacteristics']['btnEducationCurrent'].title = str(lstEducation[CHARACTERISTIC_CURRENT])
self.vwInterface['scrCharacteristics']['sldEducation'].value = (float(lstEducation[CHARACTERISTIC_CURRENT]) / SLIDER_INCREMENT)
lstSocial = self.objCharacter.get_character_social()
self.vwInterface['scrCharacteristics']['btnSocialOriginal'].title = str(lstSocial[CHARACTERISTIC_ORIGINAL])
self.vwInterface['scrCharacteristics']['btnSocialMax'].title = str(lstSocial[CHARACTERISTIC_MAX])
self.vwInterface['scrCharacteristics']['btnSocialCurrent'].title = str(lstSocial[CHARACTERISTIC_CURRENT])
self.vwInterface['scrCharacteristics']['sldSocial'].value = (float(lstSocial[CHARACTERISTIC_CURRENT]) / SLIDER_INCREMENT)
except:
pass
def _initialise_character_skills_data_source(self, lstCharacterSkills):
"""
To do whatever the method does.
Arguments:
Specifics:
"""
try:
strHeader = ['Skill | Level']
return clsCharacterDataSource.clsCharacterDataSource(lstCharacterSkills, strHeader)
except:
pass
def _initialise_character_weapons_data_source(self, lstCharacterWeapons):
"""
To do whatever the method does.
Arguments:
Specifics:
"""
try:
strHeader = ['Weapon | Level']
return clsCharacterDataSource.clsCharacterDataSource(lstCharacterWeapons, strHeader)
except:
pass
def _initialise_character_equipment_data_source(self, lstCharacterEquipment):
"""
To do whatever the method does.
Arguments:
Specifics:
"""
try:
strHeader = ['Equipment | Level']
return clsCharacterDataSource.clsCharacterDataSource(lstCharacterEquipment, strHeader)
except:
pass
def _iphone_interface_layout(self):
"""
Alters the layout to suit an iPhone.
Arguments:
Specifics:
"""
try:
# first cal calculate proportions based on the golden ratio
Proportion = 5
BufferBetweenCampaignListAndContent = 30
Width = ui.get_screen_size()[1]
print(Width)
ContentWidth = (Width / Proportion) * 4
print(ContentWidth)
CampaignListWidth = Width - ContentWidth
print(CampaignListWidth)
print(Width, ContentWidth, CampaignListWidth)
ContentLeft = CampaignListWidth + BufferBetweenCampaignListAndContent
self.vwInterface['tblCampaigns'].x = 0
self.vwInterface['tblCampaigns'].width = CampaignListWidth
self.vwInterface['segCampaign'].x = ContentLeft
self.vwInterface['lblDescription'].x = ContentLeft
except:
pass
#//--------------------------------------------------------------
#//--------------- Main Body ------------------------------------
#//--------------------------------------------------------------
def main():
"""
This starts the application.
Arguments:
Specifics:
"""
console.clear()
#//--------------------------------------------------------------
#//--------------- Global Variables -----------------------------
#global
try:
objCharacterManagement = clsCharacterManagement(True)
objCharacterManagement.present_view()
except:
pass
if __name__ == '__main__':
main()