summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2024-06-06 11:18:54 +0200
committerTor Andersson <tor@ccxvii.net>2024-06-06 11:18:54 +0200
commit90091d021db53ee6a06212e7e73c6c6dcfa28087 (patch)
tree1be7d935d995228a148ae4845b2bda9e9784119b
parentde18086709f3e19e7bab269d3fecb74ca47cb4b8 (diff)
downloadfriedrich-90091d021db53ee6a06212e7e73c6c6dcfa28087.tar.gz
turn summary at game end
-rw-r--r--play.js47
-rw-r--r--rules.js3
2 files changed, 39 insertions, 11 deletions
diff --git a/play.js b/play.js
index acdc35f..9f7e449 100644
--- a/play.js
+++ b/play.js
@@ -1,7 +1,7 @@
"use strict"
// vim: set nowrap:
-/* globals data, view, action_button, action_button_with_argument, confirm_action_button, send_action, params, roles
+/* globals data, view, action_button, action_button_with_argument, confirm_action_button, send_action, params, roles, game_log
*/
function toggle_pieces() {
@@ -1275,6 +1275,20 @@ function on_update() {
process_actions()
}
+function turn_summary() {
+ let turn = 0
+ let list = []
+ for (let line of game_log) {
+ if (line.startsWith("#")) {
+ let fate = line.substring(2)
+ if (strokes_of_fate_name.includes(fate) || fate.startsWith("Card of Fate"))
+ list.push("Turn " + turn + ": " + fate)
+ ++turn
+ }
+ }
+ return list.join("\n") + "<div></div>"
+}
+
/* LOG */
const piece_name = [
@@ -1435,6 +1449,15 @@ function sub_tc(_match, p1) {
return `<span class="value deck_${d+1}">${v}</span>${suit_icon[s]}`
}
+const strokes_of_fate_name = [
+ "Poems",
+ "Lord Bute",
+ "Elisabeth",
+ "Sweden",
+ "India",
+ "America",
+]
+
function on_log(text) {
let p = document.createElement("div")
@@ -1468,24 +1491,28 @@ function on_log(text) {
p.className = "move_tip"
text = sub_path(text.substring(1).split(";"))
}
- else if (text.match(/^\$(\d+)/)) {
+ else if (text.startsWith("#")) {
+ p.className = "h fate"
+ text = text.substring(2)
+ }
+ else if (text.startsWith("$")) {
let fx = parseInt(text.substring(1))
if (fx < 48)
text = `<div class="q">${fate_flavor_text[fx]}</div><div></div><div>${fate_effect_text[fx]}</div><div></div>`
else
text = `<div class="q">${fate_flavor_text[fx]}</div><div></div>`
}
- else if (text.match(/^# /)) {
- p.className = "h fate"
- text = text.substring(2)
+ else if (text.startsWith("=")) {
+ p.className = "h " + power_class[text[1]]
+ text = power_name[text[1]]
}
- else if (text.match(/^\.s1/))
+ else if (text === ".s1")
text = the_war_in_the_west_text
- else if (text.match(/^\.s2/))
+ else if (text === ".s2")
text = the_austrian_theater_text
- else if (text.match(/^=\d/)) {
- p.className = "h " + power_class[text[1]]
- text = power_name[text[1]]
+ else if (text === ".summary") {
+ p.className = "q"
+ text = turn_summary()
}
p.innerHTML = text
diff --git a/rules.js b/rules.js
index 087d370..df845cc 100644
--- a/rules.js
+++ b/rules.js
@@ -4547,11 +4547,12 @@ exports.view = function (state, player) {
/* COMMON FRAMEWORK */
function goto_game_over(result, victory) {
+ log("# The End")
game.active = "None"
game.state = "game_over"
game.result = result
game.victory = victory
- log("# Game Over")
+ log(".summary")
log(game.victory)
return true
}