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 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 sec_gen( maxcolumn, maxrow ): #input maximum generated space row and column. as well as the file name for generation """ SEC file generating function """ sector_name = stellagama.savefile("txt") file_name = sector_name + ".sec" with open(file_name, "w") as outp: outp.write(sector_name + '\r\n') #start of SEC file header output outp.write("" + '\r\n') outp.write( "The data in the sector text files is laid out in column format:" + '\r\n') outp.write("" + '\r\n') outp.write(" 1-14: Name" + '\r\n') outp.write("15-18: HexNbr" + '\r\n') outp.write("20-28: UWP" + '\r\n') outp.write(" 31: Bases" + '\r\n') outp.write("33-47: Codes & Comments" + '\r\n') outp.write(" 49: Zone" + '\r\n') outp.write("52-54: PBG" + '\r\n') outp.write("56-57: Allegiance" + '\r\n') outp.write("59-74: Stellar Data" + '\r\n') outp.write("" + '\r\n') outp.write( "....+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8" + '\r\n') outp.write("" + '\r\n') #end of SEC file header output for column in range(1, maxcolumn + 1): #generate subsector, quadrant, or sector for row in range(1, maxrow + 1): throw = stellagama.dice(1, 6) if throw >= 4: if row <= 9: row_loc = "0%i" % (row) if row >= 10: row_loc = "%i" % (row) if column <= 9: column_loc = "0%i" % (column) if column >= 10: column_loc = "%i" % (column) worldhex = column_loc + row_loc world_line = world_gen(worldhex) outp.write(world_line + '\r\n')
def sector_generator_json(maxrow, maxcolumn): sector_name = stellagama.savefile("json") sector_dict = {} for column in range(1, maxcolumn + 1): sector_dict[column] = {} 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_dict = { "hex": world_hex, "name": world.name, "starport": world.uwp_dict["starport"], "size": world.uwp_dict["size"], "atmosphere": world.uwp_dict["atmosphere"], "hydrographics": world.uwp_dict["hydrographics"], "population": world.uwp_dict["population"], "government": world.uwp_dict["government"], "law": world.uwp_dict["law"], "tl": world.uwp_dict["tl"], "zone": world.zone, "base": world.base, "gas_giants": world.gas_giant, "trade": world.trade_string } sector_dict[column][row] = world_dict else: pass with open(sector_name, 'w') as outfile: json.dump(sector_dict, outfile)
def chargen( level0number, level0die, level1number, level1die, level2number, level2die, level3number, level3die, level4number, level4die ): #input dice numbers and types for all four potential character levels """ generates NPCs in numbers based on the dice numbers and types received """ filename = stellagama.savefile("txt") with open(filename, "w") as output: for i in range(0, stellagama.dice(level0number, level0die)): character1 = character(0) output.write("%s, level %s %s %s %s, %s hit points" % (character1.name, character1.level, character1.sex, character1.race, character1.cclass, character1.hp) + '\r\n') output.write("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) output.write("Proficiencies: %s" % (proflist) + '\r\n') output.write(character1.quirk + '\r\n') output.write( "%s, %s, %s" % (character1.weapon, character1.armor, character1.trinket) + '\r\n') output.write('\r\n') for i in range(0, stellagama.dice(level1number, level1die)): character1 = character(1) output.write("%s, level %s %s %s %s, %s hit points" % (character1.name, character1.level, character1.sex, character1.race, character1.cclass, character1.hp) + '\r\n') output.write("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) output.write("Proficiencies: %s" % (proflist) + '\r\n') output.write(character1.quirk + '\r\n') output.write( "%s, %s, %s" % (character1.weapon, character1.armor, character1.trinket) + '\r\n') output.write('\r\n') for i in range(0, stellagama.dice(level2number, level2die)): character1 = character(2) output.write("%s, level %s %s %s %s, %s hit points" % (character1.name, character1.level, character1.sex, character1.race, character1.cclass, character1.hp) + '\r\n') output.write("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) output.write("Proficiencies: %s" % (proflist) + '\r\n') output.write(character1.quirk + '\r\n') output.write( "%s, %s, %s" % (character1.weapon, character1.armor, character1.trinket) + '\r\n') output.write('\r\n') for i in range(0, stellagama.dice(level3number, level3die)): character1 = character(3) output.write("%s, level %s %s %s %s, %s hit points" % (character1.name, character1.level, character1.sex, character1.race, character1.cclass, character1.hp) + '\r\n') output.write("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) output.write("Proficiencies: %s" % (proflist) + '\r\n') output.write(character1.quirk + '\r\n') output.write( "%s, %s, %s" % (character1.weapon, character1.armor, character1.trinket) + '\r\n') output.write('\r\n') for i in range(0, stellagama.dice(level4number, level4die)): character1 = character(4) output.write("%s, level %s %s %s %s, %s hit points" % (character1.name, character1.level, character1.sex, character1.race, character1.cclass, character1.hp) + '\r\n') output.write("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) output.write("Proficiencies: %s" % (proflist) + '\r\n') output.write(character1.quirk + '\r\n') output.write( "%s, %s, %s" % (character1.weapon, character1.armor, character1.trinket) + '\r\n') output.write('\r\n')
def sector_generator_excel(maxrow, maxcolumn): file_name = stellagama.savefile("xlsx") sector_name = file_name.strip('.xlsx') workbook = openpyxl.Workbook() sheet = workbook.active sheet.title = sector_name sheet['A1'] = sector_name sheet['A1'].font = Font(size=16, bold=True) sheet['A2'] = "Generated by the Cepheus Light World Generator" for cell in [ "A3", "B3", "C3", "D3", "E3", "F3", 'G3', 'H3', 'I3', 'J3', 'K3', 'L3', 'M3' ]: sheet[cell].font = Font(bold=True) sheet['A3'] = "Hex" sheet['B3'] = "Starport" sheet['C3'] = "Size" sheet['D3'] = "Atmosphere" sheet['E3'] = "Hydrographics" sheet['F3'] = "Population" sheet['G3'] = "Government" sheet['H3'] = "Law" sheet['I3'] = "TL" sheet['J3'] = "Zone" sheet['K3'] = "Bases" sheet['L3'] = "Gas Giant" sheet['M3'] = "Trade Codes" excel_row = 3 for column in range(1, maxcolumn + 1): for row in range(1, maxrow + 1): if stellagama.dice(1, 6) >= 4: excel_row += 1 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() sheet.cell(row=excel_row, column=1).value = world_hex sheet.cell(row=excel_row, column=2).value = world.hex_uwp["starport"] sheet.cell(row=excel_row, column=3).value = world.hex_uwp["size"] sheet.cell(row=excel_row, column=4).value = world.hex_uwp["atmosphere"] sheet.cell(row=excel_row, column=5).value = world.hex_uwp["hydrographics"] sheet.cell(row=excel_row, column=6).value = world.hex_uwp["population"] sheet.cell(row=excel_row, column=7).value = world.hex_uwp["government"] sheet.cell(row=excel_row, column=8).value = world.hex_uwp["law"] sheet.cell(row=excel_row, column=9).value = world.hex_uwp["tl"] sheet.cell(row=excel_row, column=10).value = world.zone sheet.cell(row=excel_row, column=11).value = world.base sheet.cell(row=excel_row, column=12).value = world.gas_giants sheet.cell(row=excel_row, column=13).value = world.trade_string else: pass workbook.save(file_name)
# henchgen.py # Henchman generator for the Adventurer Conqueror King System (ACKS). # v1.1, November 10th, 2018. # This is open source code, feel free to use it for any purpose. # Contact the author at [email protected]. #import modules import random import string import os import platform import stellagama import henchgenlib import henchgenchar #Program Body input_loop=True while input_loop==True: print("ACKS Henchman Generator v1.1 by Omer Golan-Joel") market = input ("Please enter market class: 1 through 6 \n") if int(market) in range(1,7): input_loop=False else: print ("Unknown market type") henchoutput = henchgenchar.market_gen (int(market)) output = open(stellagama.savefile("txt"),"w") output.write(henchoutput) output.close()