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

Issues/234 player item interaction #252

Merged
merged 23 commits into from
Aug 4, 2023

Conversation

jessesnyder
Copy link
Contributor

@jessesnyder jessesnyder commented Aug 2, 2023

Description

Features added here

  • Items not defined as crossable cannot be crossed over by players
  • Details (the name, for now) of the item on the same square as the current player are displayed to the player
  • Available transitions on the current square are displayed (crudely, for now)

Non-public changes

  • Use a different delimiter between actor and target transition elements, so allow using friendly strings in item/transition config
  • Don't persist position on Items on the clients side. Instead use the GridItems wrapper as the single point of truth on grid position for items (avoids possibility of Item.position and position registered in position map conflicting)
  • Remove a bunch of dead variables from JS code

Demo

https://app.screencast.com/wrJQmlLXDFutN

@jessesnyder jessesnyder force-pushed the issues/234-player-item-interaction branch from 223e02b to 4b88145 Compare August 3, 2023 18:22
@jessesnyder jessesnyder force-pushed the issues/234-player-item-interaction branch from 6deb0a1 to 65a06f3 Compare August 3, 2023 20:43
@jessesnyder jessesnyder marked this pull request as ready for review August 4, 2023 00:15
@jessesnyder jessesnyder requested a review from alecpm August 4, 2023 00:16
@jessesnyder jessesnyder changed the title WIP: Issues/234 player item interaction Issues/234 player item interaction Aug 4, 2023
Copy link
Contributor

@alecpm alecpm left a comment

Choose a reason for hiding this comment

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

Love this! The separation of the grid items into its own class that manages the position mapping is a nice improvement. I think there are a couple of small inconsistencies in how you're using gridItems.remove(), but otherwise this looks great.

(state) => settings.item_config[state]
);

return `✋${aStartItem.name} + ${tStartItem.name} = ✋${aEndItem.name} + ${tEndItem.name}`;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think I'd rather see a ➡️ or a than a = here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Natalia's mockup used the =, so I went with that, but I also prefer the arrow. I'm going to go with that. I think there's likely to be a lot more change in this presentation anyway.

$square.html(inspectedItem.name);
}

if (_.isUndefined(transition)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

player.getTransition() should return null not undefined. I think it would be more semantically appropriate if gridItems.atPosition(...) returned null as well.

}

remove(item) {
this._itemsByPosition.delete(JSON.stringify(item.position));
Copy link
Contributor

@alecpm alecpm Aug 4, 2023

Choose a reason for hiding this comment

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

It seems like we're not setting position on Item anymore, won't that be a problem here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in related PR

@@ -871,8 +795,7 @@ function bindGameKeys(socket) {
} else if (!player_item && item_at_pos && item_at_pos.portable) {
// If there's a portable item here and we don't something in hand, pick it up.
msg_type = "item_pick_up";
item_at_pos.position = null;
delete itemPositions[position[0] + '_' + position[1]];
gridItems.remove(position);
Copy link
Contributor

Choose a reason for hiding this comment

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

gridItems.remove() seems to take an item, not a position, though perhaps this would be better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like I passed an Item in one case and a position in another. I agree position is better.


atPosition(position) {
const key = JSON.stringify(position);
return this._itemsByPosition.get(key);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should explicitly return a null (e.g. || null) if nothing is found, if only because undefined seems like kind of a weird value for this to return.

@alecpm alecpm mentioned this pull request Aug 4, 2023
@jessesnyder jessesnyder merged commit e5c1d7d into one-hour-one-life Aug 4, 2023
1 of 2 checks passed
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