summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--play.css5
-rw-r--r--play.js33
-rw-r--r--rules.js57
3 files changed, 76 insertions, 19 deletions
diff --git a/play.css b/play.css
index e482421..eb31f96 100644
--- a/play.css
+++ b/play.css
@@ -241,7 +241,10 @@ path.campaign { stroke: black; stroke-dasharray: 4 4; }
.space.box { border-radius: 0%; }
.space.action { border-color: lightgreen; box-shadow: 0 0 2px 1px black, inset 0 0 2px 1px black; background-color: rgb(144, 238, 144, 0.3); }
-.space.box.action { border-color: rgb(236, 121, 45); box-shadow: 0 0 2px 1px black, inset 0 0 2px 1px black; background-color: rgb(236, 121, 45, 0.3); }
+.space.box.action.ds { border-color: rgb(88, 88, 88); box-shadow: 0 0 2px 1px black, inset 0 0 2px 1px black; background-color: rgba(168, 168, 167, 0.5); }
+.space.box.action.bk { border-color: rgb(15, 202, 187); box-shadow: 0 0 2px 1px black, inset 0 0 2px 1px black; background-color: rgba(17, 219, 199, 0.5); }
+.space.box.action.ve { border-color: rgb(226, 207, 31); box-shadow: 0 0 2px 1px black, inset 0 0 2px 1px black; background-color: rgba(226, 190, 71, 0.5); }
+.space.box.action.mi { border-color: rgb(236, 121, 45); box-shadow: 0 0 2px 1px black, inset 0 0 2px 1px black; background-color: rgb(236, 121, 45, 0.5); }
.space.selected { border-color: yellow; box-shadow: 0 0 2px 1px black, inset 0 0 2px 1px black; }
.space.tip { border: 4px dotted white; }
diff --git a/play.js b/play.js
index 5f328f2..c02f8ba 100644
--- a/play.js
+++ b/play.js
@@ -172,7 +172,7 @@ const space_id = [
]
/* LAYOUT DATA */
-// :r !node tools/parse-layout.js
+// modified from tools/parse-layout.js
const layout = {
"circles": {
"provinces": {
@@ -285,22 +285,22 @@ const layout = {
"h": 126
},
"DS_available": {
- "x": 796,
- "y": 91,
- "w": 388,
- "h": 223
+ "x": 792,
+ "y": 85,
+ "w": 400,
+ "h": 237
},
"BK_available": {
- "x": 21,
- "y": 908,
- "w": 238,
- "h": 224
+ "x": 16,
+ "y": 902,
+ "w": 250,
+ "h": 237
},
"VE_available": {
- "x": 21,
- "y": 1405,
- "w": 239,
- "h": 225
+ "x": 16,
+ "y": 1401,
+ "w": 251,
+ "h": 236
}
},
"tracks": {
@@ -594,6 +594,11 @@ function init_ui() {
}
}
+ ui.spaces[S_MONGOL_INVADERS].classList.toggle("mi", true)
+ ui.spaces[S_DS_AVAILABLE].classList.toggle("ds", true)
+ ui.spaces[S_BK_AVAILABLE].classList.toggle("bk", true)
+ ui.spaces[S_VE_AVAILABLE].classList.toggle("ve", true)
+
function create_piece(c, action, id, x, y) {
let e = create("div", {
className: c,
@@ -1043,7 +1048,7 @@ function on_update() {
xy = get_layout_xy(s, "mongols")
layout_pieces(items, xy[0], xy[1], discs, MI)
} else if (s <= S_VE_AVAILABLE) {
- // Nothing ?
+ ui.spaces[s].classList.toggle("action", is_action("space", s))
} else if (s <= S_BK_INF_4) {
items.length = discs.length = 0
filter_piece_list(items, s, BK, ELITE)
diff --git a/rules.js b/rules.js
index 6706763..5cdab7f 100644
--- a/rules.js
+++ b/rules.js
@@ -155,18 +155,17 @@ exports.view = function (state, role) {
else
view.prompt = "Unknown state: " + game.state
- if (states[game.state])
if (!states[game.state].disable_negotiation) {
view.actions.ask_resources = 1
if (game.resources[game.current] > 0)
view.actions.transfer_resources = 1
else
view.actions.transfer_resources = 0
- if (game.cavalry[game.current] > 0)
+ if (n_cavalry(game.current) > 0)
view.actions.transfer_cavalry = 1
else
view.actions.transfer_cavalry = 0
- if (true) // TODO: can_ask_cavalry()
+ if (can_ask_cavalry())
view.actions.ask_cavalry = 1
else
view.actions.ask_cavalry = 0
@@ -612,7 +611,7 @@ function is_timurid() {
/* STATES */
states.eligible = {
- disable_negotiation: true,
+ disable_negotiation: false,
inactive: "Eligible Faction",
prompt() {
if (!did_option(SOP_COMMAND_DECREE) && !did_option(SOP_EVENT_OR_COMMAND)) {
@@ -3333,6 +3332,10 @@ function gen_action_token(t) {
gen_action("token", t)
}
+function gen_action_faction(f) {
+ gen_action("space", 17+f)
+}
+
function gen_choose_faction(faction) {
if (game.current === faction) {
switch (faction) {
@@ -3472,6 +3475,10 @@ states.transfer_resources = {
},
}
+function can_ask_cavalry() {
+ return game.cavalry.some(c => ![-1, game.current].includes(c))
+}
+
function action_ask_cavalry() {
push_undo()
game.transfer = {
@@ -3530,6 +3537,48 @@ states.give_cavalry = {
},
}
+function action_transfer_cavalry() {
+ push_undo()
+ game.transfer = {
+ current: game.current,
+ state: game.state,
+ count: null
+ }
+ game.state = "transfer_cavalry"
+}
+
+states.transfer_cavalry = {
+ disable_negotiation: true,
+ prompt() {
+ view.prompt = "Transfer Cavalry tokens to another faction."
+ if (n_cavalry(game.current) >= 1) {
+ if (!is_player_ds())
+ gen_action_faction(DS)
+ if (!is_player_bk())
+ gen_action_faction(BK)
+ if (!is_player_ve())
+ gen_action_faction(VE)
+ }
+ if (game.transfer.count)
+ view.actions.done = 1
+ else
+ view.actions.done = 0
+ },
+ space(s) {
+ let to = s - 17
+ if (!game.transfer.count)
+ game.transfer.count = [0, 0, 0]
+ let c = find_cavalry(game.current)
+ game.transfer.count[to]++
+ set_cavalry_faction(c, to)
+ },
+ done() {
+ for (let i = 0; i < 3; ++i)
+ if (game.transfer.count[i] > 0)
+ log_transfer_cavalry(game.current, i, game.transfer.count[i])
+ end_negotiation()
+ },
+}
function end_negotiation() {
game.current = game.transfer.current