From 6cf3cfd3ea9c031d5c2d4980f61e111b95198d49 Mon Sep 17 00:00:00 2001 From: Frostbide <129122542+Frostbide@users.noreply.github.com> Date: Thu, 26 Jun 2025 01:02:31 -0700 Subject: [PATCH] Fix error on cell toggle before step --- src/commands/slash/conwaysgameoflife.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/commands/slash/conwaysgameoflife.js b/src/commands/slash/conwaysgameoflife.js index c02b613..5d1dc2e 100644 --- a/src/commands/slash/conwaysgameoflife.js +++ b/src/commands/slash/conwaysgameoflife.js @@ -229,6 +229,8 @@ const moduleFuncs = { constructor(size) { this.size = size; this.grid = this.createGrid(); + this.history = [this.cloneGrid(this.grid)]; + this.currentStep = 0; } createGrid() { @@ -286,11 +288,6 @@ const moduleFuncs = { } step(n = 1) { - if (!this.history) { - this.history = [this.cloneGrid(this.grid)]; - this.currentStep = 0; - } - if (n === 0) return; if (n > 0) { @@ -341,7 +338,7 @@ module.exports = { ...moduleFuncs, data: new SlashCommandBuilder() .setName('gameoflife') - .setDescription("Simulates conway's game of life (In development)") + .setDescription("Simulates conway's game of life") .addIntegerOption((option) => option .setName('size')