diff options
Diffstat (limited to 'play.js')
-rw-r--r-- | play.js | 76 |
1 files changed, 76 insertions, 0 deletions
@@ -3,6 +3,23 @@ // TODO: battle dialog popup for rolling and assigning hits! // TODO: show killed leaders taken for bonus purchase +const DICE = { + B0: '<span class="black d0"></span>', + B1: '<span class="black d1"></span>', + B2: '<span class="black d2"></span>', + B3: '<span class="black d3"></span>', + B4: '<span class="black d4"></span>', + B5: '<span class="black d5"></span>', + B6: '<span class="black d6"></span>', + W0: '<span class="white d0"></span>', + W1: '<span class="white d1"></span>', + W2: '<span class="white d2"></span>', + W3: '<span class="white d3"></span>', + W4: '<span class="white d4"></span>', + W5: '<span class="white d5"></span>', + W6: '<span class="white d6"></span>', +} + // === SYNC with rules.js === const LEGION_COUNT = 33 @@ -1304,5 +1321,64 @@ function on_update() { action_button("undo", "Undo") } +function sub_region_name(match, p1) { + let x = p1 | 0 + return REGION_NAME[x] +} + +function sub_dice_image(match) { + return DICE[match] +} + +function on_log(text) { + let p = document.createElement("div") + + if (text.match(/^>/)) { + text = text.substring(1) + p.className = 'i' + } + + text = text.replace(/&/g, "&") + text = text.replace(/</g, "<") + text = text.replace(/>/g, ">") + + text = text.replace(/S(\d+)/g, sub_region_name) + text = text.replace(/\b[BW]\d\b/g, sub_dice_image) + + if (text.match(/^.turn/)) { + text = text.substring(6) + p.className = 'turn ' + text + } + + if (text.match(/^\.h1/)) { + text = text.substring(4) + p.className = "h1" + } + else if (text.match(/^\.h2 Red/)) { + text = text.substring(4) + p.className = "h2 p_red" + } + else if (text.match(/^\.h2 Blue/)) { + text = text.substring(4) + p.className = "h2 p_blue" + } + else if (text.match(/^\.h2 Yellow/)) { + text = text.substring(4) + p.className = "h2 p_yellow" + } + else if (text.match(/^\.h2 Green/)) { + text = text.substring(4) + p.className = "h2 p_green" + } + if (text.match(/^\.h3/)) { + text = text.substring(4) + p.className = "h3" + } + + p.innerHTML = text + return p +} + + on_init() scroll_with_middle_mouse("main") |