Exemple #1
0
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
Exemple #2
0
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()
Exemple #3
0
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)
Exemple #4
0
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)