Skip to content
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

Re-implement the 1/3 hex asciimap reader #49

Merged
merged 2 commits into from
Apr 1, 2020
Merged

Conversation

youngmit
Copy link
Contributor

@youngmit youngmit commented Apr 1, 2020

The old one was not interpreting the leading hyphens properly. The new
ones is a more reliable inversion of the writing process, and handles
spacing between elements better.

The old one was not interpreting the leading hyphens properly. The new
ones is a more reliable inversion of the writing process, and handles
spacing between elements better.
@youngmit youngmit requested a review from ntouran April 1, 2020 21:14
Copy link
Member

@ntouran ntouran left a comment

Choose a reason for hiding this comment

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

Approved with comments.

@@ -69,6 +70,8 @@ def readMap(self, text):
for col, char in enumerate(line.split()):
i, j = self._getIndices(base, col)
self.lattice[i, j] = char

self.lattice = {k: v for k, v in self.lattice.items() if v != "-"}
Copy link
Member

Choose a reason for hiding this comment

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

we should probably constantize this with

PLACEHOLDER = "-" and then refer to PLACEHOLDER here.

grid = {}
# The length of the largest string contents. Useful for spacing everything out
# nicely
maxSize = len(str(next(iter(self.lattice.values()))))
Copy link
Member

Choose a reason for hiding this comment

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

groan is that really what we have to do to get the length of the first value!? Python 3 whyyyy

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I had a private little hissy of my own when I found out that the various dict view classes arent themselves iterators. It feels like the iter() call should be unnecessary.

# of our otherwise infinite loop
break
if contents is None:
contents = '-'
Copy link
Member

Choose a reason for hiding this comment

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

PLACEHOLDER

@youngmit youngmit merged commit 23a9332 into master Apr 1, 2020
@youngmit youngmit deleted the mty/asciiMapHex branch April 10, 2020 16:18
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.

None yet

2 participants