summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
authorJoël Simoneau <simoneaujoel@gmail.com>2024-10-26 23:13:06 -0400
committerJoël Simoneau <simoneaujoel@gmail.com>2024-10-26 23:13:06 -0400
commit84fae8c76f570b649ad3f4b2f6a75438c303c272 (patch)
tree9896e7ecfc9cbe3badffb574c4362e65ea83a943 /rules.js
parent79022fe756cfdf48184456ff09cd66baf8ff5f9f (diff)
downloadvijayanagara-84fae8c76f570b649ad3f4b2f6a75438c303c272.tar.gz
Build.
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js58
1 files changed, 57 insertions, 1 deletions
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) {