Giter VIP home page Giter VIP logo

Comments (11)

cpojer avatar cpojer commented on August 11, 2024 1

I agree it should be similar to "secret discovered" on the screen. I'm thinking we'd add a new ActionResponse called something like OptionalWinConditionActionResponse (See the Actions guide) that contains the condition/conditionId so it can be used to show the banner.

onGameEnd should definitely not be triggered. I would probably suggest to extend checkGameOverConditions and if an optional condition is hit, return the OptionalWinConditionActionResponse. I assume I'll have to rename some things later to make it fit with this new model, however it should work since that function returns a GameState.

from athena-crisis.

cpojer avatar cpojer commented on August 11, 2024 1

We should never mutate the map state directly, see: MapData guide. applyActionResponse always takes a map data object and returns a new one. In our case since we are editing win conditions it's a bit more finicky. Something like this:

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
  })
})

from athena-crisis.

cpojer avatar cpojer commented on August 11, 2024 1

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. validateMap is what takes care of that. We call dropInactivePlayersFromWinConditions and I would suggest renaming that function to resetWinConditions and setting the completed field to an empty set + keep doing what the function is already doing.

Secondly, validateWinCondition should basically just verify that everything is set to the initial state. So if completed is not empty, that function should return false.

Let me know if you have any more questions, happy to answer them.

from athena-crisis.

Delta456 avatar Delta456 commented on August 11, 2024

Hi, https://github.com/nkzw-tech/athena-crisis-universe/blob/ed772104aeaa8264b2c3d8afd677312e7860b1f1/apollo/lib/checkWinCondition.tsx is not working. It gives 404.

from athena-crisis.

cpojer avatar cpojer commented on August 11, 2024

Thank you. The correct link is checkWinCondition.tsx, I edited the issue description. Apologies for the inconvenience.

from athena-crisis.

sookmax avatar sookmax commented on August 11, 2024

@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 onGameEnd() or should it never trigger 'GameEnd' action in the first place?

from athena-crisis.

sookmax avatar sookmax commented on August 11, 2024

@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 completed state—that tracks players that have completed the optional win condition so far—cannot be a field in a WinCondition, right? since a WinCondition doesn't change once a game starts, but the completed state would, as the game progresses.

Maybe having it in MapData would make more sense? so that we can update completed in checkGameOverConditions() like:

map = map.copy({
  completed: [...map.completed, pickWinningPlayer(...)]
})

from athena-crisis.

cpojer avatar cpojer commented on August 11, 2024

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 applyActionResponse that adds the player id to the completed field on the win condition.

from athena-crisis.

sookmax avatar sookmax commented on August 11, 2024

Sorry, I may be misinterpreting your intent here, but it looks like applyActionRespose() simply calculates and returns a new map, depending on actionResponse.type? And what you're suggesting is to modify the condition contained in actionResponse.condition in place and return the same map as is? so something like:

case 'OptionalWin': {
  const { condition, playerId } = actionResponse;
  condition.completed?.add(playerId);
  return map;
}

If so, I should use Set<PlayerID> instead of PlayerIDSet for the type of condition.completed since add() is going to be used?

from athena-crisis.

sookmax avatar sookmax commented on August 11, 2024

Ah ha! thank you so much for that code snippet! It clarifies things a lot 👍

from athena-crisis.

sookmax avatar sookmax commented on August 11, 2024

@cpojer Hey, I was reading the issue description again, and was wondering about this part:

and validateMap (or maybe validateWinCondition or similar) needs to reset the completed state.

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 🥹

from athena-crisis.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.