Skip to content

Commit

Permalink
Do not re-enable games after they end.
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 1cce170c0bfd7cb416ceb787657950794d0df2cc
  • Loading branch information
cpojer committed May 19, 2024
1 parent b62fd7e commit 3b19330
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions hera/GameMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -718,8 +718,12 @@ export default class GameMap extends Component<Props, State> {
) => {
this._update((state) => {
const newState = {
...this.state.behavior?.deactivate?.(),
...resetBehavior(this.props.behavior),
...state.behavior?.deactivate?.(),
...resetBehavior(
state.lastActionResponse?.type === 'GameEnd'
? NullBehavior
: this.props.behavior,
),
};

if (
Expand Down Expand Up @@ -856,7 +860,13 @@ export default class GameMap extends Component<Props, State> {
action: Action,
): [Promise<GameActionResponse>, MapData, ActionResponse] => {
const { onAction } = this.props;
const { map, preventRemoteActions, vision } = state;
const { lastActionResponse, map, preventRemoteActions, vision } = state;
if (lastActionResponse?.type === 'GameEnd') {
throw new Error(
`Action: Cannot issue actions for a game that has ended.\nAction: '${JSON.stringify(action)}'`,
);
}

if (preventRemoteActions) {
const { currentViewer } = state;
const player = map.getCurrentPlayer();
Expand Down

0 comments on commit 3b19330

Please sign in to comment.