summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2022-03-05 13:31:53 +0100
committerTor Andersson <tor@ccxvii.net>2023-02-18 11:54:52 +0100
commita536aa7800d8f97588925f1efd6f64cc4d18d0d7 (patch)
treef7158d0fefdc0d2836d18a59d2badc4f93da939d /rules.js
parent345d8eae6f1255e704350e38297461a430e92a83 (diff)
downloadwilderness-war-a536aa7800d8f97588925f1efd6f64cc4d18d0d7.tar.gz
Use query/reply to show supply lines, discard, and removed card lists.
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js48
1 files changed, 27 insertions, 21 deletions
diff --git a/rules.js b/rules.js
index 2903c76..2438149 100644
--- a/rules.js
+++ b/rules.js
@@ -1832,25 +1832,6 @@ function search_supply_spaces() {
}
}
-function goto_debug_supply(role) {
- if (game.state === 'debug_supply') {
- pop_undo();
- } else {
- push_undo();
- set_active(role);
- game.state = 'debug_supply';
- }
-}
-
-states.debug_supply = {
- prompt() {
- search_supply_spaces();
- view.prompt = "Showing supply lines.";
- supply_cache.forEach(gen_action_space);
- },
- space: pop_undo
-}
-
function is_in_supply(from) {
if (game.active === BRITAIN && has_amphib(from))
return true;
@@ -1866,6 +1847,17 @@ function is_in_supply(from) {
return x;
}
+function query_supply() {
+ let reply = {};
+ set_active(BRITAIN);
+ search_supply_spaces();
+ reply.british = supply_cache;
+ set_active(FRANCE);
+ search_supply_spaces();
+ reply.french = supply_cache;
+ return reply;
+}
+
// CLOSEST PATH SEARCH
function find_closest_friendly_unbesieged_fortification(start) {
@@ -8671,6 +8663,22 @@ exports.action = function (state, current, action, arg) {
return game;
}
+exports.query = function (state, current, q, params) {
+ if (q === 'supply') {
+ load_game_state(state, current);
+ return query_supply();
+ }
+ if (q === 'discard') {
+ load_game_state(state, current);
+ return game.discard;
+ }
+ if (q === 'removed') {
+ load_game_state(state, current);
+ return game.removed;
+ }
+ return null;
+}
+
exports.view = function(state, current) {
load_game_state(state);
view = {
@@ -8683,8 +8691,6 @@ exports.view = function(state, current) {
fieldworks: game.fieldworks,
last_card: game.last_card,
// deck: game.deck.length,
- // discard: game.discard,
- // removed: game.removed,
french: {
hand: game.french.hand.length,
allied: game.french.allied,