summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rules.js6
-rw-r--r--rules.ts7
2 files changed, 7 insertions, 6 deletions
diff --git a/rules.js b/rules.js
index e068bbf..9e8cd52 100644
--- a/rules.js
+++ b/rules.js
@@ -79,10 +79,10 @@ function gen_spend_hero_points() {
}
}
function action(state, player, action, arg) {
- if (action !== 'undo' && state.state !== 'choose_card') {
- state.undo = push_undo();
- }
game = state;
+ if (action !== 'undo' && game.state !== 'choose_card') {
+ push_undo();
+ }
let S = states[game.state];
if (action in S)
S[action](arg, player);
diff --git a/rules.ts b/rules.ts
index 1939d74..1cc024a 100644
--- a/rules.ts
+++ b/rules.ts
@@ -172,11 +172,12 @@ export function action(
action: string,
arg: unknown
) {
- if (action !== 'undo' && state.state !== 'choose_card') {
- state.undo = push_undo();
+ game = state;
+
+ if (action !== 'undo' && game.state !== 'choose_card') {
+ push_undo();
}
- game = state;
let S = states[game.state];
if (action in S) S[action](arg, player);
else if (action === 'undo' && game.undo && game.undo.length > 0) pop_undo();