aboutsummaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
Diffstat (limited to 'web')
-rw-r--r--web/pw-visualizer/src/index.ts12
1 files changed, 11 insertions, 1 deletions
diff --git a/web/pw-visualizer/src/index.ts b/web/pw-visualizer/src/index.ts
index f97bd2b..74b2319 100644
--- a/web/pw-visualizer/src/index.ts
+++ b/web/pw-visualizer/src/index.ts
@@ -51,6 +51,16 @@ export function set_loading(loading: boolean) {
}
}
+function clamp(min: number, max: number, value: number): number {
+ if (value < min) {
+ return min;
+ }
+ if (value > max) {
+ return max;
+ }
+ return value;
+}
+
const ELEMENTS: any = {};
var CANVAS: any;
var RESOLUTION: any;
@@ -561,7 +571,7 @@ export class GameInstance {
}
updateTurn(turn: number) {
- this.frame = Math.max(0, turn);
+ this.frame = clamp(0, this.turn_count-1, turn);
this.game.update_turn(this.frame);
this._update_state();
this.updateTurnCounters();