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

Change the keys for Game.map.describeExits to be actual directions #251

Closed
wants to merge 1 commit into from

Conversation

tiennou
Copy link
Contributor

@tiennou tiennou commented Dec 30, 2023

Brief Description

This makes it at least a bit clearer why the keys are odd numbers.

Checklists

  • Test passed
  • Coding style (indentation, etc)
  • Edits have been made to src/ files not index.d.ts
  • Run npm run dtslint to update index.d.ts

@DiamondMofeng
Copy link
Member

This changes the type of ExitKey from string to number, So I was a little hesitant...
Maybe we need to investigate how player use this in their code

@tiennou
Copy link
Contributor Author

tiennou commented Feb 2, 2025

I think the issue I had is that the forced stringification of keys makes something like the following break:

const exits = Game.map.describeExits("room");
for (const dir in exits) {
  if (dir === EXIT_TOP) { /* … */ } // "Never true" TS error
}

But either way, that code doesn't even fix that issue, so I guess it could be dropped.

@tiennou
Copy link
Contributor Author

tiennou commented Feb 2, 2025

Closing, since it's not as useful as I thought, and could actually be dangerous if you end up trusting the number type you could get back with a strict comparison.

@tiennou tiennou closed this Feb 2, 2025
@tiennou tiennou deleted the fix/exit-key-type branch February 2, 2025 18:16
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.

2 participants