refactor: use separate seed for reroll of vegetables

This commit is contained in:
2025-11-05 09:11:59 +01:00
parent 4dca72c57d
commit 8b3b026aea
3 changed files with 7 additions and 6 deletions
+1
View File
@@ -25,6 +25,7 @@ export default [
"max-statements": ["warn", 50], "max-statements": ["warn", 50],
"max-params": ["warn", 5], "max-params": ["warn", 5],
"max-lines": "off", "max-lines": "off",
"init-declarations": "off",
}, },
}, },
{ {
+1 -1
View File
@@ -75,7 +75,7 @@
<td><label for="candidates">Candidates:</label></td> <td><label for="candidates">Candidates:</label></td>
<td><textarea v-model="config.candidates" id="candidates" rows="8"></textarea></td> <td><textarea v-model="config.candidates" id="candidates" rows="8"></textarea></td>
<td> <td>
<button @click="newVegetables"><i icon="rotate-ccw"></i></button> <button @click="newVegetables"><i icon="dices"></i></button>
<br /> <br />
<span v-if="candidates.length <= 2" title="not enough candidates"> <span v-if="candidates.length <= 2" title="not enough candidates">
<i icon="triangle-alert"></i> <i icon="users-round"></i> {{candidates.length}} <i icon="triangle-alert"></i> <i icon="users-round"></i> {{candidates.length}}
+3 -3
View File
@@ -103,6 +103,7 @@ class TableGenerator {
return scores; return scores;
} }
// eslint-disable-next-line class-methods-use-this
mixKey(index1, index2) { mixKey(index1, index2) {
return Math.min(index1, index2) * 1000 + Math.max(index1, index2); return Math.min(index1, index2) * 1000 + Math.max(index1, index2);
} }
@@ -312,7 +313,7 @@ const app = createApp({
}, },
newVegetables() { newVegetables() {
this.config.candidates = utils this.config.candidates = utils
.shuffleSeeded(Object.keys(VEGETABLES), this.config.seed) .shuffleSeeded(Object.keys(VEGETABLES), utils.randomSeed())
.map((key) => `${key} ${VEGETABLES[key]}`) .map((key) => `${key} ${VEGETABLES[key]}`)
.slice(0, 6) .slice(0, 6)
.join("\n"); .join("\n");
@@ -374,8 +375,7 @@ const app = createApp({
try { try {
await navigator.clipboard.writeText(csvTable); await navigator.clipboard.writeText(csvTable);
this.copyTableOverride = "Table Copied"; this.copyTableOverride = "Table Copied";
} catch (error) { } catch {
console.error(error.message);
this.copyTableOverride = "Error"; this.copyTableOverride = "Error";
} }
setTimeout(() => { setTimeout(() => {