summaryrefslogtreecommitdiff
path: root/rules.ts
diff options
context:
space:
mode:
Diffstat (limited to 'rules.ts')
-rw-r--r--rules.ts46
1 files changed, 22 insertions, 24 deletions
diff --git a/rules.ts b/rules.ts
index 2b858c7..0e50af6 100644
--- a/rules.ts
+++ b/rules.ts
@@ -77,6 +77,8 @@ const states = {} as States;
let game = {} as Game; // = null
var view = {} as View; // = null
+const POOL_ID = 3;
+
const role_ids: FactionId[] = [ANARCHISTS_ID, COMMUNISTS_ID, MODERATES_ID];
const faction_player_map: Record<FactionId, Player> = [
@@ -111,11 +113,13 @@ const {
const bonuses = [MORALE_BONUS, TEAMWORK_BONUS];
-const faction_cards = {
- [ANARCHISTS_ID]: make_list(37, 54) as CardId[],
- [COMMUNISTS_ID]: make_list(19, 36) as CardId[],
- [MODERATES_ID]: make_list(1, 18) as CardId[],
-};
+const faction_cards = [
+ make_list(37, 54) as CardId[],
+ make_list(19, 36) as CardId[],
+ make_list(1, 18) as CardId[],
+];
+
+console.log(faction_cards)
const fascist_decks = {
1: make_list(55, 72) as CardId[],
@@ -625,15 +629,9 @@ export function setup(seed: number, _scenario: string, options: Record<string,bo
[],
[],
],
- hero_points: {
- factions: [2, 2, 0],
- pool: 14
- },
+ hero_points: [2, 2, 0, 14],
initiative: MODERATES_ID,
- medallions: {
- factions: [[],[],[]],
- pool: [],
- },
+ medallions: [[],[],[],[]],
played_card: null,
player_order: [MODERATE],
selected_cards: [
@@ -1363,10 +1361,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');
}
},
@@ -1379,9 +1377,9 @@ states.choose_medallion = {
logp(`earned ${medallion.name}`);
- const index = game.medallions.pool.indexOf(m);
+ const index = game.medallions[POOL_ID].indexOf(m);
- game.medallions.pool[index] = null;
+ game.medallions[POOL_ID][index] = null;
switch (m) {
case 0:
@@ -1557,7 +1555,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');
@@ -2778,7 +2776,7 @@ function gain_hero_points(
value: number,
skip_abilities = false // Used to prevent gaining of extra hero points when taking them from another player
) {
- if (game.hero_points.pool === 0) {
+ if (game.hero_points[POOL_ID] === 0) {
return;
}
if (
@@ -2802,8 +2800,8 @@ function gain_hero_points(
(ability) => ability !== 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`);
}
@@ -3070,7 +3068,7 @@ function move_track_to(track_id: number, new_value: number) {
function pay_hero_points(faction: FactionId, amount: number) {
game.hero_points[faction] -= amount;
- game.hero_points.pool += amount;
+ game.hero_points[POOL_ID] += amount;
}
function can_use_medallion(medallion_id: number, faction?: FactionId) {
@@ -3412,7 +3410,7 @@ function draw_fascist_card(): CardId {
function lose_hero_points(faction: FactionId, value: number) {
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`);
@@ -3701,7 +3699,7 @@ function draw_medallions() {
let i = random(medallion_ids.length);
let r = medallion_ids[i] as CardId;
set_delete(medallion_ids, r);
- game.medallions.pool.push(r);
+ game.medallions[POOL_ID].push(r);
logi("M" + r)
}
}