mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Reset game state on new turn.
This may not be the way to do this long term, but it is how the old map works so it's at least not a regression. It might be better to generate events for the between-turn changes in state instead. https://github.com/dcs-liberation/dcs_liberation/issues/2039
This commit is contained in:
@@ -3,7 +3,10 @@ import { gameLoaded, gameUnloaded } from "./actions";
|
||||
import backend from "./backend";
|
||||
import Game from "./game";
|
||||
|
||||
export default function reloadGameState(dispatch: AppDispatch) {
|
||||
export default function reloadGameState(
|
||||
dispatch: AppDispatch,
|
||||
ignoreRecenter: boolean = false
|
||||
) {
|
||||
backend
|
||||
.get("/game")
|
||||
.catch((error) => console.log(`Error fetching game state: ${error}`))
|
||||
@@ -12,6 +15,10 @@ export default function reloadGameState(dispatch: AppDispatch) {
|
||||
dispatch(gameUnloaded());
|
||||
return;
|
||||
}
|
||||
dispatch(gameLoaded(response.data as Game));
|
||||
const game = response.data as Game;
|
||||
if (ignoreRecenter) {
|
||||
game.map_center = null;
|
||||
}
|
||||
dispatch(gameLoaded(game));
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user