Conversation
|
Many thanks! |
AlexMooney
left a comment
There was a problem hiding this comment.
Saw the hex formatting and then I just started reading this all. Feel free to ignore this; just throwing out some ideas that will hopefully be useful.
| def number_to_hex(number): | ||
| if number < 10: | ||
| return number | ||
| if number == 10: | ||
| return "A" | ||
| if number == 11: | ||
| return "B" | ||
| if number == 12: | ||
| return "C" | ||
| if number == 13: | ||
| return "D" | ||
| if number == 14: | ||
| return "E" | ||
| if number == 15: | ||
| return "F" | ||
| if number == 16: | ||
| return "G" |
There was a problem hiding this comment.
Unless you really want a 'G' instead of a '10', you can use hex. If you do want the 'G', then it's just 1 if statement on top of hex formatting. Or I guess you could ditch this method and just add a bunch of :X to the f-strings. Edit: or you could call pseudo_hex from stellagama.
| def number_to_hex(number): | |
| if number < 10: | |
| return number | |
| if number == 10: | |
| return "A" | |
| if number == 11: | |
| return "B" | |
| if number == 12: | |
| return "C" | |
| if number == 13: | |
| return "D" | |
| if number == 14: | |
| return "E" | |
| if number == 15: | |
| return "F" | |
| if number == 16: | |
| return "G" | |
| def number_to_hex(number): | |
| return f'{number:X}' |
| printmap[row][column].append(" ") | ||
| printmap[row][column].append(" ") | ||
| printmap[row][column].append(" ") | ||
| printmap[row][column].append("_____") |
There was a problem hiding this comment.
def print_empty_cell(cell)
cell.append(" ")
cell.append(" ")
cell.append(" ")
cell.append("_____")| printmap[row][column].append(" ") | |
| printmap[row][column].append(" ") | |
| printmap[row][column].append(" ") | |
| printmap[row][column].append("_____") | |
| print_empty_cell(printmap[row][column]) |
| printmap[row][column].append(f" {starmap[column][row].starport} {starmap[column][row].gas_giants}") | ||
| printmap[row][column].append(f"{starmap[column][row].naval_base()} {starmap[column][row].worldtype()} ") | ||
| printmap[row][column].append(f"{name_converter(starmap[column][row].name)}") | ||
| printmap[row][column].append(f"{starmap[column][row].scout_base()}{hex_number(column, row, starmap[column][row].worldtype)}") |
There was a problem hiding this comment.
I think I like putting this into World2 more, but here's another way of doing this:
def print_star_cell(cell, star_cell):
cell.append(f" {starmap[column][row].starport} {starmap[column][row].gas_giants}")
cell.append(f"{starmap[column][row].naval_base()} {starmap[column][row].worldtype()} ")
cell.append(f"{name_converter(starmap[column][row].name)}")
cell.append(f"{starmap[column][row].scout_base()}{hex_number(column, row, starmap[column][row].worldtype)}")| printmap[row][column].append(f" {starmap[column][row].starport} {starmap[column][row].gas_giants}") | |
| printmap[row][column].append(f"{starmap[column][row].naval_base()} {starmap[column][row].worldtype()} ") | |
| printmap[row][column].append(f"{name_converter(starmap[column][row].name)}") | |
| printmap[row][column].append(f"{starmap[column][row].scout_base()}{hex_number(column, row, starmap[column][row].worldtype)}") | |
| print_cell(printmap[row][column], starmap[column][row]) |
| return row_string | ||
|
|
||
|
|
||
|
|
| starmap[column][row] = World(" ", " ", " ", " ", "_", " ") | ||
| starmap[column][row] = None |
There was a problem hiding this comment.
If you leave this as in instance of World, then later you could call printmap[row][column] = starmap[column][row].print_lines() and move all the print_map.append logic into this class, and then you don't need the if starmap[column][row] is not None:.
class World2:
def print_lines(self):
return [
f" {self.starport} {self.gas_giants}",
f"{starmap[column][row].naval_base()} {starmap[column][row].worldtype()} "
# etc.
]|
Thanks! |
This changes map generation slightly so that it will be easier to change what information is displayed in the hexes and keep it consistent.