diff options
-rw-r--r-- | play.js | 46 | ||||
-rw-r--r-- | rules.js | 58 |
2 files changed, 70 insertions, 34 deletions
@@ -581,29 +581,6 @@ function init_ui() { create_piece_list(MI, TROOPS, "piece mongol cube", 2, 0) -return - - /* - <div class="piece ds governor" style="left:200px;top:380px"></div> - <div class="piece bk amir rebel" style="left:230px;top:380px"></div> - <div class="piece ve raja rebel" style="left:260px;top:380px"></div> - <div class="piece ds cube" style="left:210px;top:430px"></div> - <div class="piece mongol cube" style="left:245px;top:430px"></div> - <div class="piece ds disk" style="left:200px;top:480px"></div> - <div class="piece bk disk" style="left:250px;top:480px"></div> - <div class="piece ve disk" style="left:300px;top:480px"></div> - */ - - - - - 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) @@ -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) { |