summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--play.html13
-rw-r--r--play.js24
-rw-r--r--rules.js29
-rw-r--r--tools/gendata.js8
4 files changed, 56 insertions, 18 deletions
diff --git a/play.html b/play.html
index 9ef7a26..323d4e2 100644
--- a/play.html
+++ b/play.html
@@ -34,7 +34,7 @@
padding: 2px 8px;
}
-#log .t {
+#log .p1, #log .p2 {
text-align: right;
background-color: wheat;
margin: 8px 0;
@@ -44,8 +44,15 @@
#log div.i1 { padding-left: 32px; text-indent: -12px; }
#log div.i2 { padding-left: 44px; text-indent: -12px; }
-#log .i {
+#log .lore {
font-style: italic;
+ text-indent: 0;
+ padding-left: 8px;
+}
+
+#log .rule {
+ text-indent: 0;
+ padding-left: 8px;
}
#log .n { padding: 0 3px }
@@ -370,7 +377,7 @@ body.shift .number { display: block; }
<div id="log"></div>
</aside>
-<main data-min-zoom="0.5" data-max-zoom="1.125" data-map-xheight="500">
+<main data-min-zoom="0.5" data-max-zoom="1.125" data-map-height="500">
<div class="table">
diff --git a/play.js b/play.js
index c4e7a51..71ef20a 100644
--- a/play.js
+++ b/play.js
@@ -210,10 +210,10 @@ function create_formation_card(id) {
et = append_div(ee, "action_type", a.type)
register_action(et, "a" + ix, id, "n" + ix)
append_div(ee, "action_requirement", a.requirement)
- if (Array.isArray(a.target))
- append_div(ee, "action_target", a.target.map(t=>data.cards[t].name).join(", "))
+ if (a.target)
+ append_div(ee, "action_target", a.target.split(", ").map(x=>x.replaceAll(" ", "\xa0")).join(", "))
else
- append_div(ee, "action_target", a.target)
+ append_div(ee, "action_target", "")
if (a.effect) {
if (a.short)
append_div(ee, "action_effect short", a.effect)
@@ -516,17 +516,21 @@ function on_log(text) {
text = text.substring(4)
p.className = "h2"
}
- else if (text.match(/^\.t0/)) {
+ else if (text.match(/^\.p1/)) {
text = data.scenarios[view.scenario].players[0].name
- p.className = "t"
+ p.className = "p1"
}
- else if (text.match(/^\.t1/)) {
+ else if (text.match(/^\.p2/)) {
text = data.scenarios[view.scenario].players[1].name
- p.className = "t"
+ p.className = "p2"
}
- else if (text.match(/^\.i /)) {
- text = text.substring(3)
- p.className = "i"
+ else if (text.match(/^\.rule /)) {
+ text = text.substring(6)
+ p.className = "rule"
+ }
+ else if (text.match(/^\.lore /)) {
+ text = text.substring(6)
+ p.className = "lore"
}
else if (text.match(/^>>/)) {
text = text.substring(2)
diff --git a/rules.js b/rules.js
index b8dc0e1..9f1a92b 100644
--- a/rules.js
+++ b/rules.js
@@ -173,6 +173,12 @@ exports.resign = function (state, player) {
}
function goto_game_over(result, victory) {
+ if (result === P1)
+ victory = player_name(0) + " won:\n" + victory
+ else if (result === P2)
+ victory = player_name(1) + " won:\n" + victory
+ else
+ victory = result + ":\n" + victory
game.state = "game_over"
game.active = "None"
game.result = result
@@ -477,13 +483,13 @@ exports.setup = function (seed, scenario, options) {
if (info.lore_text) {
for (let line of info.lore_text.split("<p>"))
- log(".i " + line)
+ log(".lore " + line)
log("")
}
if (info.rule_text) {
for (let line of info.rule_text.split("<p>"))
- log(line)
+ log(".rule " + line)
log("")
}
@@ -1468,6 +1474,7 @@ function goto_roll_phase() {
}
states.skip_action = {
+ inactive: "roll",
prompt() {
view.prompt = "Skipped action phase; roll the dice in your pool."
@@ -1489,6 +1496,7 @@ states.skip_action = {
}
states.roll = {
+ inactive: "roll",
prompt() {
view.prompt = "Roll the dice in your pool."
view.actions.roll = 1
@@ -1533,6 +1541,7 @@ function gen_place_dice_select_card() {
}
states.place = {
+ inactive: "place dice",
prompt() {
view.prompt = "Place dice on your formations."
gen_place_dice_select_card()
@@ -1549,6 +1558,7 @@ states.place = {
}
states.place_on_card = {
+ inactive: "place dice",
prompt() {
let card = data.cards[game.selected]
view.prompt = "Place dice on " + card.name + "."
@@ -2057,7 +2067,7 @@ function count_cards_remaining_from_wing(w) {
function goto_start_turn() {
let p = player_index()
- log(".t" + p)
+ log(".p" + (p + 1))
if (check_impossible_to_attack_victory())
return
@@ -2137,6 +2147,7 @@ function end_action_phase() {
}
states.action = {
+ inactive: "take an action",
prompt() {
view.prompt = "Take an action."
view.actions.roll = 1
@@ -2300,6 +2311,7 @@ function can_shift_any_cavalry() {
}
states.shift_from = {
+ inactive: "shift sticks",
prompt() {
view.prompt = "Shift sticks from one Formation to another."
let p = player_index()
@@ -2320,6 +2332,7 @@ states.shift_from = {
}
states.shift_to = {
+ inactive: "shift sticks",
prompt() {
view.prompt = "Shift sticks from " + card_name(game.selected) + "."
let p = player_index()
@@ -2556,6 +2569,7 @@ function find_all_targets_of_command(c, a) {
}
states.bombard = {
+ inactive: "bombard",
prompt() {
view.prompt = "Bombard."
view.actions.bombard = 1
@@ -2586,6 +2600,7 @@ function goto_attack_choose_target() {
}
states.attack_choose_target = {
+ inactive: "attack",
prompt() {
view.prompt = "Choose the target of your attack."
let a = current_action()
@@ -2784,6 +2799,7 @@ function update_attack2() {
}
states.attack = {
+ inactive: "attack",
prompt() {
view.prompt = "Attack " + card_name(game.target) + "."
gen_action_card(game.target)
@@ -2950,6 +2966,7 @@ function goto_command() {
}
states.command = {
+ inactive: "command",
prompt() {
let list = find_all_targets_of_command(game.selected, current_action())
view.prompt = "Bring " + list.map(c => card_name(c)).join(" and ") + " out of reserve."
@@ -3162,6 +3179,7 @@ function take_wild_die_if_needed_for_reaction(c, ix) {
}
states.react = {
+ inactive: "react",
prompt() {
view.prompt = card_name(game.selected) + " attacks " + card_name(game.target) + "!"
let voluntary = true
@@ -3265,6 +3283,7 @@ function goto_screen(c, a) {
}
states.screen = {
+ inactive: "screen",
prompt() {
view.prompt = "Screen attack from " + card_name(game.selected) + "."
view.actions.screen = 1
@@ -3345,6 +3364,7 @@ states.s29_meade = {
}
states.absorb = {
+ inactive: "absorb",
prompt() {
view.prompt = "Absorb attack from " + card_name(game.selected) + "."
view.actions.absorb = 1
@@ -3413,6 +3433,7 @@ function goto_counterattack(c, a) {
}
states.counterattack = {
+ inactive: "counterattack",
prompt() {
view.prompt = "Counterattack " + card_name(game.selected) + "."
view.actions.counterattack = 1
@@ -3631,6 +3652,7 @@ function resume_routing() {
}
states.routing = {
+ inactive: "remove routing and pursuing cards",
prompt() {
view.prompt = "Routing: Remove routing and pursuing cards from play!"
for (let p = 0; p <= 1; ++p) {
@@ -3762,6 +3784,7 @@ function bring_out_of_reserve(c) {
}
states.reserve = {
+ inactive: "enter reserves",
prompt() {
view.prompt = "Enter reserves!"
for (let p = 0; p <= 1; ++p)
diff --git a/tools/gendata.js b/tools/gendata.js
index 5e4891b..548d9b0 100644
--- a/tools/gendata.js
+++ b/tools/gendata.js
@@ -62,6 +62,10 @@ function flush_scenario_html() {
result = []
}
+function nbsp_target(target) {
+ return target.split(", ").map(x=>x.replaceAll(" ", "\xa0")).join(", ")
+}
+
for (let c of card_records) {
if (!c.number) {
allcards.push(`</div><h1>${c.scenario}</h1><div class="list">`)
@@ -202,7 +206,7 @@ for (let c of card_records) {
else
html.push(`<div class="action_type">${c.action1_type}</div>`)
html.push(`<div class="action_requirement">${c.action1_req}</div>`)
- html.push(`<div class="action_target">${c.action1_target}</div>`)
+ html.push(`<div class="action_target">${nbsp_target(c.action1_target)}</div>`)
if (c.action1_effect) {
if (c.rule_text_1 || squeeze)
html.push(`<div class="action_effect short">${c.action1_effect}</div>`)
@@ -226,7 +230,7 @@ for (let c of card_records) {
else
html.push(`<div class="action_type">${c.action2_type}</div>`)
html.push(`<div class="action_requirement">${c.action2_req}</div>`)
- html.push(`<div class="action_target">${c.action2_target}</div>`)
+ html.push(`<div class="action_target">${nbsp_target(c.action2_target)}</div>`)
if (c.action2_effect) {
if (c.rule_text_2 || squeeze)
html.push(`<div class="action_effect short">${c.action2_effect}</div>`)