-
-
Notifications
You must be signed in to change notification settings - Fork 127
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
[Attempt] Show Game Player Statistics during Gameplay #23
Conversation
Hello @sookmax 👋 Thank you for contributing to Athena Crisis. I like the solution using statistics, however I was thinking we don't need to cache any of this information at all and we can simply calculate it when showing the info by expanding the menu. Would you mind reverting the changes to the stats object and simply calculating it on-demand? Also note that There is no limit on the size of this panel when it is expanded. I almost think it would be best if we put this info on the next line since the win condition stuff is also shown in that line and it could be too much with many conditions etc. What do you think? |
@cpojer thanks for the quick feedbacks!
Ah I see. Since we have access to both
Got it. I was primarily working in the map editor UI in the docs, and it seemed reasonable to show the counts of existing buildings and units on the map when I hit the Oh and I also wanted to ask if there's any other place in the docs where I can see the
Sounds about right to me too! So just to make sure we're on the same page, you want the new info line to be placed below the funds+win conditions line but above the charge gauge line right? I'll work on your feedbacks and get back to you, thanks 😁 |
I've pushed 3f5a7ff containing the followings:
Side notesWhile I was re-organizing the dom structures for the stats, I realized the div with the ![]() So I've added a resize observer that observes this absolutely positioned div with Screen.Recording.2024-05-19.at.5.54.05.PM.movBut I'm not entirely sure if it's the best way to solve the issue, so let me know what you think! |
hera/ui/PlayerCard.tsx
Outdated
? Math.max( | ||
player.stats.createdUnits - player.stats.lostUnits, | ||
0, | ||
) |
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.
Sorry, maybe I wasn't explaining it well earlier. We shouldn't use stats at all, they are just for internal tracking.
For units and buildings we should use the map
object and filter map.units
and map.buildings
for map.matchesPlayer(unit, player)
.
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.
Sorry my bad! I should've looked more into MapData
before jumping into reading Player
😅
Another thing I've realized is that the initial stats for the map editor (when play-testing) now correctly reflect the number of units and buildings placed on the board!
hera/ui/PlayerCard.tsx
Outdated
const icon = | ||
key === 'fundsPerTurn' | ||
? Coin | ||
: key === 'netUnits' | ||
? HumanHandsdown | ||
: Buildings; |
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.
Let's make the icon the third argument instead of checking here. Also, mind calling it just units
and buildings
instead of netUnits
etc.?
I left a few more comments. If you could do one more pass on it, then I can take a look at the sizing issue. |
@sookmax Thank you so much for the contribution. The funds were sent to you. Please consider contributing again! |
@cpojer Thanks for guiding me through this half-baked PR! I feel like I've only done half the work 😅. And I would love to contribute again! A quick question if you don't mind: |
@sookmax that's ok, it's a big codebase and it was fun to collaborate with you! Re Storybook, I'm not too sure to be honest. I got the docs setup nicely now so that game components can be rendered inline in the docs. What exactly would you be interested in adding? |
I think Storybook is great for developing / maintaining / testing UI components in isolation. It would also be much easier for external contributors to dive in and fix a specific issue in a specific UI component quickly. And if set up correctly, it'd be much easier to see different states of a particular UI in Storybook. For example, while I was working on this PR, I wanted to render a win condition (any) on the player card so I could see how the new stats UI would fit between the funds and the win condition—being ignorant of how to trigger one of the win condition, I ended up temporarily enabling a condition (and commenting out the others) to see how it presents on the screen. If setting up Storybook in the project is not too painful (given that the project uses Vite, I think there shouldn't be much frictions since Storybook supports Vite-based projects relatively well) I highly think it'd be worthwhile to have it. And once set up properly, writing stories can be as incremental/gradual as you want it to be. Actually I enjoy writing stories on UI components, so I could write them while learning how all these UI pieces work together and what data they need, etc. |
I'd definitely be curious to explore what that might look like. In my experience Storybook can be kinda heavy and bring in a whole toolchain, but if it works with Vite it might be worth a try! |
Haha hey that was fast 🤯. Glad you're interested!
Yeah I mean it's a mess actually.. I happened to have contributed to Storybook 7 a little last year, and there were just too many things broken (+tech debts). But as a user (especially Vite-binding) with pretty basic use cases in mind, it's not too bad. I have some mediocre examples deployed on Vercel
I was going to look into #17 next, but I could also look into Storybook setup first! |
#17 is definitely more important, but it's also a big task. Up to you! |
Co-authored-by: cpojer <[email protected]> GitOrigin-RevId: 5e3af9a90b7df7438f6efb9520e4f3b609bc8f88
Hello @cpojer! First of all, I would like to thank you for open-sourcing this amazing project 🤗
This is my attempt at #2.
I've decided to store
fundsPerTurn
inPlayer.stats.fundsPerTurn
, though I'm not entirely sure that is the right place for it. And I've also decided to show the stats only whenCurrentGameCard
is expanded since there aren't enough spaces to fit the stats nicely when the card is collapsed.Lastly, apart from the actual implementation, I added
inset={100}
to<MapEditor>
indocs/content/examples/map-editor.tsx
so that I can actually see theCurrentGameCard
(it seems it was hidden under the docs header when inset = 0)Screenshots