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

InstanceMapStateAuthority #489

Open
Maelstromeous opened this issue Apr 5, 2022 · 0 comments
Open

InstanceMapStateAuthority #489

Maelstromeous opened this issue Apr 5, 2022 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@Maelstromeous
Copy link
Member

Maelstromeous commented Apr 5, 2022

Idea to better manage map state:

Create an InstanceMapStateAuthority which has the following responsibilities:

  • Handles the inititilisation of the map state on alert start (sending the API call to Cenus) rather than in the Start Action
  • Updates the state of the instance per FacilityCapture message and performs the following checks on each message:
    • Is the newFaction value in the FacilityCapture message equal to the current facility owner current "pre-capture" state?
      • If not, grab the map state from Census and check the current owner of each base, compare what they report the owner what we think the map state is
      • If we're out by more than one base, trash the map data and re-sync. Having accurate result data is more important than capture history.
  • Also responsibile for loading alert state upon script start
  • Responsible for ensuring there's no deviance from state with peroidic state scans
  • Will trigger a state scan just before the alert ends to ensure the result will be absolutely correct

Maintains state via holding various maps, which are hydrated from an PS2Alerts API call to /instance/facilities upon script start:

MapStates = Map<InstanceID><FacilityID> =

{
  facilityName: "Foo base",
  owner: 1,
  lastUpdated: 123456789 (unix TS)
}

Methods:

  • resync(instanceId) - Pulls in a fresh copy from the API and trashes all data both in the state and triggers a special API call to nuke the data for that instance, then calculates the result and updates the instance via the PS2Alerts API
  • update(instanceId, newOwner) - Updates the state, but calls first:
  • check(instanceId, oldOwner) - This checks if the oldOwner matches the current state, if it doesn't somethings wrong, which triggers a resync
  • scan(instanceId)- Periodically calls Census and initiates a scan of the continent to detect early any state inconsistencies. It will loop through each facility Census returns and checks our state compared to theirs, callingcheck()` each time. If there's a difference, we re-sync the state.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Todo
Development

No branches or pull requests

1 participant