def base_gen(starport): naval = False scout = False pirate = False if starport in ["A", "B"] and stellagama.dice(2, 6) >= 8: naval = True if starport in ["A", "B", "C", "D"]: scout_presence = stellagama.dice(2, 6) if starport == "C": scout_presence -= 1 elif starport == "B": scout_presence -= 2 elif starport == "A": scout_presence -= 3 if scout_presence >= 7: scout = True if starport != "A" and naval == False: if stellagama.dice(2, 6) >= 12: pirate = True if naval and not scout: base = "N" elif scout and not naval: base = "S" elif scout and naval: base = "A" elif pirate and not scout: base = "P" elif pirate and scout: base = "T" else: base = " " return base
def pbg_gen(pop): pbg = [0, 0, 0] if pop == 0: pbg[0] = 0 else: pbg[0] = stellagama.dice(2, 6) - 2 if pbg[0] < 1: pbg[0] = 1 elif pbg[0] > 9: pbg[0] = 9 if stellagama.dice(2, 6) >= 4: pbg[1] = stellagama.dice(1, 6) - 3 if pbg[1] < 1: pbg[1] = 1 else: pbg[1] = 0 if stellagama.dice(2, 6) >= 5: pbg[2] = stellagama.dice(1, 6) - 2 if pbg[2] < 1: pbg[2] = 1 else: pbg[2] = 0 for item in range(0, 3): pbg[item] = str(pbg[item]) return "".join(pbg)
def hp_gen(charclass, ability_dict, level): hp = 0 hp_dict = { "fighter": 8, "mage": 4, "cleric": 6, "thief": 4, "assassin": 6, "bard": 6, "bladedancer": 6, "explorer": 6, "vaultguard": 8, "craftpriest": 6, "spellsword": 6, "nightblade": 6, "anti-paladin": 6, "barbarian": 8, "delver": 6, "fury": 8, "machinist": 6, "courtier": 6, "enchanter": 4, "ranger": 6, "trickster": 4, "mystic": 6, "wonderworker": 4, "paladin": 6, "priestess": 4, "shaman": 6, "gladiator": 8, "venturer": 6, "warlock": 4, "witch": 4, "ruinguard": 6, "beastmaster": 6, "berserker": 8, "chosen": 6, "spellsinger": 4, "freebooter": 4, "bounder": 6, "burglar": 4, "champion": 8, "wizard": 4, "deathchanter": 8, "warmistress": 6, "darklord": 4, "sorcerer": 4 } if level == 0: hp = stellagama.dice(1, 6) elif level > 1: for i in range(1, level + 1): hp += stellagama.dice(1, hp_dict[charclass]) else: hp = stellagama.dice(1, 6) hp += attribute_modifier(ability_dict["constitution"]) if hp <= 0: hp = 1 return hp
def gas_gen(): """ determine gas giant presence """ gas = 0 gas_presence = 0 gas_presence = stellagama.dice(2, 6) if gas_presence >= 5: gas = stellagama.dice(1, 6) - 2 if gas < 1: gas = 1 else: gas = 0 return gas #output gas giant number
def planetoid_gen(worldsize): #input world size """ determine planetoid presence """ planetoid = 0 planetoid_presence = 0 planetoid_presence = stellagama.dice(2, 6) if planetoid_presence >= 4 or worldsize == 0: planetoid = stellagama.dice(1, 6) - 3 if planetoid < 1: planetoid = 1 else: planetoid = 0 return planetoid #output planetoid belt number
def size_gen(): """ generates the size number """ worldsize = 0 worldsize = stellagama.dice(2, 6) - 2 return worldsize #outputs world size number
def __init__(self, level): self.level = level self.sex = random.choice(["male", "female"]) self.race = henchgenlib.race_gen() self.abilities = henchgenlib.ability_gen(self.race) self.ability_mods = henchgenlib.ability_modifiers(self.abilities) self.name = henchgenlib.name_gen(self.sex) self.charclass = henchgenlib.class_gen(self.level, self.race, self.sex, self.abilities) if level > 0: self.template = henchgenlib.template_gen(self.charclass) else: pass self.hp = henchgenlib.hp_gen(self.charclass, self.abilities, self.level) self.inventory = [] self.gold = 10 * stellagama.dice(3, 6) self.proficiencies = henchgenlib.prof_gen(self.level, self.charclass, self.ability_mods["int"]) self.inventory = henchgenlib.inventory_gen(self.level, self.charclass) self.trinket = henchgenlib.trinket_gen() if self.trinket is not None: self.inventory.append(self.trinket) else: pass self.proficiency_string = stellagama.list_stringer_comma( self.proficiencies) self.inventory.sort() self.inventory_string = stellagama.list_stringer_comma(self.inventory) self.quirk = henchgenlib.quirk_gen()
def sector_generator_csv(maxrow, maxcolumn): sector_name = stellagama.savefile("csv") with open(sector_name, 'w') as csvfile: csvwriter = csv.writer( csvfile, delimiter=',', lineterminator='\n', ) for column in range(1, maxcolumn + 1): for row in range(1, maxrow + 1): if stellagama.dice(1, 6) >= 4: if row <= 9: row_location = "0%i" % row elif row >= 10: row_location = "%i" % row if column <= 9: column_location = "0%i" % column elif column >= 10: column_location = "%i" % column world_hex = column_location + row_location world = worldgenlib.World(world_hex) world_list = [ column_location, row_location, world.name, world.uwp_dict["starport"], world.uwp_dict["size"], world.uwp_dict["atmosphere"], world.uwp_dict["hydrographics"], world.uwp_dict["population"], world.uwp_dict["government"], world.uwp_dict["law"], world.uwp_dict["tl"], world.zone, world.base, world.gas_giant, world.trade_string ] csvwriter.writerow(world_list) else: pass
def sector_generator(maxrow, maxcolumn): sector_name = stellagama.savefile("sec") output = open(sector_name, "w") output.write( f"{'Hex': <{5}}{'Name': <{13}}{'UWP': <{10}}{'Remarks': <{28}}{'{Ix}': <{6}}{'(Ex)': <{8}}{'[Cx]': <{7}}{'N': <{2}}{'B': <{3}}{'Z': <{2}}{'PBG': <{4}}{'W': <{3}}{'A': <{3}}{'Stellar': <{22}}\n" ) output.write( "---- ------------ --------- --------------------------- ----- ------- ------ - -- - --- -- -- ----------------------\n" ) for column in range(1, maxcolumn + 1): for row in range(1, maxrow + 1): if stellagama.dice(1, 6) >= 4: if row <= 9: row_location = "0%i" % row elif row >= 10: row_location = "%i" % row if column <= 9: column_location = "0%i" % column elif column >= 10: column_location = "%i" % column world_hex = column_location + row_location world = worldgenlib.World(world_hex) world_string = world.get_world_row() + "\r" output.write(world_string) else: pass output.close()
def __init__ (self, level): #input character level self.level=level self.strength=stellagama.dice(3,6) #ability generation self.dexterity=stellagama.dice(3,6) self.constitution=stellagama.dice(3,6) self.intelligence=stellagama.dice(3,6) self.wisdom=stellagama.dice(3,6) self.charisma=stellagama.dice(3,6) self.strmod=henchgenlib.attribute_modifier(self.strength) #ability modifier calculation self.dexmod=henchgenlib.attribute_modifier(self.dexterity) self.conmod=henchgenlib.attribute_modifier(self.constitution) self.intmod=henchgenlib.attribute_modifier(self.intelligence) self.wismod=henchgenlib.attribute_modifier(self.wisdom) self.chamod=henchgenlib.attribute_modifier(self.charisma) self.attribute_list=[self.strength,self.dexterity, self.constitution, self.intelligence, self.wisdom, self.charisma] #turning abilities into a list self.gold=10*stellagama.dice(3,6) #generate starting gold self.sex=henchgenlib.sex_gen() #generate sex self.race=henchgenlib.race_gen(self.constitution, self.intelligence) #generate race self.name=henchgenlib.name_gen(self.sex) #generate name self.cclass=henchgenlib.charclass(self.strength, self.dexterity, self.constitution, self.intelligence, self.wisdom, self.charisma, self.sex, self.race, self.level) #choose character class self.hp=henchgenlib.hp_gen(self.cclass, self.conmod, self.level) #generate hit points self.proficiencies=henchgenlib.profgen(self.intmod, self.level, self.cclass) #generate proficiencies self.weapon=henchgenlib.weapon_gen(self.cclass) #generate weapon self.armor=henchgenlib.armor_gen(self.cclass) #generate armor self.trinket=stellagama.random_line("trinkets.txt") #generates trinket self.quirk=stellagama.random_line("quirks.txt") #generates quirk
def gov_gen(population): government = stellagama.dice(2, 6) - 7 + population if population == 0: government = 0 if government < 0: government = 0 if government > 15: government = 15 return government
def law_gen(government): law = stellagama.dice(2, 6) - 7 + government if government == 0: law = 0 if law < 0: law = 0 if law > 10: law = 10 return law
def zone_gen(uwp_dict): if uwp_dict["atmosphere"] >= 10: if stellagama.dice(2, 6) >= 9: return "A" else: return " " if uwp_dict["government"] in [0, 7, 10]: if stellagama.dice(2, 6) >= 9: return "A" else: return " " if uwp_dict["law"] == 0 or uwp_dict["law"] >= 9: if stellagama.dice(2, 6) >= 9: return "A" else: return " " else: return " "
def base_gen(starport): #input starship letter """ determine base presence """ base = " " naval = 0 naval_presence = 0 scout = 0 scout_presence = 0 pirate = 0 pirate_presence = 0 if starport in ["A", "B"]: naval_presence = stellagama.dice(2, 6) if naval_presence >= 8: naval = 1 else: naval = 0 if starport in ["A", "B", "C", "D"]: scout_presence = stellagama.dice(2, 6) if starport == "C": scout_presence -= 1 if starport == "B": scout_presence -= 2 if starport == "A": scout_presence -= 3 if scout_presence >= 7: scout = 1 if starport != "A" and naval != 1: pirate_presence = stellagama.dice(2, 6) if pirate_presence >= 12: pirate = 1 else: pirate = 0 if naval == 1 and scout == 1 and pirate != 1: base = "A" if scout == 1 and pirate == 1 and naval != 1: base = "G" if naval == 1 and scout != 1 and pirate != 1: base = "N" if naval != 1 and scout != 1 and pirate == 1: base = "P" if naval != 1 and scout == 1 and pirate != 1: base = "S" return base #output base letter
def atmo_gen(size): if size == 0: atmosphere = 0 else: atmosphere = stellagama.dice(2, 6) - 7 + size if atmosphere > 15: atmosphere = 15 if atmosphere < 0: atmosphere = 0 return atmosphere
def tech_gen(uwp_dict): tech = stellagama.dice(1, 6) if uwp_dict["starport"] == "A": tech += 6 elif uwp_dict["starport"] == "B": tech += 4 elif uwp_dict["starport"] == "C": tech += 2 elif uwp_dict["starport"] == "X": tech -= 4 if uwp_dict["size"] in [0, 1]: tech += 2 elif uwp_dict["size"] in range(1, 5): tech += 1 if uwp_dict["atmosphere"] in range(0, 4): tech += 1 elif uwp_dict["atmosphere"] >= 10: tech += 1 if uwp_dict["hydrographics"] == 0: tech += 1 elif uwp_dict["hydrographics"] in [9, 10]: tech += 1 if uwp_dict["population"] in range(1, 6): tech += 1 elif uwp_dict["population"] == 9: tech += 1 elif uwp_dict["population"] == 10: tech += 2 elif uwp_dict["population"] == 11: tech += 3 elif uwp_dict["population"] >= 12: tech += 4 if uwp_dict["government"] in [1, 5]: tech += 1 elif uwp_dict["government"] == 7: tech += 2 elif uwp_dict["government"] in [13, 14]: tech -= 2 if uwp_dict["hydrographics"] in [ 0, 10 ] and uwp_dict["population"] >= 6 and tech < 4: tech = 4 elif uwp_dict["atmosphere"] in [4, 7, 9] and tech < 5: tech = 5 elif uwp_dict["atmosphere"] in [0, 1, 2, 3, 10, 11, 12] and tech < 7: tech = 7 elif uwp_dict["atmosphere"] in [ 13, 14 ] and uwp_dict["hydrographics"] == 10 and tech < 7: tech = 7 if tech < 0: tech = 0 elif uwp_dict["population"] == 0: tech = 0 return tech
def law_gen(worldgov): #inputs the world government number """ generate law level number """ worldlaw = 0 worldlaw = stellagama.dice(2, 6) - 7 + worldgov if worldgov == 0: worldlaw = 0 if worldlaw < 0: worldlaw = 0 return worldlaw #outputs the world law level number
def tech_gen( starport, worldsize, worldatmo, worldhyd, worldpop, worldgov ): #input the world's starport, size, atmosphere, hydrographics, population, and government ratings - 6 parameters """ generate tech-level number """ worldtech = 0 worldtech = stellagama.dice(1, 6) if starport == "A": worldtech += 6 if starport == "B": worldtech += 4 if starport == "C": worldtech += 2 if starport == "X": worldtech -= 4 if worldsize in [0, 1]: worldtech += 2 if worldsize in [2, 3, 4]: worldtech += 1 if worldatmo in [0, 1, 2, 3, 10, 11, 12, 13, 14, 15]: worldtech += 1 if worldhyd in [0, 9]: worldtech += 1 if worldhyd == 10: worldtech += 2 if worldpop == 0: worldtech = 0 if worldpop in [1, 2, 3, 4, 5, 9]: worldtech += 1 if worldpop == 10: worldtech += 2 if worldpop == 11: worldtech += 3 if worldpop == 12: worldtech += 4 if worldgov in [0, 5]: worldtech += 1 if worldgov == 7: worldtech += 2 if worldgov in [13, 14]: worldtech -= 2 if worldhyd in [0, 10] and worldpop >= 6 and worldtech < 4: worldtech = 4 if worldatmo in [4, 7, 9] and worldtech < 5: worldtech = 5 if worldatmo < 3 or worldatmo in [10, 11, 12]: if worldtech < 7: worldtech = 7 if worldatmo in [13, 14] and worldhyd == 10 and worldtech < 7: worldtech = 7 if worldtech < 0: worldtech = 0 return worldtech #outputs the world tech level number
def sex_gen(): """ sex-generating function """ roll = stellagama.dice(1, 6) if roll in [1, 2, 3]: return "male" elif roll in [4, 5, 6]: return "female" else: return "androgynous"
def pop_mod(worldpop): #inputs the world population number """ generates the population multiplier """ popmod = 0 popmod = stellagama.dice(2, 6) - 2 if worldpop == 0: popmod = 0 if popmod > 9: popmod = 9 return popmod #outputs the world population multiplier
def individual_chargen(levelNumber, levelDie, characterLevel): charstring = "" for i in range (0, stellagama.dice(levelNumber, levelDie)): character1=character(characterLevel) charstring += "%s, level %s %s %s %s, %s hit points" %(character1.name, character1.level, character1.sex, character1.race, character1.cclass, character1.hp)+'\r\n' charstring += "STR: %s DEX: %s CON: %s INT: %s WIS: %s CHA: %s" %(character1.strength, character1.dexterity, character1.constitution, character1.intelligence, character1.wisdom, character1.charisma)+'\r\n' proflist=", ".join(character1.proficiencies) charstring += "Proficiencies: %s" %(proflist)+'\r\n' charstring += character1.quirk+'\r\n' charstring += "%s, %s, %s" %(character1.weapon, character1.armor, character1.trinket)+'\r\n' charstring += '\r\n' return charstring
def atmo_gen(worldsize): #inputs world size number """ generates the atmosphere number """ worldatmo = 0 worldatmo = stellagama.dice(2, 6) - 7 + worldsize if worldsize == 0: worldatmo = 0 if worldatmo < 0: worldatmo = 0 if worldatmo > 15: worldatmo = 15 return worldatmo #outputs atmosphere number
def hp_gen(cclass, conmod, level): #input character class, constitution modifier, and level """ hit point generator """ if level == 0: hp = stellagama.dice(1, 6) + conmod else: if cclass in ["fighter", "vaultguard"]: hp = stellagama.dice(level, 8) + conmod elif cclass in ["mage", "thief"]: hp = stellagama.dice(level, 4) + conmod elif cclass in [ "assassin", "cleric", "bard", "bladedancer", "explorer", "craftpriest", "spellsword", "nightblade" ]: hp = stellagama.dice(level, 6) + conmod else: hp = 1 + conmod if hp < 1: hp = 1 return hp #output hit points
def race_gen(con, intel): """ race-generating function """ roll = stellagama.dice(1, 6) if roll in [1, 2, 3, 4]: return "human" elif roll == 5 and intel >= 9: return "elf" if roll == 6 and con >= 9: return "dwarf" else: return "human"
def hydro_gen(size, atmosphere): hydrographics = stellagama.dice(2, 6) - 7 + size if size <= 1: hydrographics = 0 elif atmosphere in [0, 1, 10, 11, 12]: hydrographics -= 4 elif atmosphere == 14: hydrographics -= 2 if hydrographics < 0: hydrographics = 0 if hydrographics > 10: hydrographics = 10 return hydrographics
def gov_gen(worldpop): #inputs the world population number """ generate government number """ worldgov = 0 worldgov = stellagama.dice(2, 6) - 7 + worldpop if worldgov < 0: worldgov = 0 if worldgov > 15: worldgov = 15 if worldpop == 0: worldgov = 0 return worldgov #outputs the world government number
def add_skill(skill_list, skill): #inputs the skill dictionary and skill """ adds a skill or characteristic bonus to a character """ if skill == "Gun Combat": if stellagama.dice(1, 6) >= 3: for item in guns: if item in skill_list: skill = item else: skill = stellagama.random_choice(guns) else: skill = stellagama.random_choice(guns) elif skill in ["Blade Combat", "Blade Cbt"]: if stellagama.dice(1, 6) >= 3: for item in melee: if item in skill_list: skill = item else: skill = stellagama.random_choice(melee) else: skill = stellagama.random_choice(melee) elif skill == "Vehicle": if stellagama.dice(1, 6) >= 3: for item in vehicles: if item in skill_list: skill = item else: skill = stellagama.random_choice(vehicles) else: skill = stellagama.random_choice(vehicles) if skill in skill_list: skill_list[skill] += 1 elif skill not in skill_list: skill_list[skill] = 1 return skill_list #outputs the skill dictionary
def pop_gen(atmosphere, hydrographics): population = stellagama.dice(2, 6) - 2 if atmosphere >= 10: population -= 2 elif atmosphere == 6: population += 3 elif atmosphere in [5, 8]: population += 1 if hydrographics == 0 and atmosphere < 3: population -= 1 if population < 0: population = 0 elif population > 10: population = 10 return population
def race_gen(): throw = stellagama.dice(1, 100) if throw <= 83: return "human" elif throw in range(84, 91): return "elven" elif throw in range(91, 98): return "dwarven" elif throw == 98: return "thrassian" elif throw == 99: return "zaharan" elif throw == 100: sub_throw = stellagama.dice(1, 3) if sub_throw == 1: return "gnome" elif sub_throw == 2: return "halfling" elif sub_throw == 3: return "nobiran" else: return "human" else: return "human"
def __init__(self, hex): self.name = stellagama.random_line(os.path.join('data', 'worlds.txt')) self.hex = hex self.uwp_dict = { "starport": "X", "size": stellagama.dice(2, 6) - 2, "atmosphere": 0, "hydrographics": 0, "population": 0, "government": 0, "law": 0, "tl": 0 } self.uwp_dict["atmosphere"] = atmo_gen(self.uwp_dict["size"]) self.uwp_dict["hydrographics"] = hydro_gen(self.uwp_dict["size"], self.uwp_dict["atmosphere"]) self.uwp_dict["population"] = pop_gen(self.uwp_dict["atmosphere"], self.uwp_dict["hydrographics"]) self.uwp_dict["government"] = gov_gen(self.uwp_dict["population"]) self.uwp_dict["law"] = law_gen(self.uwp_dict["government"]) self.uwp_dict["starport"] = starport_gen(self.uwp_dict["population"]) self.uwp_dict["tl"] = tech_gen(self.uwp_dict) self.hex_uwp = { "starport": self.uwp_dict["starport"], "size": stellagama.pseudo_hex(self.uwp_dict["size"]), "atmosphere": stellagama.pseudo_hex(self.uwp_dict["atmosphere"]), "hydrographics": stellagama.pseudo_hex(self.uwp_dict["hydrographics"]), "population": stellagama.pseudo_hex(self.uwp_dict["population"]), "government": stellagama.pseudo_hex(self.uwp_dict["government"]), "law": stellagama.pseudo_hex(self.uwp_dict["law"]), "tl": stellagama.pseudo_hex(self.uwp_dict["tl"]) } self.zone = zone_gen(self.uwp_dict) self.pbg = pbg_gen(self.uwp_dict["population"]) self.pbg_list = self.pbg.split() if int(self.pbg_list[0]) > 0: self.gas_giant = "G" self.base = base_gen(self.uwp_dict["starport"]) self.trade_list = trade_gen(self.uwp_dict) self.trade_string = " ".join(self.trade_list) self.allegiance = "Na" self.ix = "" self.ex = "" self.cx = "" self.noble = "" self.w = "" self.stellar = ""