-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify map generation #3
base: main
Are you sure you want to change the base?
Conversation
Many thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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]) |
@@ -93,28 +113,52 @@ def base_row(base_row_string): | |||
return row_string | |||
|
|||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
starmap[column][row] = World(" ", " ", " ", " ", "_", " ") | ||
starmap[column][row] = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wonderful! 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.