-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTravLITE.py
More file actions
674 lines (568 loc) · 32.3 KB
/
Copy pathTravLITE.py
File metadata and controls
674 lines (568 loc) · 32.3 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
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
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
#
# LITE chargen app for Traveller NPCs v0.2.0.
# https://github.com/ShawnDriscoll/Traveller-NPC-LITE
#
# This LITE CharGen for Traveller is a Classic Python 2.5 program for generating
# NPCs for Traveller.
#
# bottle testing has begun with the release of 0.1.0.
# Run this code at the CMD prompt while pointing your web browser
# to http://localhost:8080/generate
#
#
# The Traveller game in all forms is owned by Far Future Enterprises.
# Copyright 1977 - 2021 Far Future Enterprises.
# Traveller is a registered trademark of Far Future Enterprises.
#
from rpg_tools.diceroll import roll
import os
import logging
from random import randint
from bottle import route, run, template, get, post, request
import simplejson as json
__author__ = 'Shawn Driscoll <shawndriscoll@hotmail.com>\nshawndriscoll.blogspot.com'
__version__ = '0.2.0'
__app__ = 'TravLITE ' + __version__
def app():
def pick_sound(s_type):
'''
Pick a vowel or consonant, as well as initial and final ones.
'''
if s_type == V:
sound = v_sounds[randint(1, len(v_sounds)) - 1]
if s_type == CV:
sound = ic_sounds[randint(1, len(ic_sounds)) - 1] + v_sounds[randint(1, len(v_sounds)) - 1]
if s_type == VC:
sound = v_sounds[randint(1, len(v_sounds)) - 1] + fc_sounds[randint(1, len(fc_sounds)) - 1]
if s_type == CVC:
sound = ic_sounds[randint(1, len(ic_sounds)) - 1] + v_sounds[randint(1, len(v_sounds)) - 1] \
+ fc_sounds[randint(1, len(fc_sounds)) - 1]
if s_type == CC:
sound = mc_sounds[randint(1, len(mc_sounds)) - 1]
return sound
def gen_word(length):
'''
Generate a word
'''
proper = False
while not(proper):
temp = CC
while temp == CC:
temp = syllable_type[randint(1, len(syllable_type)) - 1]
s_type = temp
word = pick_sound(s_type)
building = True
while building:
syllable = syllable_type[randint(1, len(syllable_type)) - 1]
while temp == CC and (syllable == CV or syllable == CVC or syllable == CC):
syllable = syllable_type[randint(1, len(syllable_type)) - 1]
while temp == V and (syllable == V or syllable == VC):
syllable = syllable_type[randint(1, len(syllable_type)) - 1]
while temp == CV and (syllable == V or syllable == VC):
syllable = syllable_type[randint(1, len(syllable_type)) - 1]
while temp == VC and (syllable == CV or syllable == CVC or syllable == CC):
syllable = syllable_type[randint(1, len(syllable_type)) - 1]
while temp == CVC and (syllable == CV or syllable == CVC or syllable == CC):
syllable = syllable_type[randint(1, len(syllable_type)) - 1]
if temp == VC or temp == CVC:
building = False
else:
s_type = syllable
word += pick_sound(s_type)
temp = syllable
if len(word) > 3 and len(word) < length:
proper = True
return chr(ord(word[0]) - 32) + word[1:len(word)]
def add_background_skills(skill):
temp = len(background_skills)
for i in range(4):
skill[background_skills[randint(1,temp)-1]] = 0
def add_skill(job, skill, n):
temp = len(grinder[job][3])
for i in range(n):
picked_skill = grinder[job][3][randint(1,temp)-1]
if picked_skill in skill:
#print picked_skill, '+1'
skill[picked_skill] += 1
else:
#print picked_skill, '0'
skill[picked_skill] = 0
def grind(characteristic, age):
'''
Grind the NPC in this.
'''
skill = {}
add_background_skills(skill)
#print 'Background Skills:', skill
terms = roll('2d6-2')
if terms == 0:
# No career
name_title = 'Young'
job = 'None'
else:
skill['Anglic Language'] = 0 # Default skill
skill['Jack of all Trades'] = 0 # Default skill
job = career[roll('1d12-1')]
if terms > grinder[job][1]:
temp = grinder[job][1]
else:
temp = terms
characteristic[grinder[job][0]] += temp
if terms > len(grinder[job][2]):
temp = len(grinder[job][2])-1
else:
temp = terms
name_title = grinder[job][2][randint(1,temp)-1]
# Add skills per terms
for i in range(terms):
add_skill(job, skill, 2)
# NPC ages
age += terms * 4
# NPC could have crisis
crisis = (age - 34) / 4
if crisis > 0:
for i in range(crisis):
temp = roll('1d3-1')
characteristic[characteristic_name[temp]] -= roll('1d3')
if characteristic[characteristic_name[temp]] < 1:
characteristic[characteristic_name[temp]] = 1
else:
add_skill(job, skill, 1)
else:
add_skill(job, skill, 1)
return terms, age, name_title, job, skill
# UPP Code Table
hex_code = ['0', '1', '2', '3', '4', '5', '6',
'7', '8', '9', 'A', 'B', 'C', 'D',
'E', 'F', 'G', 'H', 'J', 'K',
'L', 'M', 'N', 'P', 'Q', 'R',
'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
noble_hex_code = ['0', '1', '2', '3', '4', '5', '6',
'7', '8', '9', 'A', 'B', 'c', 'C',
'D', 'e', 'E', 'f', 'F', 'G',
'G', 'H', 'H', 'H', 'H', 'H',
'H', 'H', 'H', 'H', 'H', 'H', 'H', 'H']
career = ['Agent', 'Army', 'Citizen', 'Drifter', 'Entertainer', 'Marines', 'Merchants', 'Navy', 'Nobility',
'Rogue', 'Scholar', 'Scout']
background_skills = ['Animals', 'Zero-G Training', 'Survival Training', 'Seafarer', 'Computer Training', 'Streetwise', 'Vacc Suit Training', 'Profession', 'Carousing']
grinder = {
'Agent' : ['INT', 3, ['Rookie', 'Agent', 'Field Agent', 'Field Agent', 'Special Agent', 'Assistant Director', 'Director'],
['Administrating', 'Carousing', 'Telecomm', 'Computer Training', 'Deceiving', 'Investigating', 'Language',
'Streetwise', 'Slug Pistol', 'Energy Pistol', 'Vilani Language', 'Zdetl Language', 'Small Craft Piloting',
'Political Science', 'Stealth', 'Reconnaissance']],
'Army' : ['STR', 4, ['Private', 'Lance Corporal', 'Corporal', 'Lance Sergeant', 'Sergeant', 'Gunnery Sergeant', 'Sergeant Major'],
['Athletic Endurance', 'Athletics', 'Explosives', 'Gunnery', 'Gun Fighting', 'Leadership', 'Mechanical Training', 'Medical Training', 'Melee',
'Remote Operating', 'Survival Training', 'Tactics', 'Tank Driving', 'Slug Rifle', 'Slug Pistol', 'Energy Rifle', 'Energy Pistol',
'Fist Fighting', 'Reconnaissance', 'Portable Artillery']],
'Citizen' : ['EDU', 3, ['Citizen', 'Citizen', 'Technician', 'Technician', 'Craftsman', 'Craftsman', 'Master Technician'],
['Administrating', 'Animals', 'Art', 'Carousing', 'Computer Training', 'Driving', 'Engineering', 'Companion', 'Streetwise',
'Profession', 'Veterinary', 'Vilani Language', 'Civil Construction', 'Space Construction', 'Navigating', 'Hydroponics', 'Polymers', 'Belter', 'Vacc Suit Training',
'Zero-G Training', 'Jack of all Trades']],
'Drifter' : ['END', 3, ['Barbarian', 'Barbarian', 'Warrior', 'Warrior', 'Chieftain', 'Chieftain', 'Chieftain'],
['Deceiving', 'Gambling', 'Gun Fighting', 'Jack of all Trades', 'Vilani Language', 'Melee', 'Reconnaissance', 'Streetwise',
'Survival Training', 'Animal Riding', 'Animal Training', 'Animal Farming', 'Athletic Co-ord', 'Shotgun', 'Fist Fighting',
'Knife Fighting', 'Blunt Fighting', 'Sword Fighting', 'Belter', 'Navigating', 'Motorboat Helm']],
'Entertainer': ['SOC', 5, ['Extra', 'Extra', 'Extra', 'Extra', 'Extra', 'Extra', 'Famous Performer'],
['Advocating', 'Athletics', 'Art', 'Carousing', 'Companion', 'Animal Riding', 'Acting', 'Writing', 'Dancing', 'Sculpting',
'Musical Training', 'Autocar Driving', 'Aero Flying', 'Vilani Language', 'Holography']],
'Marines' : ['STR', 4, ['Marine', 'Lance Corporal', 'Corporal', 'Lance Sergeant', 'Sergeant', 'Gunnery Sergeant', 'Sergeant Major'],
['Battle Suit Training', 'Explosives', 'Heavy Weapons', 'Reconnaissance', 'Remote Operating', 'Sensor Reading', 'Survival Training',
'Tactics', 'Athletic Strength', 'Jumping', 'Mole Trucking', 'Roto Flying', 'Energy Rifle', 'Heavy Launchers', 'Field Artillery',
'Robotics', 'Military Tactics', 'Motorboat Helm', 'Navigating']],
'Merchants' : ['INT', 3, ['Crewman', 'Senior Crewman', '4th Officer', '3rd Officer', '2nd Officer', '1st Officer', 'Captain'],
['Administrating', 'Trading', 'Carousing', 'Deceiving', 'Language', 'Persuading', 'Piloting', 'Companion', 'Streetwise', 'Economics', 'Political Science']],
'Navy' : ['SOC', 6, ['Crewman', 'Able Spacehand', 'Petty Officer 3rd Class', 'Petty Officer 2nd Class', 'Petty Officer 1st Class', 'Chief Petty Officer', 'Master Chief'],
['Administrating', 'Athletic Co-ord', 'Astrogating', 'Telecomm', 'Computer Training', 'Diplomacy', 'Engineering',
'Flying', 'Gunnery', 'Language', 'Leadership', 'Medical Training', 'Melee', 'Piloting', 'Seafaring', 'Sensor Reading', 'Stealth', 'Tactics', 'Vacc Suit Training',
'Zero-G Training', 'Gravitics', 'Jumpspace', 'Electronics', 'Grav Flying', 'Turret Gunnery', 'Ortillery Gunnery', 'Ship Screens',
'Capital Weapons', 'Anglic Language', 'Vilani Language', 'Fist Fighting', 'Sword Fighting', 'Spacecraft Piloting', 'Capital Ship Helm', 'Sailboat Helm',
'Submarine Helm', 'Naval Tactics']],
'Nobility' : ['SOC', 7, ['Wastrel', 'Wastrel', 'Ingrate', 'Ingrate', 'Black Sheep', 'Black Sheep', 'Scoundrel'],
['Administrating', 'Advocating', 'Art', 'Carousing', 'Deceiving', 'Diplomacy', 'Autocar Driving', 'Roto Flying', 'Athletics', 'Gambling', 'Language', 'Persuading',
'Companion', 'Streetwise', 'Animal Riding', 'Acting', 'Dancing', 'Musical Training', 'Sculpting', 'Slug Pistol', 'Knife Fighting', 'Sword Fighting', 'Small Craft Piloting',
'Archeology', 'Economics', 'History', 'Political Science', 'Cruise Ship Helm', 'Bionetics', 'Philosophy']],
'Rogue' : ['DEX', 4, ['Lackey', 'Henchman', 'Corporal', 'Sergeant', 'Lieutenant', 'Leader', 'Captain'],
['Athletics', 'Art', 'Astrogating', 'Battle Suit Training', 'Trading', 'Carousing', 'Telecomm', 'Computer Training', 'Deceiving', 'Diplomacy', 'Driving', 'Explosives',
'Flying', 'Gambling', 'Gun Fighting', 'Jack of all Trades', 'Language', 'Leadership', 'Mechanical Training', 'Medical Training', 'Melee', 'Navigating', 'Persuading',
'Piloting', 'Reconnaissance', 'Remote Operating', 'Seafaring', 'Sensor Reading', 'Social Sciences', 'Stealth', 'Companion', 'Streetwise', 'Tactics', 'Vacc Suit Training',
'Animal Riding', 'Athletic Co-ord', 'Jumping', 'Dancing', 'Holography', 'Autocar Driving', 'Jumpspace', 'Electronics', 'Grav Flying', 'Slug Rifle', 'Slug Pistol',
'Shotgun', 'Fist Fighting', 'Knife Fighting', 'Sword Fighting', 'Anglic Language', 'Vilani Language', 'Zdetl Language', 'Small Craft Piloting', 'Spacecraft Piloting',
'Cybernetics', 'Archeology', 'Economics', 'Linguistics', 'Psychology', 'Political Science', 'Robotics']],
'Scholar' : ['EDU', 3, ['', '', '', '', '', '', ''],
['Astrogating', 'Computer Training', 'Engineering', 'Language', 'Life Sciences', 'Medical Training', 'Physical Sciences', 'Social Sciences', 'Space Sciences', 'Veterinary',
'Holography', 'Writing', 'Gavitics', 'Jumpspace', 'Electronics', 'Life Support', 'Energy', 'Anglic Language', 'Vilani Language', 'Zdetl Language', 'Oynprith Language',
'Small Craft Piloting', 'Physics', 'Chemisty', 'Computer Science', 'Biology', 'Cybernetics', 'Genetics', 'Psionicology', 'Archeology', 'Economics', 'History', 'Linguistics',
'Philosophy', 'Psychology', 'Political Science', 'Planetology', 'Robotics', 'Xenology', 'Bionetics', 'Hydroponics']],
'Scout' : ['END', 3, ['Trainee', 'Scout', 'Scout', 'Senior Scout', 'Senior Scout', 'Senior Scout', 'Senior Scout'],
['Athletics', 'Astrogating', 'Telecomm', 'Computer Training', 'Diplomacy', 'Driving', 'Flying', 'Jack of all Trades',
'Language', 'Life Sciences', 'Medical Training', 'Navigating', 'Piloting', 'Physical Sciences', 'Reconnaissance',
'Remote Operating', 'Seafaring', 'Sensor Reading', 'Space Sciences', 'Survival Training', 'Vacc Suit Training', 'Zero-G Training',
'Animal Riding', 'Athletic Co-ord', 'Jumpspace', 'Life Support', 'Slug Rifle', 'Anglic Language', 'Vilani Language',
'Zdetl Language', 'Roto Flying', 'Small Craft Piloting', 'Spacecraft Piloting', 'Biology', 'Archeology', 'History',
'Linguistics', 'Planetology', 'Xenology']]
}
social_standing_male = ['NOT USED','NOT USED','NOT USED','NOT USED','NOT USED','NOT USED',
'NOT USED','NOT USED','NOT USED','NOT USED','NOT USED',
'Sir','Baronet','Baron','Marquis','Viscount','Count','Duke','Duke',
'Archduke','Prince','Emperor',
'Emperor','Emperor','Emperor','Emperor','Emperor','Emperor',
'Emperor','Emperor','Emperor','Emperor','Emperor','Emperor']
social_standing_female = ['NOT USED','NOT USED','NOT USED','NOT USED','NOT USED','NOT USED',
'NOT USED','NOT USED','NOT USED','NOT USED','NOT USED',
'Lady','Baronetess','Baroness','Marchioness','Viscountess','Countess','Duchess','Duchess',
'Archduchess','Princess','Empress',
'Empress','Empress','Empress','Empress','Empress','Empress',
'Empress','Empress','Empress','Empress','Empress','Empress']
social_class = ['Outcast',
'Misfit',
'Dregs of Society',
'Lower Low',
'Middle Low',
'Upper Low',
'Low Middle',
'Middle',
'Upper Middle',
'Low Upper',
'Middle Upper',
'Upper Upper',
'Remarkable',
'Extraordinary',
'Extreme',
'Supreme']
male = 'Male'
female = 'Female'
sex = ''
# Characteristic Names
characteristic_name = ['STR', 'DEX', 'END', 'INT', 'EDU', 'SOC']
# Sound Tables
V = 1
CV = 2
VC = 3
CVC = 4
CC = 5
ic_sound = ['b','br','c','ch','d','g',
'h','j','k','l','m','p',
'r','s','st','sh',
't','v','w','z']
ic_freq = [28,12,20,16,27,9,20,20,13,
28,24,27,24,30,13,25,
20,6,16,4]
v_sound = ['a','e','i','o','u']
v_freq = [16,20,10,7,3]
mc_sound = ['g','lt','ns','nst','ls','ll','nn']
mc_freq = [20,3,18,16,18,4,3]
fc_sound = ['ch','ck','d','dy','dyne',
'hl','li','la','le','ler',
'nn','m','man','ma','mer','ny',
'me','n','nas','ne','ng',
'ner','nor','nie',
'rie','rlie','rly','rie','rt',
'ry','sa','sha','nshi','nski','son',
'nson','th','ta','ti','t','v',
'za','ue','than',
'lam','lis','lus','ton','tis','tus',
'love','se','nter','ll']
fc_freq = [6,13,22,12,3,3,3,10,6,10,7,
25,10,4,13,12,5,27,11,4,14,13,17,7,6,5,5,6,3,
21,10,3,8,3,20,9,14,10,16,11,8,6,8,10,7,6,5,7,7,4,
4,12,5,4]
for i in range(len(ic_sound)):
log.debug(ic_sound[i] + ' ' + str(ic_freq[i]))
for i in range(len(v_sound)):
log.debug(v_sound[i] + ' ' + str(v_freq[i]))
for i in range(len(mc_sound)):
log.debug(mc_sound[i] + ' ' + str(mc_freq[i]))
for i in range(len(fc_sound)):
log.debug(fc_sound[i] + ' ' + str(fc_freq[i]))
syllable_type = [V,V,V,V,V,V,V,V,VC,VC,VC,VC,CV,CV,CV,CV,CVC,CVC,CVC,CVC,CVC,CVC,CC,CC]
ic_sounds = []
for i in range(len(ic_freq)):
for j in range(ic_freq[i]):
ic_sounds.append(ic_sound[i])
v_sounds = []
for i in range(len(v_freq)):
for j in range(v_freq[i]):
v_sounds.append(v_sound[i])
mc_sounds = []
for i in range(len(mc_freq)):
for j in range(mc_freq[i]):
mc_sounds.append(mc_sound[i])
fc_sounds = []
for i in range(len(fc_freq)):
for j in range(fc_freq[i]):
fc_sounds.append(fc_sound[i])
def check_number(num_npcs, fnum, snum):
if num_npcs >= fnum and num_npcs <= snum:
return True
else:
return False
# Set defalt generation values that can be changed as needed for input
@get('/generate')
def input_gen_variables():
'''
Variables needed for NPC generation are:
Sex
Number of NPCs to generate
Characteristic roll type
'''
return '''<html>
<head>
<title>''' + __app__ + '''</title>
<link href='https://shawndriscollrpg.blogspot.com/favicon.ico' rel='icon' type='image/x-icon'/>
</head>
<body>
<br><br>
<h1>''' + __app__ + '''</h1>
<form action="/generate" method="post">
<br>
<label for="sex_chosen">Sex (Male, Female, Random):</label><br>
<input type="text" name="sex_chosen" value="Random"><br><br>
<label for="no_of_npcs">How many NPCs (1 - 100):</label><br>
<input type="text" name="no_of_npcs" value="10"><br><br>
<label for="roll_type">Characteristic Roll (2d6, Boon, 1d6+6, etc):</label><br>
<input type="text" name="roll_type" value="2d6"><br><br>
<input value="Generate" type="submit">
</form>
</body>
</html>'''
# Start NPC generation
@post('/generate') # or @route('/generate', method='POST')
def do_generation():
'''
Get the form values from the web browser and begin NPC generation
'''
sex_chosen = request.forms.get('sex_chosen')
no_of_npcs = request.forms.get('no_of_npcs')
roll_type = request.forms.get('roll_type')
if sex_chosen == '':
sex_chosen = 'Random'
if no_of_npcs == '':
no_of_npcs = 1
else:
no_of_npcs = int(no_of_npcs)
if check_number(no_of_npcs, 1, 100):
if sex_chosen == 'Random':
random_sex = True
else:
random_sex = False
if sex_chosen in ['Random', 'Male', 'Female']:
if not os.path.exists('data'):
os.mkdir('data')
json_file_out = open('data/TravLITE_NPCs.json', 'w')
# Start with a blank slate
trav_rec = {}
trav_rec['NPCs'] = []
npc_list = '''<html>
<head>
'''
if no_of_npcs > 1:
npc_list += '''<title>''' + str(no_of_npcs) + ''' NPCs Were'''
else:
npc_list += '''<title>Only One NPC Was'''
npc_list += ''' Generated</title>
<link href='https://shawndriscollrpg.blogspot.com/favicon.ico' rel='icon' type='image/x-icon'/>
</head>
<body>
<br>'''
# NPC generation loop
log.info('sex_chosen = ' + sex_chosen)
log.info('no_of_npcs = ' + str(no_of_npcs))
log.info('roll_type = ' + roll_type)
if no_of_npcs > 1:
npc_list += '''
<table>
'''
for i in range(no_of_npcs):
# What are the six characteristics for this NPC?
characteristic = {}
#
# Create a dictionary for the NPC's characteristics.
# I could have used a list instead of a dict, but I
# wanted to learn how to do dict for a change.
#
for key in characteristic_name:
characteristic[key] = roll(roll_type) # entered in web browser
#characteristic[key] = roll('2d6') # normal two 6-sided roll
#characteristic[key] = roll('boon') # Method I roll
#characteristic[key] = roll('1d6+6') # Nexus roll
# Generate NPC's name
sex = ''
#sex_chosen = 'Random'
while sex <> sex_chosen:
first_name = gen_word(11)
last_name = gen_word(11)
middle_name = gen_word(11)
homeworld_name = gen_word(14)
if len(first_name) > len(last_name):
temp = first_name
first_name = last_name
last_name = temp
if first_name[len(first_name) - 1] == 'a' \
or first_name[len(first_name) - 3:len(first_name)] == 'nny' \
or first_name[len(first_name) - 2:len(first_name)] == 'ne' \
or first_name[len(first_name) - 2:len(first_name)] == 'se' \
or first_name[len(first_name) - 2:len(first_name)] == 'ie' \
or first_name[len(first_name) - 1] == 'i' \
or first_name[len(first_name) - 3:len(first_name)] == 'del' \
or first_name[len(first_name) - 2:len(first_name)] == 'ly' \
or first_name[len(first_name) - 2:len(first_name)] == 'll' \
or first_name[len(first_name) - 4:len(first_name)] == 'lynn' \
or first_name[len(first_name) - 2:len(first_name)] == 'le' \
or first_name[len(first_name) - 3:len(first_name)] == 'ndy' \
or first_name[0:2] == 'Gw' \
or first_name[0:2] == 'Qu':
sex = female
else:
sex = male
if random_sex:
sex_chosen = sex
# Randomize the starting age of NPC
age = 18 + roll('1D4') - roll('1D4')
# Get their social class
vp_soc = characteristic['SOC']
# print '[' + hex_code[characteristic['STR']] + \
# hex_code[characteristic['DEX']] + \
# hex_code[characteristic['END']] + \
# hex_code[characteristic['INT']] + \
# hex_code[characteristic['EDU']] + \
# noble_hex_code[characteristic['SOC']] + ']', age, social_class[vp_soc]
# Grind the NPC down (age them)
terms, age, name_title, job, skill = grind(characteristic, age)
# Spit out their number of terms, their age, their title, job, and skills
# Now make a full name for the NPC based on their life
if characteristic['SOC'] > 10:
if sex == male:
if characteristic['SOC'] > 11:
full_name = social_standing_male[characteristic['SOC']] + ' ' + first_name + ' ' + middle_name + ' ' + last_name + ' of ' + homeworld_name
else:
full_name = social_standing_male[characteristic['SOC']] + ' ' + first_name + ' ' + chr(randint(1,26) + 64) + '. ' + last_name
else:
if characteristic['SOC'] > 11:
full_name = social_standing_female[characteristic['SOC']] + ' ' + first_name + ' ' + middle_name + ' ' + last_name + ' of ' + homeworld_name
else:
full_name = social_standing_female[characteristic['SOC']] + ' ' + first_name + ' ' + chr(randint(1,26) + 64) + '. ' + last_name
else:
if name_title == '':
#if skill_level[27] == 3:
if characteristic['INT'] == 11:
full_name = 'Dr. ' + first_name + ' ' + last_name
#elif characteristic['EDU'] > 11 or skill_level[27] > 3:
elif characteristic['EDU'] > 11 or characteristic['INT'] > 11:
full_name = 'Dr. ' + first_name + ' ' + chr(randint(1,26) + 64) + '. ' + last_name
else:
full_name = first_name + ' ' + last_name
else:
full_name = name_title + ' ' + first_name + ' ' + chr(randint(1,26) + 64) + '. ' + last_name
if no_of_npcs > 1:
npc_list += '''<tr>
<td>''' + '%s.<br><br><br><br><br><br></td>' % (i + 1)
npc_list += '''
<td>'''
npc_list += full_name + ' [' + hex_code[characteristic['STR']] + \
hex_code[characteristic['DEX']] + \
hex_code[characteristic['END']] + \
hex_code[characteristic['INT']] + \
hex_code[characteristic['EDU']] + \
noble_hex_code[characteristic['SOC']] + ']<br>%s, age %d, %s class' % (sex, age, social_class[vp_soc])
if terms > 0:
npc_list += ', %d-term %s' % (terms, job)
npc_list += '<br>'
trained_skills = {}
# Sort skill list
skill_item = []
skill_amount = []
for i in range(80):
skill_item.append(-1)
skill_amount.append(-1)
key_count = 0
for key in skill:
#print key, skill[key]
skill_item[key_count] = key
skill_amount[key_count] = skill[key]
key_count += 1
key_count -= 1
swapping = True
while swapping:
swapping = False
for i in range(key_count):
if skill_item[i] > skill_item[i + 1]:
temp = skill_item[i]
skill_item[i] = skill_item[i + 1]
skill_item[i + 1] = temp
temp = skill_amount[i]
skill_amount[i] = skill_amount[i + 1]
skill_amount[i + 1] = temp
swapping = True
key_count += 1
skill_count = 0
for i in range(key_count):
npc_list += '%s %d, ' % (skill_item[i], skill_amount[i])
trained_skills[skill_item[i]] = skill_amount[i]
skill_count += 1
if skill_count == 6 and i <> key_count - 1:
npc_list += '<br>'
skill_count = 0
npc_list = npc_list[0:len(npc_list) - 2] + '<br><br><br>'
if no_of_npcs > 1:
npc_list += '''</td>
'''
if terms > 0:
temp_terms = terms
else:
temp_terms = 0
trav_rec['NPCs'].append({
'Traveller_Name': full_name,
'STR': hex_code[characteristic['STR']],
'DEX': hex_code[characteristic['DEX']],
'END': hex_code[characteristic['END']],
'INT': hex_code[characteristic['INT']],
'EDU': hex_code[characteristic['EDU']],
'SOC': noble_hex_code[characteristic['SOC']],
'Sex': sex,
'Age': age,
'Social_Class': social_class[vp_soc],
'Terms': temp_terms,
'Career': job,
'Skills': trained_skills
})
log.info(full_name + ' was generated.')
#return "<p>It worked!</p>"
if no_of_npcs > 1:
npc_list += '''</tr>
</table>'''
npc_list += '''
</body>
</html>'''
json.dump(trav_rec, json_file_out, ensure_ascii = True)
json_file_out.close()
return npc_list
else:
return "<p><br><br>Enter Sex. Not gender, please.</p>"
else:
return "<p><br><br>Enter a value of 1 to 100 NPCs, please.</p>"
run(host='localhost', port='8080')
#
# Program exits here!
#
if __name__ == '__main__':
log = logging.getLogger('TravLITE_' + __version__)
log.setLevel(logging.DEBUG)
if not os.path.exists('Logs'):
os.mkdir('Logs')
fh = logging.FileHandler('Logs/TravLITE.log', 'w')
formatter = logging.Formatter('%(asctime)s %(levelname)s %(name)s - %(message)s',
datefmt = '%a, %d %b %Y %H:%M:%S')
fh.setFormatter(formatter)
log.addHandler(fh)
log.info('Logging started.')
log.info(__app__ + ' starting...')
print
print 'Thank you for giving', __app__, 'a try.'
vernum, release = roll('info')
print 'This program is using', release
print
print '----------------------------'
print __author__
print
log.info(__app__ + ' started, and running...')
app()