-
-
Notifications
You must be signed in to change notification settings - Fork 126
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
[Feature] Add optional win conditions #17
Comments
Thank you. The correct link is |
@cpojer this might be a dumb question, but what should happen (on the screen) when a user achieves one of the optional win conditions? It seems like an optional win condition shouldn't end the game.. so should it trigger some kind of animation, similar to 'Secret discovered banner'? And (well sorry this is a little more specific, but I'm kinda lost 😭) how should I prevent an optional win condition from ending the game? should I perhaps do something in |
I agree it should be similar to "secret discovered" on the screen. I'm thinking we'd add a new
|
@cpojer Hey thanks for a detailed answer! It was immensely helpful 😄 I would like to ask another question though if you don't mind. So this Maybe having it in map = map.copy({
completed: [...map.completed, pickWinningPlayer(...)]
}) |
We can certainly edit the win conditions to add the player ids! I assume the action response will have a playerID, conditionId, and the condition, so in that case we can add a few lines in |
Sorry, I may be misinterpreting your intent here, but it looks like case 'OptionalWin': {
const { condition, playerId } = actionResponse;
condition.completed?.add(playerId);
return map;
} If so, I should use |
We should never mutate the map state directly, see: MapData guide. const { condition, conditionId, playerId } = actionResponse;
const winConditions = Array.from(map.config.winConditions);
winConditions[conditionId] = {...condition, completed: new Set([...condition.completed, playerId])};
map.copy({
config: map.config.copy({
winConditions
})
}) |
Ah ha! thank you so much for that code snippet! It clarifies things a lot 👍 |
@cpojer Hey, I was reading the issue description again, and was wondering about this part:
I'm not very sure when and why we should reset the completed state? Maybe when the game ends eventually? I'd greatly appreciate it if you could elaborate on this part a little more 🥹 |
Sorry for being unclear. We don't need to reset the state at the end, but the way Athena Crisis works is when you save a map, it resets everything to the initial state so it's ready for games to be played. Secondly, Let me know if you have any more questions, happy to answer them. |
It would be awesome to add a toggle for win conditions that makes them "optional". Together with win conditions being secret, they could add for hidden rewards within a game that do not end the game.
Code & Steps
WinConditions.tsx
for data structures.checkWinCondition
for checking whether a condition was meet. Check its call-sites for handling optional win conditions.WinConditionCard
for rendering.This change likely requires adding an
optional
field to each win condition. The structure of encoded conditions cannot be changed, so we can only add fields to them that are optional. Sorry, there is no codegen for encoded win condition, but it's all local toWinConditions.tsx
. We'll also want to add acompleted
field that is a Set ofPlayerID
s that have completed that win condition. Similar to hidden/secret win conditions, the UI should show a checkbox to mark them as optional. I would suggest that the default win condition (defeat all units or capture HQ) cannot be made optional. Win condition validation needs to be updated to check for that, andvalidateMap
(or maybevalidateWinCondition
or similar) needs to reset the completed state.You can find the win condition panel in the map editor when pressing
c
, or by tapping "Conditions" in the bottom drawer.Funding
The text was updated successfully, but these errors were encountered: