Skip to content

Conversation

@julian94
Copy link

This changes map generation slightly so that it will be easier to change what information is displayed in the hexes and keep it consistent.

@Golan2072
Copy link
Owner

Many thanks!

Copy link

@AlexMooney AlexMooney left a 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.

Comment on lines +7 to +23
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"
Copy link

@AlexMooney AlexMooney Feb 26, 2021

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.

Suggested change
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}'

Comment on lines +134 to +137
printmap[row][column].append(" ")
printmap[row][column].append(" ")
printmap[row][column].append(" ")
printmap[row][column].append("_____")

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("_____")
Suggested change
printmap[row][column].append(" ")
printmap[row][column].append(" ")
printmap[row][column].append(" ")
printmap[row][column].append("_____")
print_empty_cell(printmap[row][column])

Comment on lines +129 to +132
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)}")

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)}")
Suggested change
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



Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Comment on lines -66 to +86
starmap[column][row] = World(" ", " ", " ", " ", "_", " ")
starmap[column][row] = None

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.
        ]

@Golan2072
Copy link
Owner

Thanks!

Copy link
Owner

@Golan2072 Golan2072 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonderful! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants