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

feat: add fog of war feature to map #1798

Closed
wants to merge 8 commits into from

Conversation

alecejones
Copy link
Contributor

@alecejones alecejones commented Aug 28, 2023

Closes #1237

@alecejones alecejones force-pushed the Feat/Fog branch 7 times, most recently from b1aaad2 to a2bf968 Compare August 29, 2023 07:44
@gereon77
Copy link
Collaborator

gereon77 commented Aug 29, 2023

@alecejones-noodoe I see your branch has been diverged. It is based on my commit fa55054 but the latest commit on master is the merge of the PR: fd8a481. Can you please rebase your branch onto master? Otherwise I am not able to pull it into my fork for testing...

@gereon77
Copy link
Collaborator

gereon77 commented Aug 29, 2023

Finally I was able to pull your branch as it is. So many thx for your efforts so far!

Here is a list of things that need to be done before I can merge this.

  • Fog of War is only implemented on client-side and therefore allows to reveal units of all other houses. See bottom for further details about this issue.
  • "Orders were revealed logs" reveal the complete board. Please filter out this log type in gameLogManager.serializeToClient as long game has not ended or cancelled.
  • Players don't see the units of their vassals and are not able to place units for their vassals

The biggest hurdle of this feature: Create different views for each player server-side

Currently tracing the ws messages reveal the complete game state tree, including units in fogged regions. And even worse: You can use browsers dev tools to create a breakpoint in EntireGame.deserializeFromServer(), set fogOfWar to false and then you will see the full map. Of course this should behave like the faceless flag, which won't reveal the real names if you set it to true.
To achieve the same for fog of war you have to change region.serializeToClients() and only send units, power tokens, garrisons and loyalty tokens if the region is not fogged to the player. This will then result in an "invisible" victory track as players then really don't know positions of others and it's not just visually hidden. Therefore we should think about revealing the current victory track at the begin of each round. Maybe it's easier to create an own FogOfWar houses list view for this, similar to the ReplayComponent, wich as well shows static numbers instead of examining the current board state.

I hope I haven't demotivated you to continue on this. But you have picked a very tricky feature to implement...

@alecejones
Copy link
Contributor Author

alecejones commented Aug 30, 2023

Few notes:

  1. Right now I'm not going to write a bunch of code to filter the game state server side. I don't understand the game state tree well enough to do this without causing unintended side effects that could break the game. If that's something you'd like to assist me with, we can talk about that. I'm happy to commit this to a different branch and make it a work in progress.

  2. I just added a fix to filter out 'orders revealed' but other logs are still there. I tried implementing new logs that filter out region data mentions but there were some type issues. I was waiting to discuss approaches with you for dealing with logging problems.

  3. I have set Object.freeze on the fogOfWar value in the Map component to make it immutable. I'm not sure if this helps or developer tools can get around it, you can try this again. I think this would at least reduce the opportunity to toggle fogOfWar in the Map component to the initial data fetch.

  4. Vassals are now included in visibility calculations.

If you'd like to help me alter server-side code in a way that doesn't break the game, then we can fix these issues together. Otherwise, you're talking about situations where players will be man-in-the-middle hacking server side data themselves in order to acquire visibility. I think most players either don't know how to do this or don't have any desire to cheat if they do. For the rest of the hackers, just don't allow it for tournaments or public games until it's ready.

I'd say mark this feature as a beta version and let it be usable in some limited state until more permanent fixes arrive. People should see how it affects strategy and offer suggestions for improvement.

@alecejones alecejones closed this Aug 31, 2023
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.

Add custom game option: Fog of war
2 participants