summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rules.js149
1 files changed, 79 insertions, 70 deletions
diff --git a/rules.js b/rules.js
index 6712f44..7e14bad 100644
--- a/rules.js
+++ b/rules.js
@@ -394,11 +394,6 @@ function goto_amass() {
game.state = "amass"
}
-function goto_build() {
- init_decree("Build")
- game.state = "build"
-}
-
function goto_cavalry(n, next) {
game.cav = {
"n": n,
@@ -551,11 +546,6 @@ function goto_tax() {
game.state = "tax"
}
-function goto_trade() {
- init_decree("Trade")
- game.state = "trade"
-}
-
/* STATES */
states.eligible = {
@@ -691,36 +681,6 @@ states.amass = {
}
}
-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 (game.decree === 1) {
- for (let s = first_space; s <= last_space; ++s) {
- if (can_build_in_space(s))
- gen_action_space(s)
- }
- } else {
- view.prompt = "Build: Done."
- view.actions.end_build = 1
- }
- },
- 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
- },
- end_build: end_decree,
-}
-
states.cavalry = {
prompt() {
if (game.cav.n > 0) {
@@ -1061,27 +1021,6 @@ states.tax = {
end_tax: end_decree
}
-states.trade = {
- prompt() {
- if (game.decree === 1) {
- view.prompt = `Trade: Collect ${trade_count()} from Provinces with your presence.`
- gen_action_resources(BK)
- } else {
- view.prompt = "Trade: Done."
- view.actions.end_trade = 1
- }
- },
- resources(f) {
- let t = trade_count()
- add_resources(game.current, t)
- logi_resources(BK, t)
- game.decree = 0
- goto_cavalry(trade_cavalry_count(), "trade")
- },
- end_trade: end_decree,
-}
-
-
/* COMMANDS */
function init_command(type) {
@@ -1262,7 +1201,7 @@ function gen_any_decree() {
} else if (game.current === BK) {
view.actions.trade = can_trade() ? 1 : 0
view.actions.build = can_build() ? 1 : 0
- // view.actions.conspire = can_conspire() ? 1 : 0
+ view.actions.conspire = can_conspire() ? 1 : 0
} else if (game.current === VE) {
view.actions.tax = can_tax() ? 1 : 0
view.actions.build = can_build() ? 1 : 0
@@ -1270,14 +1209,6 @@ function gen_any_decree() {
}
}
-function can_build() {
- return has_piece(AVAILABLE, game.current, DISC)
-}
-
-function can_build_in_space(s) {
- return has_piece(s, game.current, ELITE) && !has_piece(s, game.current, DISC)
-}
-
function can_demand() {
for (let s = first_space; s <= last_province; ++s)
if (can_demand_in_space(s))
@@ -1297,6 +1228,58 @@ function tax_count() {
return count_pieces_on_map(VE, DISC) + game.prosperity[VE]
}
+/* REBELS DECREES */
+
+function can_build() {
+ if (!has_piece(AVAILABLE, game.current, DISC))
+ return false
+
+ for (let s = first_space; s <= last_province; ++s)
+ if (can_build_in_space(s))
+ return true
+
+ return false
+}
+
+function can_build_in_space(s) {
+ return has_piece(s, game.current, ELITE) && !has_piece(s, game.current, DISC)
+}
+
+function goto_build() {
+ init_decree("Build")
+ game.state = "build"
+}
+
+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 (game.decree === 1) {
+ for (let s = first_space; s <= last_space; ++s) {
+ if (can_build_in_space(s))
+ gen_action_space(s)
+ }
+ } else {
+ view.prompt = "Build: Done."
+ view.actions.end_build = 1
+ }
+ },
+ 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
+ },
+ end_build: end_decree,
+}
+
function can_trade() {
return trade_count() > 0
}
@@ -1308,6 +1291,32 @@ function trade_count() {
return count
}
+function goto_trade() {
+ init_decree("Trade")
+ game.state = "trade"
+}
+
+states.trade = {
+ prompt() {
+ if (game.decree === 1) {
+ view.prompt = `Trade: Collect ${trade_count()} from Provinces with your presence.`
+ gen_action_resources(BK)
+ } else {
+ view.prompt = "Trade: Done."
+ view.actions.end_trade = 1
+ }
+ },
+ resources(f) {
+ let t = trade_count()
+ add_resources(game.current, t)
+ logi_resources(BK, t)
+ game.decree = 0
+ goto_cavalry(trade_cavalry_count(), "trade")
+ },
+ end_trade: end_decree,
+}
+
+
/* MONGOL INVADERS COMMANDS */
function gen_mi_command() {