From 84fae8c76f570b649ad3f4b2f6a75438c303c272 Mon Sep 17 00:00:00 2001 From: Joël Simoneau Date: Sat, 26 Oct 2024 23:13:06 -0400 Subject: Build. --- play.js | 46 +++++++++++++--------------------------------- rules.js | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 70 insertions(+), 34 deletions(-) diff --git a/play.js b/play.js index 9253d0a..df932ed 100644 --- a/play.js +++ b/play.js @@ -581,29 +581,6 @@ function init_ui() { create_piece_list(MI, TROOPS, "piece mongol cube", 2, 0) -return - - /* -
-
-
-
-
-
-
-
- */ - - - - - create_piece_list(BK, DISK, "piece ve disk", -4, 10) - create_piece_list(BK, AMIR, "piece ve amir", 2, 0) - - create_piece_list(VE, DISK, "piece ve disk", -4, 10) - create_piece_list(VE, RAJA, "piece ve raja", 2, 0) - - create_piece_list(MI, CUBE, "piece mongol cube", 2, 0) } /* UPDATE */ @@ -690,8 +667,8 @@ function layout_pieces(list, xorig, yorig, discs, s) { layout_piece_rowcol(nrow, ncol, row, col, list[list.length-(++i)], z--) } - // if (discs) - // layout_discs(discs, xorig + off_x, yorig + 12 + off_y, s) + if (discs) + layout_discs(discs, xorig + off_x, yorig + 12 + off_y, s) } function place_piece(p, x, y, z) { @@ -984,6 +961,9 @@ function on_update() { action_button("rally", "Rally") action_button("end_rally", "End Rally") + // Decree buttons + action_button("build", "Build") + action_button("next", "Next") action_button("undo", "Undo") @@ -1333,21 +1313,21 @@ function on_log(text) { text = text.substring(4) p.className = "h1" } - else if (text.match(/^\.h2 Gov/)) { + else if (text.match(/^\.h2 Delhi Sultanate/)) { text = text.substring(3) - p.className = "h2 govt" + p.className = "h2 ds" } - else if (text.match(/^\.h2 AUC/)) { + else if (text.match(/^\.h2 Bahmani Kingdom/)) { text = text.substring(3) - p.className = "h2 auc" + p.className = "h2 bk" } - else if (text.match(/^\.h2 Cartels/)) { + else if (text.match(/^\.h2 Vijayanagara Empire/)) { text = text.substring(3) - p.className = "h2 cartels" + p.className = "h2 ve" } - else if (text.match(/^\.h2 FARC/)) { + else if (text.match(/^\.h2 Mongol Invaders/)) { text = text.substring(3) - p.className = "h2 farc" + p.className = "h2 mi" } else if (text.match(/^\.h2 /)) { text = text.substring(3) diff --git a/rules.js b/rules.js index 9937e19..f0449c4 100644 --- a/rules.js +++ b/rules.js @@ -196,7 +196,8 @@ exports.setup = function (seed, scenario, _options) { free: null, spaces: [], where: null, - } + }, + decree: 0 } if (scenario === "Solo") @@ -359,6 +360,11 @@ function goto_pass() { resume_event_card() } +function goto_build() { + init_command("Build") + game.state = "build" +} + function goto_conscript() { init_command("Conscript") game.state = "conscript" @@ -434,6 +440,7 @@ states.eligible = { command_decree() { push_undo() game.cylinder[game.current] = SOP_COMMAND_DECREE + game.decree = 1 game.state = "command_decree" }, event_command() { @@ -454,7 +461,10 @@ states.command_decree = { prompt() { view.prompt = "Select a Command and a Decree!" gen_any_command() + if (game.decree === 1) + gen_any_decree() }, + build: goto_build, conscript: goto_conscript, rally: goto_rally, } @@ -479,6 +489,34 @@ states.lim_command = { rally: goto_rally, } +states.build = { + prompt() { + if (game.current === BK) + view.prompt = "Build: Select a Province with an Amir" + else if (game.current === VE) + view.prompt = "Build: Select a Province with a Raja" + + if (can_build()) { + for (let s = first_space; s <= last_space; ++s) { + if (can_build_in_space(s)) + gen_action_space(s) + } + } + }, + space(s) { + push_undo() + push_summary() + let p = find_piece(AVAILABLE, game.current, DISC) + log_summary_place(p) + place_piece(p, s) + log_space(s, "Build") + pop_summary() + game.decree = 0 + game.state = "command_decree" + } + +} + states.conscript = { prompt() { view.prompt = "Conscript: Select Tributaries, Qasbah or Dehli to place troops." @@ -656,6 +694,24 @@ function end_command() { resume_event_card() } +/* DECREES */ + +function gen_any_decree() { + if (game.current === DS) { + // view.actions.conscript = can_conscript() ? 1 : 0 + } else if (game.current === BK || game.current === VE) { + view.actions.build = can_build() ? 1 : 0 + } +} + +function can_build() { + return has_piece(AVAILABLE, game.current, DISC) +} + +function can_build_in_space(s) { + return has_piece(s, game.current, ELITE) +} + /* TOKENS */ function add_tributary(s) { -- cgit v1.2.3