add about button & option to disable solution printing

master
Ondřej Hruška 5 years ago
parent 3590f6aff1
commit e3f56be149
Signed by: MightyPork
GPG Key ID: 2C5FD5035250423D
  1. 21
      script.js
  2. 4
      style.css

@ -630,6 +630,8 @@ class Board {
this.buttons.optFancy = this.addButton(x0, cfgy0, 'Effects:', 'config');
this.buttons.optBlockedEffect = this.addButton(x0, cfgy0+ysp2, 'Dim Blocked:', 'config');
this.buttons.optSloppy = this.addButton(x0, cfgy0+ysp2*2, 'Sloppy Mode:', 'config');
this.buttons.btnAbout = this.addButton(x0, cfgy0+ysp2*-1.5, 'About', 'config');
}
updateSettingsGUI(cfg) {
@ -712,6 +714,7 @@ class SettingsStorage {
attemptTemplates: 50,
svgEffects: false,
dimBlocked: true,
logSolution: false,
};
this.settings = Object.assign({}, this.defaults);
}
@ -1193,7 +1196,7 @@ class Game {
}
}
throw Error("Failed to find available tile");
throw Error("Failed to find available board tile.");
};
place(60, 'gold');
@ -1460,6 +1463,7 @@ class Game {
this.nextMetal = item.nextMetal;
for (let entry of item.orbs) {
this.debug(`Undo orb ${entry.symbol} at ${entry.n}`);
this.board.placeOrbByIndex(entry.n, entry.symbol);
}
@ -1562,32 +1566,45 @@ class Game {
*/
installButtonHandlers() {
this.board.buttons.restart.addEventListener('click', () => {
this.info("New Game with the same seed");
this.newGame(this.rng.seed);
});
this.board.buttons.randomize.addEventListener('click', () => {
this.info("New Game with a random seed");
this.newGame(+new Date);
});
this.board.buttons.btnAbout.addEventListener('click', () => {
let url = 'https://git.ondrovo.com/MightyPork/sigmar';
this.info(`Opening docs page in new tab: ${url}`);
window.open(url);
});
this.board.buttons.undo.addEventListener('click', () => {
if (this.undoStack.length) {
this.undo();
} else {
this.warn("Nothing to undo.");
}
});
this.board.buttons.optFancy.addEventListener('click', () => {
this.info("Toggle effects");
this.setCfg({
svgEffects: !this.cfg.svgEffects,
})
});
this.board.buttons.optBlockedEffect.addEventListener('click', () => {
this.info("Toggle blocked dim");
this.setCfg({
dimBlocked: !this.cfg.dimBlocked,
})
});
this.board.buttons.optSloppy.addEventListener('click', () => {
this.info("Toggle sloppy placement mode");
this.setCfg({
allowTemplateAugmenting: !this.cfg.allowTemplateAugmenting,
})
@ -1686,6 +1703,7 @@ class Game {
`teplate "${board_info.template.name}"` +
(this.cfg.allowTemplateAugmenting ? ` with ${board_info.tilesAdded} extra tiles` : ''));
if (this.cfg.logSolution) {
this.info('Reference solution:\n ' + board_info.solution.reduce((s, entry, i) => {
s += `${entry[0]} ${entry[1]}`;
@ -1702,6 +1720,7 @@ class Game {
}
}
}
}
/* Start */

@ -125,6 +125,10 @@ html, body {
font-size: 26px;
}
.button-text.right {
text-anchor: end;
}
.button-text:hover {
fill: #e3c4a2;
}

Loading…
Cancel
Save