#! /usr/bin/python # Template Generator v1.04 # Shawn Geier # Copyright Galbraith Games # 05/03/04 # Changes by Seth Galbraith (25 June 2004): # hash-bang line :-) # changed stats from list to dictionary # altered many repetitive sections to use lists and loops from math import * # for the floor function stats = {'Name' : 'No Name', 'Size' : 0, 'Reach' : 0, 'Reach PPV' : 0, 'Stride' : 0, 'PPV' : 0} abilities = {'Acrobatics' : 0, # Holds Ability Values. Extras are appended 'Alchemy' : 0, # as users add more specialized 'Animal Handling' : 0, 'Climbing' : 0, 'Communication' : 0, 'Craftsmanship' : 0, 'Detection' : 0, 'Flying' : 0, 'Hand to Hand' : 0, 'Marksmanship' : 0, 'Power' : 0, 'Regeneration' : 0, 'Running' : 0, 'Stealth' : 0, 'Strength' : 0, 'Swimming' : 0, 'Toughness' : 0} disabilities = {'Ignorance' : 0, # Holds Disability Values 'Thumbless' : 0, 'Farsighted' : 0, 'Nearsighted' : 0, 'Deaf' : 0, 'Lame' : 0} nat_arm = {'Absorbtion' : 0, 'Cover' : 0} nat_wpn = {'Conceal' : 0, 'Grapple' : 0, 'Parry' : 0, 'Sharpness' : -7} def print_main_menu(): # Prints Main Menu y = 0 print"""******************************************************************************* * Galbraith Games Template Generation Program * ******************************************************************************* * * * STATS * NATURAL EQUIPMENT""" if len(stats['Name']) < 8: print " 1. Edit Name * Name : ", stats['Name'], '\t', " * Absorbtion : ", nat_arm['Absorbtion'] else: print " 1. Edit Name * Name : ", stats['Name'], " * Absorbtion : ", nat_arm['Absorbtion'] print " 2. Edit Size * Size : ", stats['Size'], '\t', ' * Cover : ', nat_arm['Cover'] print " 3. Edit Reach * Reach : ", stats['Reach'], '\t', ' *' print " 4. Edit Stride * Stride : ", stats['Stride'], '\t', ' * Conceal : ', nat_wpn['Conceal'] print " 5. Edit Abilities * PPV : ", stats['PPV'], '\t', ' * Grapple : ', nat_wpn['Grapple'] print " 6. Edit Disabilities * * Parry : ", nat_wpn['Parry'] print " 7. Edit Natural Equipment * * Sharpness : ", nat_wpn['Sharpness'] print " 8. Save Template * *" print " 0. Exit Program * ABILITIES * DISABILITIES" abs = [] for x in abilities: #Prints Abilities & Disabilities if abilities[x] !=0: abs.append(x) abs.append(abilities[x]) dis = [] for i in disabilities: if disabilities[i] != 0: dis.append(i) dis.append(disabilities[i]) x = len(abs) y = len(dis) while x > y: dis.append(' ') y += 1 while y > x: abs.append(' ') x +=1 x = 0 y = 0 while x < len(abs): if len(abs[x]) == 1: print " * * ", dis[x], ' :', dis[x+1] elif len(abs[x])<12: print " * ", abs[x], '\t', ' :', abs[x+1], " * ", dis[x], ' :', dis[x+1] elif len(abs[x]) == 12: print " * ", abs[x], ' :', abs[x+1], " * ", dis[x], ' :', dis[x+1] elif len(abs[x]) == 13: print " * ", abs[x], ' :', abs[x+1], " * ", dis[x], ' :', dis[x+1] elif len(abs[x]) == 14: print " * ", abs[x], ' :', abs[x+1], " * ", dis[x], ' :', dis[x+1] elif len(abs[x]) == 15: print " * ", abs[x], ':', abs[x+1], " * ", dis[x], ' :', dis[x+1] x+=2 y+=1 while y < 9: # Prints blank lines to fill up the menu print " * *" y += 1 print "*******************************************************************************" def edit_name(): # Edit the name of the Template stats['Name'] = raw_input(" Enter the name of your template: ") def edit_size(): # Prints and calculates ppv for size print""" size g/oz size kg/lbs size kg/lbs size kg/lbs size tons -20 49/1.7 -12 0.8/1.7 -4 13/28 4 200/440 12 3.2 -19 73/2.6 -11 1.2/2.6 -3 19/41 5 300/660 13 4.8 -18 98/3.4 -10 1.6/3.4 -2 25/55 6 400/880 14 6.4 -17 150/5.2 -9 2.3/5.2 -1 38/83 7 600/1320 15 9.6 -16 200/6.9 -8 3.1/6.9 0 50/110 8 800/1760 16 12.8 -15 270/10 -7 4.7/10 1 75/165 9 1200/2640 17 19.2 -14 390/14 -6 6.3/14 2 100/220 10 1600/3520 18 25.6 -13 550/21 -5 9.4/21 3 150/330 11 2400/5280 19 38.4 -12 780/28 -4 12.5/28 4 200/440 12 3200/7040 20 51.2 """ if stats['Size'] != 0: stats['PPV'] -= stats['Size'] stats['Size'] = input(" Enter the size of your template: ") if stats['Reach PPV'] != 0: calc_reach() # If size is changed after reach is entered, this stats['PPV'] += stats['Size'] # will recalculate the ppv values def edit_reach(): # Edits ppv for reach, depending on size stats['Reach'] = (-1) stats['PPV'] -= stats['Reach PPV'] stats['Reach PPV'] = 0 while stats['Reach'] == -1: stats['Reach'] = input(" Enter the approximate reach of your race (in meters): ") if (0.38 > stats['Reach']) or (5.5 < stats['Reach']): stats['Reach'] = -1 calc_reach() def calc_reach(): # Calculates PPV values for reach # minimum reach values with PPV of -6,-5.5,-5,-4.5... values = (0.38, 0.41, 0.44, 0.47, 0.5, 0.54, 0.58, 0.62, 0.65, 0.69, 0.73, 0.77, 0.8, 0.88, 0.96, 1.04, 1.1, 1.17, 1.32, 1.4, 1.5, 1.6, 1.7, 1.8, 1.95, 2.1, 2.25, 2.4, 2.55, 2.7, 2.85, 3.0, 3.25, 3.5, 3.75, 4.0, 4.25, 4.5, 4.75, 5.0, 5.5) if stats['Reach PPV'] != 0: stats['PPV'] -= stats['Reach PPV'] stats['Reach PPV'] = 0 for i in range (len(values)-1): if values[i] <= stats['Reach'] < values [i+1]: stats['Reach PPV'] = (0.5 * i) - 6 stats['Reach PPV'] = stats['Reach PPV'] - stats['Size'] stats['PPV'] += stats['Reach PPV'] def check_stride(): # Assigns PPV values for Stride values = (0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 5.5) for i in range (len(values)-1): if values[i] <= stats['Stride'] < values[i+1]: x = values[i] return(x) def edit_stride(): # Gets & calculates PPV for Stride if stats['Stride'] != 0: x = check_stride() stats['PPV'] -= x stats['Stride'] = -1 while stats['Stride'] == -1: stats['Stride'] = input(" Enter your template's stride in meters: ") if (stats['Stride'] < 0) or (stats['Stride'] > 5.5): stats['Stride'] = -1 else: x = check_stride() stats['PPV'] += x def edit_abilities(): # Edits ability values & PPV choices = ('Acrobatics', 'Alchemy', 'Animal Handling', 'Climbing', 'Communication', 'Craftsmanship', 'Detection', 'Flying', 'Hand to Hand', 'Marksmanship', 'Power', 'Regeneration', 'Running', 'Stealth', 'Strength', 'Swimming', 'Toughness') get_choice = -1 while get_choice != 0: print_abilities() get_choice = input(" Edit which ability: ") if (get_choice < 1) or (get_choice > len(choices) + 1): continue if get_choice == 18: name = raw_input(" Enter the name of the ability: ") else: name = choices[get_choice-1] if (abilities.has_key(name)): if abilities[name] != 0: calc_abil_ppv(-abilities[name]) abilities[name] = input(" How much " + name + " would you like: ") calc_abil_ppv(abilities[name]) def calc_abil_ppv(bonus): # Calculates PPV cost for abilities/disabilities if bonus > 0: stats['PPV'] += ((2**bonus)/2) if bonus < 0: bonus = abs(bonus) stats['PPV'] -= ((2**(bonus))/2) def print_abilities(): # prints available abilities # added #17 in case players wanted an ability # not on the list print """ Available Abilities 1. Acrobatics 2. Alchemy 3. Animal Handling 4. Climbing 5. Communication 6. Craftsmanship 7. Detection 8. Flying 9. Hand to Hand 10. Marksmanship 11. Power 12. Regeneration 13. Running 14. Stealth 15. Strength 16. Swimming 17. Toughness 18. **OTHER** 0. Return to Main """ def edit_disabilities(): # Calculates Disabilities choices = ['Ignorance', 'Thumbless', 'Farsighted', 'Nearsighted', 'Deaf', 'Lame'] get_choice = -1 while get_choice != 0: print_disabilities() get_choice = input(" Edit which disability: ") if (get_choice < 1) or (get_choice > len(choices)): continue choice = choices[get_choice - 1] if disabilities[choice] != 0: calc_abil_ppv(-disabilities[choice]) x = input(" How much " + choice + " would you like: ") if x > 4: x = 4 disabilities[choice] = -x calc_abil_ppv(disabilities[choice]) def print_disabilities(): # Prints disability menu print """ Available Abilities 1. Ignorance 2. Thumbless 3. Farsighted 4. Nearsighted 5. Deaf 6. Lame 0. Return to Main """ def print_equip_menu(): # Prints equipment modification menu print """ NATURAL ARMOR 1. Edit Absorbtion 2. Edit Cover NATURAL WEAPON 3. Edit Conceal Bonus 4. Edit Grapple Bonus 5. Edit Parry Bonus 6. Edit Sharpness Bonus 0. Return to Main """ def edit_equip(): # Edit Equipment get_choice = -1 print_equip_menu() get_choice = input(" Enter your selection: ") while get_choice != 0: if get_choice == 1: edit_abs() elif get_choice == 2: edit_cvr() elif get_choice == 3: edit_cncl() elif get_choice == 4: edit_grp() elif get_choice == 5: edit_pry() elif get_choice == 6: edit_shrp() print_equip_menu() get_choice = input(" Enter your selection: ") def edit_abs(): if nat_arm['Absorbtion'] != 0: calc_abil_ppv(-nat_arm['Absorbtion']) nat_arm['Absorbtion'] = 0 nat_arm['Absorbtion'] = input(" How much Absorbtion would you like: ") while nat_arm['Absorbtion'] < 0: nat_arm['Absorbtion'] = input(" How much Absorbtion would you like: ") calc_abil_ppv(nat_arm['Absorbtion']) def edit_cvr(): if nat_arm['Cover'] != 0: calc_abil_ppv(-(nat_arm['Cover'])) nat_arm['Cover'] = 0 nat_arm['Cover'] = input(" How much Cover would you like: ") while nat_arm['Cover'] < 0: nat_arm['Cover'] = input(" How much Cover would you like: ") calc_abil_ppv(nat_arm['Cover']) def edit_cncl(): if nat_wpn['Conceal'] != 0: x = (nat_wpn['Conceal'] +1) calc_abil_ppv(-x) nat_wpn['Conceal'] = 0 nat_wpn['Conceal'] = input(" How much Conceal would you like: ") while nat_wpn['Conceal'] < 0: nat_wpn['Conceal'] = input(" How much Conceal would you like: ") if nat_wpn['Conceal'] > 0: calc_abil_ppv(nat_wpn['Conceal']+1) def edit_grp(): if nat_wpn['Grapple'] != 0: x = (nat_wpn['Grapple'] +1) calc_abil_ppv(-x) nat_wpn['Grapple'] = 0 nat_wpn['Grapple'] = input(" How much Grapple would you like: ") while nat_wpn['Grapple'] < 0: nat_wpn['Grapple'] = input(" How much Grapple would you like: ") if nat_wpn['Grapple'] >0: calc_abil_ppv(nat_wpn['Grapple']+1) def edit_pry(): if nat_wpn['Parry'] != 0: calc_abil_ppv(-nat_wpn['Parry']) nat_wpn['Parry'] = 0 nat_wpn['Parry'] = input(" How much Parry would you like: ") while nat_wpn['Parry'] < 0: nat_wpn['Parry'] = input(" How much Parry would you like: ") calc_abil_ppv(nat_wpn['Parry']) def print_sharp(): print """ Sharpness Bonus PPV Scale Sharp -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 PPV 0 0.5 1 1.5 2 4 8 16 32 64 128 256 512 """ def check_sharp(): # sharpness ppv starting at -7 sharpness ppv = (0, 0.5, 1, 1.5, 2, 4, 8, 16, 32, 64, 128, 256, 512) return ppv[nat_wpn['Sharpness'] + 7] def edit_shrp(): if nat_wpn['Sharpness'] != -7: check_sharp(-nat_wpn['Sharpness']) nat_wpn['Sharpness'] = -7 print_sharp() nat_wpn['Sharpness'] = input(" How much Sharpness would you like: ") while (nat_wpn['Sharpness'] < -7) or (nat_wpn['Sharpness'] > 5): print_sharp() nat_wpn['Sharpness'] = input(" How much Sharpness would you like: ") nat_wpn['Sharpness'] = int (floor (nat_wpn['Sharpness'])) x = check_sharp() stats['PPV'] += x def save_dict(): #Save template as a single dictionary filename = stats['Name'] + '.txt' out_file = open(filename, "w") data = {} data.update(stats) # equivalent to "for key in stats.keys(): data[key] = stats[key]" data.update(abilities) data.update(disabilities) data.update(nat_arm) data.update(nat_wpn) out_file.write(repr(data)) out_file.close() def save_temp(): #Save to File. Saves in same folder as Template Generator x = stats['Name']+'.txt' out_file = open(x, "w") out_file.write("Name : "+stats['Name']+'\n') out_file.write("Size : "+repr(stats['Size'])+'\n') # Used 'repr()' to turn 'int' into 'str'; out_file.write("Reach : "+repr(stats['Reach'])+'\n') # Won't work otherwise out_file.write("Stride : "+repr(stats['Stride'])+'\n') out_file.write("PPV : "+repr(stats['PPV'])+'\n') out_file.write('\n') for x in abilities.keys(): if (abilities[x]) != 0: out_file.write(x+" \t:"+repr(abilities[x])+"\n") out_file.write('\n') for x in disabilities.keys(): if (disabilities[x]) != 0: out_file.write(x+"\t:"+repr(disabilities[x])+"\n") out_file.write('\n') for x in nat_arm.keys(): if len(x) < 8: out_file.write(x+"\t\t:"+repr(nat_arm[x])+"\n") else: out_file.write(x+"\t:"+repr(nat_arm[x])+"\n") out_file.write('\n') for x in nat_wpn.keys(): if len(x) < 8: out_file.write(x+"\t\t:"+repr(nat_wpn[x])+"\n") else: out_file.write(x+"\t:"+repr(nat_wpn[x])+"\n") out_file.close() print_main_menu() # The equivalent of Main get_choice = -1 get_choice = input(" Enter your selection: ") while get_choice != 0: if get_choice == 1: edit_name() elif get_choice == 2: edit_size() elif get_choice == 3: edit_reach() elif get_choice == 4: edit_stride() elif get_choice == 5: edit_abilities() elif get_choice == 6: edit_disabilities() elif get_choice == 7: edit_equip() elif get_choice == 8: # save_temp() save_dict() print_main_menu() get_choice = input(" Enter your selection: ")