diff options
-rw-r--r-- | events.txt | 36 | ||||
-rw-r--r-- | play.js | 13 | ||||
-rw-r--r-- | rules.js | 212 | ||||
-rw-r--r-- | tools/gencode.js | 6 |
4 files changed, 194 insertions, 73 deletions
@@ -778,40 +778,60 @@ SHADED 36 remove endpiece -SUCC 1 +SUCC 0 force_current DS loge "Power struggle in Delhi." + flip_dynasty + log_h2 DS "The Sultanate reimposes its dominance." campaign force_current BK prompt "Gain Cavalry token equal to Influence and Forts." - loge "Military labor market thrives" + log_h2 BK "Military labor market thrives" gain_cavalry (game.inf[BK] + count_pieces_on_map(BK, DISC)) force_current VE prompt "Gain resources equal to Influence and Temples." - loge "Temple towns emerge anew" + log_h2 VE "Temple towns emerge anew" resources VE (game.inf[VE] + count_pieces_on_map(VE, DISC)) SUCC 2 force_current DS + log_h2 DS "Delhi monitors its interests." campaign force_current BK + log_h2 BK "Ala-ud-Din Hasan Bahman Shah gathers allies and takes the Deccan throne." any_limited_command - cav_resources (Math.min(game.prosperity[BK],3)) + if (game.prosperity[BK] === 0) + log_br + log "Not enough prosperity." + else + cav_resources (Math.min(game.prosperity[BK],3)) + endif force_current VE + log_h2 VE "Sangama brothers establish an empire." any_limited_command - cav_resources (Math.min(game.prosperity[VE],3)) + if (game.prosperity[VE] === 0) + log_br + log "Not enough prosperity." + else + cav_resources (Math.min(game.prosperity[VE],3)) + endif SUCC 3 force_current DS - loge "Renewed focus on infrastructure." + log_h2 DS "Renewed focus on infrastructure." influence_succession force_current BK - loge "Trade network covers the Deccan." + log_h2 BK "Trade network covers the Deccan." influence_succession force_current VE - loge "Vast, unifying medieval metropolis." + log_h2 VE "Vast, unifying medieval metropolis." influence_succession +SUCC 4 + force_current DS + log_h2 DS "Succession Crisis in Delhi." + timurid_crisis + SUCC 5 force_current DS prompt "Invaders are attacking in the Mountain Passes!" @@ -517,6 +517,7 @@ function on_click_action(evt) { function init_ui() { register_action(ui.this_card, "event", undefined) + register_action(ui.dynasty_card, "dynasty_card", undefined) register_action(ui.unshaded_event, "unshaded", undefined) register_action(ui.shaded_event, "shaded", undefined) register_action(ui.gk_unshaded_event, "gk_unshaded", undefined) @@ -1000,11 +1001,12 @@ function on_update() { ui.of_gods_and_kings.className = "hide" ui.this_card.classList.toggle("action", !!(view.actions && view.actions.event === 1)) + ui.dynasty_card.classList.toggle("action", !!(view.actions && view.actions.dynasty_card === 1)) ui.shaded_event.classList.toggle("action", !!(view.actions && view.actions.shaded === 1)) ui.unshaded_event.classList.toggle("action", !!(view.actions && view.actions.unshaded === 1)) ui.gk_shaded_event.classList.toggle("action", !!(view.actions && view.actions.gk_shaded === 1)) ui.gk_unshaded_event.classList.toggle("action", !!(view.actions && view.actions.gk_unshaded === 1)) - console.log(view.actions) + // Dynasty card if (view.succ > 0) ui.dynasty_card.className = "card card_dynasty_tughlaq" @@ -1330,13 +1332,14 @@ function on_log(text) { else if (text.match(/^\.h1/)) { text = text.substring(4) p.className = "h1" - } else if (text.match(/^\.h2 Delhi Sultanate/)) { + } + else if (text.match(/^\.h2 Delhi Sultanate/)) { text = text.substring(4) p.className = "h2 ds" } else if (text.match(/^\.h2 DS/)) { text = text.substring(6) - p.className = "h2 ds" + p.className = "h2 ds italic" } else if (text.match(/^\.h2 Bahmani Kingdom/)) { text = text.substring(4) @@ -1344,7 +1347,7 @@ function on_log(text) { } else if (text.match(/^\.h2 BK/)) { text = text.substring(6) - p.className = "h2 bk" + p.className = "h2 bk italic" } else if (text.match(/^\.h2 Vijayanagara Empire/)) { text = text.substring(4) @@ -1352,7 +1355,7 @@ function on_log(text) { } else if (text.match(/^\.h2 VE/)) { text = text.substring(6) - p.className = "h2 ve" + p.className = "h2 ve italic" } else if (text.match(/^\.h2 Mongol Invaders/)) { text = text.substring(4) @@ -291,6 +291,7 @@ function setup_deck() { } game.of_gods_and_kings[0] = cards[cards.length-1] game.deck = deck + game.deck = [1, 45, 2, 46, 3, 47, 4, 48, 5, 49] } function setup_standard() { @@ -474,18 +475,20 @@ function goto_cavalry(n, next) { } push_summary() - while (game.cav.n > 0 && n_available_cavalry() > 0) { - let c = find_cavalry(AVAILABLE) - log_summary_cavalry(c) - set_cavalry_faction(c, game.current) - game.cav.n -= 1 - } + game.state = "cavalry" + // Removing automatic cavalry tokens attribution + // while (game.cav.n > 0 && n_available_cavalry() > 0) { + // let c = find_cavalry(AVAILABLE) + // log_summary_cavalry(c) + // set_cavalry_faction(c, game.current) + // game.cav.n -= 1 + // } - if (game.cav.n !== 0) - game.state = "cavalry" - else { - end_cavalry() - } + // if (game.cav.n !== 0) + // game.state = "cavalry" + // else { + // end_cavalry() + // } } function end_cavalry() { @@ -583,15 +586,10 @@ function goto_tax() { function succession() { game.current = DS - game.succ += 1 + if (game.succ > 0) + game.succ += 1 - if (game.succ <= 3) - goto_vm(game.succ * 2 + 72) - else if (game.succ === 4) { - timurid_step1() - } else if (game.succ === 5) { - goto_vm(game.succ * 2 + 72) - } + goto_vm(game.succ * 2 + 74) } function is_succession() { @@ -602,20 +600,6 @@ function is_timurid() { return (game.vm && game.vm.fp > 78) } -function timurid_step1() { - let n = Math.floor(count_pieces(AVAILABLE, MI, TROOPS) / 2) - - loge("Succession Crisis in Delhi.") - push_summary() - for (let i = 0; i < n; ++i) { - let p = find_piece(AVAILABLE, MI, TROOPS) - log_summary_place(p) - place_piece(p, S_MOUNTAIN_PASSES) - } - pop_summary() - end_card() -} - /* STATES */ states.eligible = { @@ -733,7 +717,7 @@ states.compromising_gifts = { view.actions.end_gifts = 1 }, influence(f) { - log_h2(faction_acronyms[f] + "Compromising Gifts") + log_h2(faction_name[f] + "Compromising Gifts") log_resources(f, 2) add_resources(f, 2) game.inf_shift = { @@ -1915,9 +1899,10 @@ function prompt_end_decree() { } function init_decree(type) { - if (!is_succession()) + if (!is_succession()) { push_undo() - log_h2(faction_name[game.current] + " - " + type) + log_h2(faction_name[game.current] + " - " + type) + } game.decree = { spaces: [], } @@ -2082,6 +2067,9 @@ states.campaign = { } } + if (is_succession()) + view.actions.skip = 1 + }, space(s) { push_undo() @@ -2091,6 +2079,10 @@ states.campaign = { game.vm.m = s game.state = "campaign_moves" } + }, + skip() { + logi("Nothing") + vm_next() } } @@ -3174,7 +3166,9 @@ function remove_influence(faction) { } function end_influence() { - if (game.vm) + if (game.vm && game.vm.fp === 80) + game.state = "vm_influence_succession" + else if (game.vm) vm_next() else { if (typeof game.inf_shift.next === "function") @@ -4124,6 +4118,11 @@ function vm_log_br() { vm_next() } +function vm_log_h2() { + log_h2(faction_acronyms[vm_operand(1)] + " " + vm_operand(2)) + vm_next() +} + function vm_mark_space() { if (game.vm.m) set_add(game.vm.m, game.vm.s) @@ -4598,18 +4597,21 @@ states.vm_steal = { function vm_cav_resources() { game.vm.count = vm_operand(1) - if (game.vm.count > 0) { + if (game.vm.count > 0) push_summary() - game.state = "vm_cav_resources" - } else - vm_next() + game.state = "vm_cav_resources" } states.vm_cav_resources = { prompt() { - event_prompt(`Gain ${game.vm.count} Resources or Cavalry tokens.`) - gen_action_resources(game.current) - gen_take_cavalry(game.current) + if (game.vm.count === 0) { + event_prompt("No Cavalry token nor Resource to gain.") + view.actions.skip = 1 + } else { + event_prompt(`Gain ${game.vm.count} Resource${game.vm.count > 1 ? "s": ""} or Cavalry token${game.vm.count > 1 ? "s": ""}.`) + gen_action_resources(game.current) + gen_take_cavalry(game.current) + } }, resources(f) { log_summary_resources(game.current) @@ -4620,6 +4622,10 @@ states.vm_cav_resources = { log_summary_cavalry(c) set_cavalry_faction(c, game.current) tick_cav_resources() + }, + skip() { + logi("Nothing") + vm_next() } } @@ -4824,16 +4830,33 @@ function vm_free_rebel() { game.state = "rebel" } +// VM: FLIP DYNASTY + +function vm_flip_dynasty() { game.state = "vm_flip_dynasty" } + +states.vm_flip_dynasty = { + prompt() { + event_prompt("End of the oppressive Khalji Dynasty.") + + view.actions.dynasty_card = 1 + }, + dynasty_card() { + game.succ += 1 + logi("Dawn of the Tughlaq Dynasty, Rebel Commands are now available.") + vm_next() + } +} + // VM: INFLUENCE SUCCESSION function vm_influence_succession() { game.cmd = {} game.cmd.who = null game.cmd.count = 3 - game.state = "influence_succession" + game.state = "vm_influence_succession" } -states.influence_succession = { +states.vm_influence_succession = { prompt() { if (game.resources[game.current] < 3) { event_prompt("Not enough resources.") @@ -4852,22 +4875,68 @@ states.influence_succession = { if (game.inf[game.cmd.who] > 0) view.actions.remove_influence = 1 } - view.actions.skip = 1 + if (game.cmd.count === 3) + view.actions.skip = 1 + if (game.cmd.count < 3) + view.actions.next = 1 }, influence(f) { game.cmd.who = f }, add_influence() { + push_undo() add_resources(game.current, -3) add_influence(game.cmd.who) game.cmd.count -= 1 }, remove_influence() { + push_undo() add_resources(game.current, -3) remove_influence(game.cmd.who) game.cmd.count -= 1 }, - skip: vm_next + next: vm_next, + skip() { + log("Declined influence shift.") + vm_next() + }, +} + +// VM : TIMURID CRISIS + +function vm_timurid_crisis() { game.state = "vm_timurid_crisis" } + +states.vm_timurid_crisis = { + prompt() { + event_prompt("Mongols Invaders gather in the Mountain Passes.") + gen_action_space(S_MONGOL_INVADERS) + }, + space(s) { + log_space(S_MOUNTAIN_PASSES, "Advance") + let n = Math.floor(count_pieces(AVAILABLE, MI, TROOPS) / 2) + push_summary() + for (let i = 0; i < n; ++i) { + let p = find_piece(AVAILABLE, MI, TROOPS) + log_summary_place(p) + place_piece(p, S_MOUNTAIN_PASSES) + } + pop_summary() + vm_next() + } +} + +function timurid_step1() { + let n = Math.floor(count_pieces(AVAILABLE, MI, TROOPS) / 2) + + loge("Succession Crisis in Delhi.") + push_summary() + for (let i = 0; i < n; ++i) { + let p = find_piece(AVAILABLE, MI, TROOPS) + log_summary_place(p) + place_piece(p, S_MOUNTAIN_PASSES) + } + pop_summary() + end_card() } // VM : TIMURID ADVANCE @@ -4998,6 +5067,7 @@ states.vm_any_limited_command = { view.actions.migrate = can_migrate() ? 1 : 0 view.actions.rebel = can_rebel() ? 1 : 0 view.actions.attack = can_attack() ? 1 : 0 + view.actions.skip = 1 }, rally() { push_undo() @@ -5022,7 +5092,8 @@ states.vm_any_limited_command = { game.cmd.attacker = game.current game.cmd.support_space = null game.state = "attack" - } + }, + skip: vm_next } @@ -6193,51 +6264,74 @@ CODE[36 * 2 + 1] = [ [ vm_return ], ] -// SUCC 1 -CODE[1 * 2 + 72] = [ +// SUCC 0 +CODE[0 * 2 + 74] = [ [ vm_force_current, DS ], [ vm_loge, "Power struggle in Delhi." ], + [ vm_flip_dynasty ], + [ vm_log_h2, DS, "The Sultanate reimposes its dominance." ], [ vm_campaign ], [ vm_force_current, BK ], [ vm_prompt, "Gain Cavalry token equal to Influence and Forts." ], - [ vm_loge, "Military labor market thrives" ], + [ vm_log_h2, 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_loge, "Temple towns emerge anew" ], + [ vm_log_h2, VE, "Temple towns emerge anew" ], [ vm_resources, false, VE, ()=>(game.inf[VE] + count_pieces_on_map(VE, DISC)) ], [ vm_return ], ] // SUCC 2 -CODE[2 * 2 + 72] = [ +CODE[2 * 2 + 74] = [ [ vm_force_current, DS ], + [ vm_log_h2, 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_any_limited_command ], + [ vm_if, ()=>(game.prosperity[BK] === 0) ], + [ vm_log_br ], + [ vm_log, "Not enough prosperity." ], + [ vm_else ], [ 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_any_limited_command ], + [ vm_if, ()=>(game.prosperity[VE] === 0) ], + [ vm_log_br ], + [ vm_log, "Not enough prosperity." ], + [ vm_else ], [ vm_cav_resources, ()=>(Math.min(game.prosperity[VE],3)) ], + [ vm_endif ], [ vm_return ], ] // SUCC 3 -CODE[3 * 2 + 72] = [ +CODE[3 * 2 + 74] = [ [ vm_force_current, DS ], - [ vm_loge, "Renewed focus on infrastructure." ], + [ vm_log_h2, DS, "Renewed focus on infrastructure." ], [ vm_influence_succession ], [ vm_force_current, BK ], - [ vm_loge, "Trade network covers the Deccan." ], + [ vm_log_h2, BK, "Trade network covers the Deccan." ], [ vm_influence_succession ], [ vm_force_current, VE ], - [ vm_loge, "Vast, unifying medieval metropolis." ], + [ vm_log_h2, VE, "Vast, unifying medieval metropolis." ], [ vm_influence_succession ], [ vm_return ], ] +// SUCC 4 +CODE[4 * 2 + 74] = [ + [ vm_force_current, DS ], + [ vm_log_h2, DS, "Succession Crisis in Delhi." ], + [ vm_timurid_crisis ], + [ vm_return ], +] + // SUCC 5 -CODE[5 * 2 + 72] = [ +CODE[5 * 2 + 74] = [ [ vm_force_current, DS ], [ vm_prompt, "Invaders are attacking in the Mountain Passes!" ], [ vm_space, true, 1, 1, (s)=>(s === S_MOUNTAIN_PASSES && has_ds_unit(s) && has_mi_unit(s)) ], diff --git a/tools/gencode.js b/tools/gencode.js index a68451a..b962a07 100644 --- a/tools/gencode.js +++ b/tools/gencode.js @@ -61,7 +61,7 @@ for (let line of fs.readFileSync("events.txt", "utf-8").split("\n")) { SCODE[line[1]] = pc console.log("") console.log("// SUCC " + line[1]) - console.log("CODE[" + line[1] + " * 2 + 72] = [") + console.log("CODE[" + line[1] + " * 2 + 74] = [") break case "if_space": @@ -138,6 +138,10 @@ for (let line of fs.readFileSync("events.txt", "utf-8").split("\n")) { emit([ line[0], line.slice(1).join(" ") ]) break + case "log_h2": + emit([ line[0], line[1], line.slice(2).join(" ") ]) + break + case "count_spaces": emit([ line[0], "(s)=>" + line.slice(1).join(" ") ]) break |