From a25b93cf1fd61c44c6608d97630b6c0e6b106372 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sat, 12 Apr 2025 13:15:00 +0200 Subject: "Short" faction names in log. Brighter colors. --- rules.js | 156 +++++++++++++++++++++++++++++---------------------------------- 1 file changed, 72 insertions(+), 84 deletions(-) (limited to 'rules.js') diff --git a/rules.js b/rules.js index a32088a..43d07b7 100644 --- a/rules.js +++ b/rules.js @@ -60,12 +60,12 @@ const last_space = S_PUNJAB const last_province = S_TAMILAKAM const faction_name = [ "Delhi Sultanate", "Bahmani Kingdom", "Vijayanagara Empire", "Mongol Invaders" ] +const faction_short = [ "Sultanate", "Bahmani", "Vijayanagara", "Mongols" ] const faction_acronyms = [ "DS", "BK", "VE", "MI" ] const faction_flags = [ "FDS", "FBK", "FVE", "FMI" ] -const AD = [ "0", '\u2776', '\u2777', '\u2778', '\u2779', '\u277A', '\u277B' ] -const DD = [ "0", '\u2460', '\u2461', '\u2462', '\u2463', '\u2464', '\u2465' ] - +const AD = [ "A0", "A1", "A2", "A3", "A4", "A5", "A6" ] +const DD = [ "D0", "D1", "D2", "D3", "D4", "D5", "D6" ] exports.scenarios = [ "Standard", "Solo" ] @@ -366,27 +366,23 @@ function this_card() { function next_card_back() { if (game.deck.length > 1) { - if (game.deck[1] >= 45 && game.deck[1] <= 47) + if (game.deck[1] >= 45 && game.deck[1] <= 47) return game.deck[1] - 44 } return 0 } function goto_card() { - if (this_card() >= 37 && this_card() <= 40) { - log_h1("Mongol Invaders C" + this_card()) + log_h1("C" + this_card()) + if (this_card() >= 37 && this_card() <= 40) { goto_mongol_invaders(BK) - } else if (this_card() >= 41 && this_card() <= 44) { - log_h1("Mongol Invaders C" + this_card()) + } else if (this_card() >= 41 && this_card() <= 44) { goto_mongol_invaders(VE) - } else if (this_card() >= 45 && this_card() <= 47) { - log_h1(`succ${this_card()-44} C` + this_card()) + } else if (this_card() >= 45 && this_card() <= 47) { succession() } else if (this_card() >= 48 && this_card() <= 49) { - log_h1("Mongol Invaders C" + this_card()) succession() } else { - log_h1("C" + this_card()) adjust_eligibility(DS) adjust_eligibility(BK) adjust_eligibility(VE) @@ -485,7 +481,7 @@ function goto_pass() { game.sa = 0 game.cylinder[game.current] = SOP_PASS - log_h2(faction_name[game.current] + " - Pass") + log_h2(faction_short[game.current] + " - Pass") if (game.current === DS) { log_resources(game.current, 3) add_resources(game.current, 3) @@ -794,7 +790,7 @@ states.compromising_gifts = { }, influence(f) { push_undo() - log_h2(faction_name[f] + " - Compromising Gifts") + log_h2(faction_short[f] + " - Compromising Gifts") log_resources(f, 2) add_resources(f, 2) game.inf_shift = { @@ -954,18 +950,18 @@ states.tax = { function init_command(type) { push_undo() if (game.cmd.limited) - log_h2(faction_name[game.current] + " - Limited " + type) + log_h2(faction_short[game.current] + " - Limited " + type) else - log_h2(faction_name[game.current] + " - " + type) + log_h2(faction_short[game.current] + " - " + type) game.cmd.type = type } function init_vm_command(type, free, limited) { push_undo() if (limited) - log_h2(faction_name[game.current] + " - Limited " + type) + log_h2(faction_short[game.current] + " - Limited " + type) else - log_h2(faction_name[game.current] + " - " + type) + log_h2(faction_short[game.current] + " - " + type) game.cmd = { type: type, @@ -1212,18 +1208,18 @@ function attack_use_cavalry(d, f) { function charge_die(d) { if (d < 4) { - logi(`.ad ${AD[game.dice[d]]} -> ${AD[game.dice[d]-1]} charged`) + logi(`${AD[game.dice[d]]} -> ${AD[game.dice[d]-1]} charged`) } else { - logi(`.dd ${DD[game.dice[d]]} -> ${DD[game.dice[d]-1]} charged`) + logi(`${DD[game.dice[d]]} -> ${DD[game.dice[d]-1]} charged`) } game.dice[d] -= 1 } function screen_die(d) { if (d < 4) { - logi(`.ad ${AD[game.dice[d]]} screened`) + logi(`${AD[game.dice[d]]} screened`) } else { - logi(`.dd ${DD[game.dice[d]]} screened`) + logi(`${DD[game.dice[d]]} screened`) } game.dice[d] = 0 } @@ -1366,8 +1362,8 @@ states.attack_space = { roll() { clear_undo() roll_attack() - log(">.ad " + game.dice.slice(0,4).filter(d => d > 0).map(d => AD[d]).join(" ")) - log(">.dd " + game.dice.slice(4).filter(d => d > 0).map(d => DD[d]).join(" ")) + log(">" + game.dice.slice(0,4).filter(d => d > 0).map(d => AD[d]).join(" ")) + log(">" + game.dice.slice(4).filter(d => d > 0).map(d => DD[d]).join(" ")) log_br() game.cmd.step = 0 @@ -2045,7 +2041,7 @@ function prompt_end_decree() { function init_decree(type) { if (!is_succession()) { push_undo() - log_h2(faction_name[game.current] + " - " + type) + log_h2(faction_short[game.current] + " - " + type) } game.decree = { spaces: [], @@ -2109,7 +2105,7 @@ function can_collect() { } function collect_count() { - let c = Math.floor(game.prosperity[DS]) + let c = Math.floor(game.prosperity[DS]) return Math.floor(game.prosperity[0] / 2) } @@ -2157,25 +2153,26 @@ function goto_campaign() { game.state = "campaign" } +// TODO: precompute all distances from warangal! function is_n_from_warangal(n, s) { - let queue = [[s, []]] + let queue = [ [ s, [] ] ] - while (queue.length) { - let [node, path] = queue.shift(); + while (queue.length) { + let [ node, path ] = queue.shift() - if (path.length === n) { - if (is_adjacent_to_city(C_WARANGAL, node)) + if (path.length === n) { + if (is_adjacent_to_city(C_WARANGAL, node)) return true - } else if (path.length < n) { + } else if (path.length < n) { for (let neighbor of SPACES[node].adjacent) { - // if (!set_has(path, neighbor) && !set_has(game.decree.campaign, neighbor)) { + // if (!set_has(path, neighbor) && !set_has(game.decree.campaign, neighbor)) if (!set_has(path, neighbor) && !game.decree.campaign.includes(neighbor)) { - queue.push([neighbor, [...path, neighbor]]); + queue.push([ neighbor, [ ...path, neighbor ] ]) } } } - } - return false; + } + return false } states.campaign = { @@ -3398,9 +3395,9 @@ function add_influence(faction) { if (faction === BK && game.inf[faction] === 2) move_all_faction_piece_from(BK, ELITE, S_BK_INF_2, AVAILABLE) - else if (faction === BK && game.inf[faction] === 4) + else if (faction === BK && game.inf[faction] === 4) move_all_faction_piece_from(BK, ELITE, S_BK_INF_4, AVAILABLE) - else if (faction === VE) + else if (faction === VE) move_all_faction_piece_from(VE, ELITE, S_VE_INF_1 + game.inf[faction] - 1, AVAILABLE) } @@ -3653,7 +3650,7 @@ states.give_resources = { game.transfer.count = 0 }, deny() { - log_transfer(`${faction_name[game.current]} denied request from ${faction_name[game.transfer.current]}.`) + log_transfer(`${faction_short[game.current]} denied request from ${faction_short[game.transfer.current]}.`) end_negotiation() }, done() { @@ -3768,7 +3765,7 @@ states.give_cavalry = { set_cavalry_faction(c, game.transfer.current) }, deny() { - log_transfer(`${faction_name[game.current]} denied request from ${faction_name[game.transfer.current]}.`) + log_transfer(`${faction_short[game.current]} denied request from ${faction_short[game.transfer.current]}.`) end_negotiation() }, done() { @@ -3886,11 +3883,6 @@ function log(msg) { game.log.push(msg) } -function loge(msg) { - log_br() - game.log.push(".e " + msg) -} - function logi(msg) { log(">" + msg) } @@ -3924,11 +3916,11 @@ function log_transfer(msg) { } function log_transfer_resources(from, to, n) { - log_transfer(`${faction_name[from]} gave ${n} Resources to ${faction_name[to]}.`) + log_transfer(`${faction_short[from]} gave ${n} Resources to ${faction_short[to]}.`) } function log_transfer_cavalry(from, to, n) { - log_transfer(`${faction_name[from]} gave ${n} Cavalry tokens to ${faction_name[to]}.`) + log_transfer(`${faction_short[from]} gave ${n} Cavalry tokens to ${faction_short[to]}.`) } function log_space(s, action) { @@ -4465,20 +4457,20 @@ function goto_gk_event(shaded) { game.cmd = 0 if (shaded) { - log_h2(faction_name[game.current] + " - Shaded Event") + log_h2(faction_short[game.current] + " - Shaded Event") log(faction_flags[game.current] + " used the set-aside Event Card.") log_br() - log("C" + c) - log(".i " + data.card_flavor_shaded[c] + ".") + log(".h3 C" + c) + log(">.i " + data.card_flavor_shaded[c] + ".") log_br() goto_vm(c * 2 + 1) } else { - log_h2(faction_name[game.current] + " - Event") + log_h2(faction_short[game.current] + " - Event") log(faction_flags[game.current] + " used the set-aside Event Card.") log_br() - log("C" + c) + log(".h3 C" + c) if (data.card_flavor[c]) - log(".i " + data.card_flavor[c] + ".") + log(">.i " + data.card_flavor[c] + ".") log_br() goto_vm(c * 2 + 0) } @@ -4490,16 +4482,16 @@ function goto_event(shaded) { game.cmd = 0 if (shaded) { - log_h2(faction_name[game.current] + " - Shaded Event") - log("C" + c) - log(".i " + data.card_flavor_shaded[c] + ".") + log_h2(faction_short[game.current] + " - Shaded Event") + log(".h3 C" + c) + log(">.i " + data.card_flavor_shaded[c] + ".") log_br() goto_vm(c * 2 + 1) } else { - log_h2(faction_name[game.current] + " - Event") - log("C" + c) + log_h2(faction_short[game.current] + " - Event") + log(".h3 C" + c) if (data.card_flavor[c]) - log(".i " + data.card_flavor[c] + ".") + log(">.i " + data.card_flavor[c] + ".") log_br() goto_vm(c * 2 + 0) } @@ -4592,21 +4584,21 @@ states.vm_current = { if (game.current !== DS) clear_undo() change_current(DS) - log_transfer(faction_name[game.current] + "...") + log_transfer(faction_short[game.current] + "...") vm_next() }, bk() { if (game.current !== BK) clear_undo() change_current(BK) - log_transfer(faction_name[game.current] + "...") + log_transfer(faction_short[game.current] + "...") vm_next() }, ve() { if (game.current !== VE) clear_undo() change_current(VE) - log_transfer(faction_name[game.current] + "...") + log_transfer(faction_short[game.current] + "...") vm_next() } } @@ -4676,18 +4668,14 @@ function vm_log() { vm_next() } -function vm_loge() { - loge(vm_operand(1)) - vm_next() -} - function vm_log_br() { log_br() vm_next() } -function vm_log_h2() { - log_h2(faction_acronyms[vm_operand(1)] + " " + vm_operand(2)) +function vm_log_succ() { + log_h2(faction_short[vm_operand(1)]) + log(".i " + vm_operand(2)) vm_next() } @@ -5231,7 +5219,7 @@ states.vm_steal = { let f2 = vm_operand(2) let n = Math.min(vm_operand(3), game.resources[f2]) if (n == 0) { - event_prompt(`${faction_name[f2]} has no Resource.`) + event_prompt(`${faction_name[f2]} has no Resources.`) view.actions.skip = 1 } else { event_prompt(`Steal ${n} Resources from ${faction_name[f2]}.`) @@ -5306,7 +5294,7 @@ states.vm_steal_cavalry = { let f2 = vm_operand(2) let n = Math.min(vm_operand(3), n_cavalry(f2)) if (n == 0) { - event_prompt(`${faction_name[f2]} has no Cavalry token.`) + event_prompt(`${faction_name[f2]} has no Cavalry tokens.`) view.actions.skip = 1 } else { event_prompt(`Steal ${n} Cavalry token from ${faction_name[f2]}.`) @@ -5503,7 +5491,7 @@ states.vm_flip_dynasty = { }, dynasty_card() { game.succ += 1 - logi("Dawn of the Tughlaq Dynasty, Rebel Commands are now available.") + log("Dawn of the Tughlaq Dynasty, Rebel Commands are now available.") vm_next() } } @@ -5624,7 +5612,7 @@ function vm_end_game() { log_h2("Victory Phase") for (let i = 0; i < 3; i++) { - logi(faction_name[i] + " " + game.vp[i] + " VP") + logi(faction_short[i] + " " + game.vp[i] + " VP") } let result = get_result() @@ -6949,17 +6937,17 @@ CODE[36 * 2 + 1] = [ // SUCC 0 CODE[0 * 2 + 74] = [ [ vm_force_current, DS ], - [ vm_loge, "Power struggle in Delhi." ], + [ vm_log, ".i Power struggle in Delhi." ], [ vm_flip_dynasty ], - [ vm_log_h2, DS, "The Sultanate reimposes its dominance." ], + [ vm_log_succ, DS, "The Sultanate reimposes its dominance." ], [ vm_campaign ], [ vm_force_current, BK ], [ vm_prompt, "Gain Cavalry tokens equal to Influence and Forts." ], - [ vm_log_h2, BK, "Military labor market thrives" ], + [ vm_log_succ, BK, "Military labor market thrives." ], [ vm_gain_cavalry, ()=>(game.inf[BK] + count_pieces_on_map(BK, DISC)) ], [ vm_force_current, VE ], [ vm_prompt, "Gain resources equal to Influence and Temples." ], - [ vm_log_h2, VE, "Temple towns emerge anew" ], + [ vm_log_succ, VE, "Temple towns emerge anew" ], [ vm_resources, false, VE, ()=>(game.inf[VE] + count_pieces_on_map(VE, DISC)) ], [ vm_return ], ] @@ -6967,10 +6955,10 @@ CODE[0 * 2 + 74] = [ // SUCC 2 CODE[2 * 2 + 74] = [ [ vm_force_current, DS ], - [ vm_log_h2, DS, "Delhi monitors its interests." ], + [ vm_log_succ, DS, "Delhi monitors its interests." ], [ vm_campaign ], [ vm_force_current, BK ], - [ vm_log_h2, BK, "Ala-ud-Din Hasan Bahman Shah gathers allies and takes the Deccan throne." ], + [ vm_log_succ, BK, "Ala-ud-Din Hasan Bahman Shah gathers allies and takes the Deccan throne." ], [ vm_any_limited_command ], [ vm_if, ()=>(game.prosperity[BK] === 0) ], [ vm_log_br ], @@ -6979,7 +6967,7 @@ CODE[2 * 2 + 74] = [ [ vm_cav_resources, ()=>(Math.min(game.prosperity[BK],3)) ], [ vm_endif ], [ vm_force_current, VE ], - [ vm_log_h2, VE, "Sangama brothers establish an empire." ], + [ vm_log_succ, VE, "Sangama brothers establish an empire." ], [ vm_any_limited_command ], [ vm_if, ()=>(game.prosperity[VE] === 0) ], [ vm_log_br ], @@ -6993,13 +6981,13 @@ CODE[2 * 2 + 74] = [ // SUCC 3 CODE[3 * 2 + 74] = [ [ vm_force_current, DS ], - [ vm_log_h2, DS, "Renewed focus on infrastructure." ], + [ vm_log_succ, DS, "Renewed focus on infrastructure." ], [ vm_influence_succession ], [ vm_force_current, BK ], - [ vm_log_h2, BK, "Trade network covers the Deccan." ], + [ vm_log_succ, BK, "Trade network covers the Deccan." ], [ vm_influence_succession ], [ vm_force_current, VE ], - [ vm_log_h2, VE, "Vast, unifying medieval metropolis." ], + [ vm_log_succ, VE, "Vast, unifying medieval metropolis." ], [ vm_influence_succession ], [ vm_return ], ] @@ -7007,7 +6995,7 @@ CODE[3 * 2 + 74] = [ // SUCC 4 CODE[4 * 2 + 74] = [ [ vm_force_current, DS ], - [ vm_log_h2, DS, "Succession Crisis in Delhi." ], + [ vm_log_succ, DS, "Succession Crisis in Delhi." ], [ vm_timurid_crisis ], [ vm_return ], ] -- cgit v1.2.3