From ef78c9bf5a40b8be033a4479a60261da743feeec Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Thu, 4 Jan 2024 16:49:51 +0100 Subject: Break target lines on "or" as well as ",". --- play.js | 11 ++++++++++- tools/gendata.js | 7 ++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/play.js b/play.js index c853573..9204cef 100644 --- a/play.js +++ b/play.js @@ -154,6 +154,15 @@ function create_formation_slot(id, top) { return e } +function nbsp_target(target) { + return target + .split(", ") + .map(x=>x.replaceAll(" ", "\xa0")) + .join(", ") + .replaceAll("\xa0or\xa0", " or ") + .replaceAll("\xa0OR\xa0", " OR ") +} + function create_formation_card(id) { let card = data.cards[id] let e = create_div("card formation " + wing_name[card.wing]) @@ -211,7 +220,7 @@ function create_formation_card(id) { register_action(et, "a" + ix, id, "n" + ix) append_div(ee, "action_requirement", a.requirement) if (a.target) - append_div(ee, "action_target", a.target.split(", ").map(x=>x.replaceAll(" ", "\xa0")).join(", ")) + append_div(ee, "action_target", nbsp_target(a.target)) else append_div(ee, "action_target", "") if (a.effect) { diff --git a/tools/gendata.js b/tools/gendata.js index a00a3eb..bc7c996 100644 --- a/tools/gendata.js +++ b/tools/gendata.js @@ -98,7 +98,12 @@ function flush_scenario_html() { } function nbsp_target(target) { - return target.split(", ").map(x=>x.replaceAll(" ", "\xa0")).join(", ") + return target + .split(", ") + .map(x=>x.replaceAll(" ", "\xa0")) + .join(", ") + .replaceAll("\xa0or\xa0", " or ") + .replaceAll("\xa0OR\xa0", " OR ") } for (let c of card_records) { -- cgit v1.2.3