summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrans Bongers <fransbongers@franss-mbp.home>2024-12-02 22:03:02 +0100
committerFrans Bongers <fransbongers@franss-mbp.home>2024-12-02 22:03:02 +0100
commit0341a2e6c13d2b6e401cff21cc51d11d248ddb6e (patch)
tree6300da57ea2fd5709c9856d9080736599dd964b3
parent48726dd19ad8dde11a6172f30b5071987b7d09b5 (diff)
downloadland-and-freedom-0341a2e6c13d2b6e401cff21cc51d11d248ddb6e.tar.gz
resolve icons
-rw-r--r--play.js15
-rw-r--r--play.ts18
-rw-r--r--rules.js69
-rw-r--r--rules.ts86
4 files changed, 182 insertions, 6 deletions
diff --git a/play.js b/play.js
index 7607bc4..c4e15ac 100644
--- a/play.js
+++ b/play.js
@@ -249,11 +249,24 @@ function on_update() {
}
for (let e of action_register)
e.classList.toggle('action', is_action(e.my_action, e.my_id));
+ action_button('add_to_front', '+1 to a Front');
+ action_button('soviet_support', 'Soviet Support');
+ action_button('collectivization', 'Collectivization');
+ action_button('d_liberty', 'Decrease Liberty');
+ action_button('d_collectivization', 'Decrease Collectivization');
+ action_button('d_foreign_aid', 'Decrease Foreign Aid');
+ action_button('d_government', 'Decrease Government');
+ action_button('d_soviet_support', 'Decrease Soviet Support');
+ action_button('draw_card', 'Draw a Card');
+ action_button('foreign_aid', 'Foreign Aid');
+ action_button('government', 'Government');
+ action_button('liberty', 'Liberty');
+ action_button('government_to_center', 'Government towards center');
+ action_button('teamwork_on', 'Teamwork Bonus On');
action_button('Anarchist', 'Anarchist');
action_button('Communist', 'Communist');
action_button('Moderate', 'Moderate');
action_button('gain_hp', 'Gain Hero Points');
- action_button('draw_card', 'Draw card');
action_button('play_for_ap', 'Play card for Action Points');
action_button('play_for_event', 'Play card for Event');
action_button('spend_hp', 'Spend Hero Points');
diff --git a/play.ts b/play.ts
index 36d64e5..c8ffe93 100644
--- a/play.ts
+++ b/play.ts
@@ -315,11 +315,27 @@ function on_update() {
for (let e of action_register)
e.classList.toggle('action', is_action(e.my_action, e.my_id));
+ action_button('add_to_front', '+1 to a Front');
+ action_button('soviet_support', 'Soviet Support');
+ action_button('collectivization', 'Collectivization');
+ action_button('d_liberty', 'Decrease Liberty');
+ action_button('d_collectivization', 'Decrease Collectivization');
+ action_button('d_foreign_aid', 'Decrease Foreign Aid');
+ action_button('d_government', 'Decrease Government');
+
+ action_button('d_soviet_support', 'Decrease Soviet Support');
+ action_button('draw_card', 'Draw a Card');
+ action_button('foreign_aid', 'Foreign Aid');
+ action_button('government', 'Government');
+ action_button('liberty', 'Liberty');
+ action_button('government_to_center', 'Government towards center');
+
+ action_button('teamwork_on', 'Teamwork Bonus On');
action_button('Anarchist', 'Anarchist');
action_button('Communist', 'Communist');
action_button('Moderate', 'Moderate');
action_button('gain_hp', 'Gain Hero Points');
- action_button('draw_card', 'Draw card');
+ // action_button('draw_card', 'Draw card');
action_button('play_for_ap', 'Play card for Action Points');
action_button('play_for_event', 'Play card for Event');
action_button('spend_hp', 'Spend Hero Points');
diff --git a/rules.js b/rules.js
index 8dc2b2e..5a5445b 100644
--- a/rules.js
+++ b/rules.js
@@ -348,7 +348,62 @@ states.activate_icon = {
inactive: 'activate an icon',
prompt() {
view.prompt = 'Choose an icon to activate';
- }
+ const c = cards[game.chosen_cards[get_active_faction_id()]];
+ for (const i of c.icons) {
+ gen_action(i);
+ }
+ },
+ add_to_front() {
+ resolve_active_and_proceed();
+ },
+ collectivization() {
+ move_track(data_1.COLLECTIVIZATION, get_icon_count_in_tableau('collectivization'));
+ resolve_active_and_proceed();
+ },
+ d_collectivization() {
+ move_track(data_1.COLLECTIVIZATION, -1 * get_icon_count_in_tableau('d_collectivization'));
+ resolve_active_and_proceed();
+ },
+ d_foreign_aid() {
+ move_track(data_1.FOREIGN_AID, -1 * get_icon_count_in_tableau('d_foreign_aid'));
+ resolve_active_and_proceed();
+ },
+ d_government() {
+ move_track(data_1.GOVERNMENT, -1 * get_icon_count_in_tableau('d_government'));
+ resolve_active_and_proceed();
+ },
+ d_liberty() {
+ move_track(data_1.LIBERTY, -1 * get_icon_count_in_tableau('d_liberty'));
+ resolve_active_and_proceed();
+ },
+ d_soviet_support() {
+ move_track(data_1.SOVIET_SUPPORT, -1 * get_icon_count_in_tableau('d_soviet_support'));
+ resolve_active_and_proceed();
+ },
+ draw_card() {
+ resolve_active_and_proceed();
+ },
+ foreign_aid() {
+ move_track(data_1.FOREIGN_AID, get_icon_count_in_tableau('foreign_aid'));
+ resolve_active_and_proceed();
+ },
+ government() {
+ move_track(data_1.GOVERNMENT, get_icon_count_in_tableau('government'));
+ resolve_active_and_proceed();
+ },
+ government_to_center() { },
+ liberty() {
+ move_track(data_1.LIBERTY, get_icon_count_in_tableau('liberty'));
+ resolve_active_and_proceed();
+ },
+ soviet_support() {
+ move_track(data_1.SOVIET_SUPPORT, get_icon_count_in_tableau('soviet_support'));
+ resolve_active_and_proceed();
+ },
+ teamwork_on() {
+ game.bonuses[data_1.TEAMWORK_BONUS] = data_1.ON;
+ resolve_active_and_proceed();
+ },
};
states.add_glory = {
inactive: 'add tokens to the Bag of Glory',
@@ -820,6 +875,18 @@ function get_active_faction_id() {
function get_faction_id(player) {
return player_faction_map[player];
}
+function get_icon_count_in_tableau(icon, faction = get_active_faction_id()) {
+ let count = 0;
+ for (const c of game.tableaus[faction]) {
+ const card = cards[c];
+ for (const i of card.icons) {
+ if (i === icon) {
+ ++count;
+ }
+ }
+ }
+ return count;
+}
function get_player(faction_id) {
return faction_player_map[faction_id];
}
diff --git a/rules.ts b/rules.ts
index e5206bd..51666c3 100644
--- a/rules.ts
+++ b/rules.ts
@@ -8,6 +8,7 @@ import {
FactionId,
FunctionNode,
Game,
+ Icon,
LeafNode,
Player,
PlayerCard,
@@ -530,9 +531,72 @@ function start_turn() {
states.activate_icon = {
inactive: 'activate an icon',
prompt() {
- view.prompt = 'Choose an icon to activate'
- }
-}
+ view.prompt = 'Choose an icon to activate';
+ const c = cards[game.chosen_cards[get_active_faction_id()]] as PlayerCard;
+ for (const i of c.icons) {
+ gen_action(i);
+ }
+ },
+ add_to_front() {
+ // insert state to select front
+ resolve_active_and_proceed();
+ },
+ collectivization() {
+ move_track(COLLECTIVIZATION, get_icon_count_in_tableau('collectivization'));
+ resolve_active_and_proceed();
+ },
+ d_collectivization() {
+ move_track(
+ COLLECTIVIZATION,
+ -1 * get_icon_count_in_tableau('d_collectivization')
+ );
+ resolve_active_and_proceed();
+ },
+ d_foreign_aid() {
+ move_track(FOREIGN_AID, -1 * get_icon_count_in_tableau('d_foreign_aid'));
+ resolve_active_and_proceed();
+ },
+ d_government() {
+ move_track(GOVERNMENT, -1 * get_icon_count_in_tableau('d_government'));
+ resolve_active_and_proceed();
+ },
+ d_liberty() {
+ move_track(LIBERTY, -1 * get_icon_count_in_tableau('d_liberty'));
+ resolve_active_and_proceed();
+ },
+ d_soviet_support() {
+ move_track(
+ SOVIET_SUPPORT,
+ -1 * get_icon_count_in_tableau('d_soviet_support')
+ );
+ resolve_active_and_proceed();
+ },
+ draw_card() {
+ // TODO: draw cards
+ resolve_active_and_proceed();
+ },
+ foreign_aid() {
+ move_track(FOREIGN_AID, get_icon_count_in_tableau('foreign_aid'));
+ resolve_active_and_proceed();
+ },
+ government() {
+ move_track(GOVERNMENT, get_icon_count_in_tableau('government'));
+ resolve_active_and_proceed();
+ },
+ government_to_center() {},
+ liberty() {
+ move_track(LIBERTY, get_icon_count_in_tableau('liberty'));
+ resolve_active_and_proceed();
+ },
+ soviet_support() {
+ move_track(SOVIET_SUPPORT, get_icon_count_in_tableau('soviet_support'));
+ resolve_active_and_proceed();
+ },
+ teamwork_on() {
+ game.bonuses[TEAMWORK_BONUS] = ON;
+ resolve_active_and_proceed();
+ },
+};
states.add_glory = {
inactive: 'add tokens to the Bag of Glory',
@@ -1275,6 +1339,22 @@ function get_faction_id(player: Player): FactionId {
return player_faction_map[player];
}
+function get_icon_count_in_tableau(
+ icon: Icon,
+ faction: FactionId = get_active_faction_id()
+) {
+ let count = 0;
+ for (const c of game.tableaus[faction]) {
+ const card = cards[c] as PlayerCard;
+ for (const i of card.icons) {
+ if (i === icon) {
+ ++count;
+ }
+ }
+ }
+ return count;
+}
+
function get_player(faction_id: FactionId) {
return faction_player_map[faction_id];
}