summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Cully <bjc@kublai.com>2021-02-19 15:57:46 -0500
committerBrian Cully <bjc@kublai.com>2021-02-19 15:57:46 -0500
commit4ead5e928b49e78e2071f7486530359acdab0bcc (patch)
tree3a269dab5041d61d98d8e484c3d35823fb4a8f7e
parentdcbd196fd3c54b85a42b80e5e5e8d1771bbf224f (diff)
downloadmolsim2-4ead5e928b49e78e2071f7486530359acdab0bcc.tar.gz
molsim2-4ead5e928b49e78e2071f7486530359acdab0bcc.zip
Off-by-one, add missing error verbiage
-rw-r--r--rules.mjs13
1 files 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 <em>clone</em> 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}<sup>${ordinalSuffix(i)}</sup> nucleotide. Please select the ${this.want}<sup>${ordinalSuffix(this.want)}</sup> 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}<sup>${ordinalSuffix(i)}</sup>`
+ }
}
class RollForMutation {