summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js44
1 files changed, 20 insertions, 24 deletions
diff --git a/rules.js b/rules.js
index 9cbda76..3f1c52c 100644
--- a/rules.js
+++ b/rules.js
@@ -9,6 +9,7 @@ const OBSERVER = 'Observer';
const states = {};
let game = {};
var view = {};
+const POOL_ID = 3;
const role_ids = [data_1.ANARCHISTS_ID, data_1.COMMUNISTS_ID, data_1.MODERATES_ID];
const faction_player_map = [
data_1.ANARCHIST,
@@ -31,11 +32,12 @@ const front_names = [
const bonus_names = ['Morale Bonus', 'Teamwork Bonus'];
const { cards, medallions, tracks, } = data_1.default;
const bonuses = [data_1.MORALE_BONUS, data_1.TEAMWORK_BONUS];
-const faction_cards = {
- [data_1.ANARCHISTS_ID]: make_list(37, 54),
- [data_1.COMMUNISTS_ID]: make_list(19, 36),
- [data_1.MODERATES_ID]: make_list(1, 18),
-};
+const faction_cards = [
+ make_list(37, 54),
+ make_list(19, 36),
+ make_list(1, 18),
+];
+console.log(faction_cards);
const fascist_decks = {
1: make_list(55, 72),
2: make_list(73, 90),
@@ -439,15 +441,9 @@ function setup(seed, _scenario, options) {
[],
[],
],
- hero_points: {
- factions: [2, 2, 0],
- pool: 14
- },
+ hero_points: [2, 2, 0, 14],
initiative: data_1.MODERATES_ID,
- medallions: {
- factions: [[], [], []],
- pool: [],
- },
+ medallions: [[], [], [], []],
played_card: null,
player_order: [data_1.MODERATE],
selected_cards: [
@@ -1078,10 +1074,10 @@ states.choose_medallion = {
prompt() {
gen_spend_hero_points();
view.prompt = 'Earn a Medallion.';
- for (let m of game.medallions.pool) {
+ for (let m of game.medallions[POOL_ID]) {
gen_action_medallion(m);
}
- if (!game.medallions.pool.some((m) => m !== null)) {
+ if (!game.medallions[POOL_ID].some((m) => m !== null)) {
gen_action('skip');
}
},
@@ -1092,8 +1088,8 @@ states.choose_medallion = {
const faction = get_active_faction();
const medallion = medallions[m];
logp(`earned ${medallion.name}`);
- const index = game.medallions.pool.indexOf(m);
- game.medallions.pool[index] = null;
+ const index = game.medallions[POOL_ID].indexOf(m);
+ game.medallions[POOL_ID][index] = null;
switch (m) {
case 0:
add_glory(faction, 1);
@@ -1254,7 +1250,7 @@ states.hero_points = {
gen_action('lose_hp');
return;
}
- if (game.hero_points.pool > 0) {
+ if (game.hero_points[POOL_ID] > 0) {
view.prompt =
value > 1 ? `Fascist Test: Gain ${value} Hero points.` : 'Fascist Test: Gain 1 Hero point.';
gen_action('gain_hp');
@@ -2244,7 +2240,7 @@ function gain_hero_points_in_player_order(factions, value) {
}
}
function gain_hero_points(faction_id, value, skip_abilities = false) {
- if (game.hero_points.pool === 0) {
+ if (game.hero_points[POOL_ID] === 0) {
return;
}
if (!skip_abilities &&
@@ -2259,8 +2255,8 @@ function gain_hero_points(faction_id, value, skip_abilities = false) {
value++;
game.active_abilities = (game.active_abilities || []).filter((ability) => ability !== data_1.COMMUNIST_EXTRA_HERO_POINT);
}
- const gain = Math.min(game.hero_points.pool, value);
- game.hero_points.pool -= gain;
+ const gain = Math.min(game.hero_points[POOL_ID], value);
+ game.hero_points[POOL_ID] -= gain;
game.hero_points[faction_id] += gain;
logi(`${get_player(faction_id)} +${gain} HP`);
}
@@ -2472,7 +2468,7 @@ function move_track_to(track_id, new_value) {
}
function pay_hero_points(faction, amount) {
game.hero_points[faction] -= amount;
- game.hero_points.pool += amount;
+ game.hero_points[POOL_ID] += amount;
}
function can_use_medallion(medallion_id, faction) {
faction = faction === undefined ? get_active_faction() : faction;
@@ -2725,7 +2721,7 @@ function draw_fascist_card() {
}
function lose_hero_points(faction, value) {
const points_lost = Math.min(game.hero_points[faction], Math.abs(value));
- game.hero_points.pool += points_lost;
+ game.hero_points[POOL_ID] += points_lost;
game.hero_points[faction] -= points_lost;
if (points_lost !== 0)
logi(`${get_player(faction)} -${points_lost} HP`);
@@ -2952,7 +2948,7 @@ function draw_medallions() {
let i = random(medallion_ids.length);
let r = medallion_ids[i];
set_delete(medallion_ids, r);
- game.medallions.pool.push(r);
+ game.medallions[POOL_ID].push(r);
logi("M" + r);
}
}