From 4ead5e928b49e78e2071f7486530359acdab0bcc Mon Sep 17 00:00:00 2001 From: Brian Cully Date: Fri, 19 Feb 2021 15:57:46 -0500 Subject: Off-by-one, add missing error verbiage --- rules.mjs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/rules.mjs b/rules.mjs index a87ba95..c019de8 100644 --- a/rules.mjs +++ b/rules.mjs @@ -66,10 +66,9 @@ class NucleotideSelect { handleClone(evt) { window.r = this.rules - console.debug('clone', this.rules.die.value, this.rules.currentGenome.length) - if (this.rules.die.value < this.rules.currentGenome.length) { + if (this.rules.die.value <= this.rules.currentGenome.length) { this.rules.error.innerHTML = - `TODO: this should have been a selection operation` + `Select the ${this.ordinalFor(this.rules.die.value)} nucleotide.` this.rules.next(new ShowError(this.rules, this)) return } @@ -82,17 +81,21 @@ class NucleotideSelect { i++; if (this.rules.die.value > this.rules.currentGenome.length) { this.rules.error.innerHTML = - `TODO: this should have been a clone operation` + `You need to clone this nucleotide.` this.rules.next(new ShowError(this.rules, this)) return } else if (i != this.rules.die.value) { this.rules.error.innerHTML = - `You selected the ${i}${ordinalSuffix(i)} nucleotide. Please select the ${this.want}${ordinalSuffix(this.want)} one.` + `You selected the ${this.ordinalFor(i)} nucleotide. Please select the ${this.ordinalFor(this.want)} one.` this.rules.next(new ShowError(this.rules, this)) return } this.rules.next(new RollForMutation(this.rules)) } + + ordinalFor(i) { + return `${i}${ordinalSuffix(i)}` + } } class RollForMutation { -- cgit v1.2.3