From 603f2cb1e9784b38d03b7ddf925d0a0d46eacee8 Mon Sep 17 00:00:00 2001 From: iainp5 Date: Wed, 26 Jun 2024 21:25:07 +0100 Subject: Initial commit --- rules.js | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 rules.js diff --git a/rules.js b/rules.js new file mode 100644 index 0000000..4b6c57d --- /dev/null +++ b/rules.js @@ -0,0 +1,83 @@ +"use strict" + +var game, view, states = {} + +const data = require("./data.js") + +const DEM = "Democrat" +const COM = "Communist" + +const first_strategy_card = 1 +const last_strategy_card = 110 /* to check! */ + +exports.scenarios = [ "Standard" ] + +exports.roles = [ DEM, COM ] + + +// --- SET UP --- + +exports.setup = function (seed, scenario, options) { + game = { + seed: seed, + log: [], + undo: [], + active: null, + state: null, + + selected_cards: [], + + turn: 0, + round: 0, + + strategy_deck: [], + strategy_discard: [], + states_draw: [], + + draw_deck: [], + democrat_hand: [], + communist_hand: [], + democrat_set_aside: [], + + } + + log_h1("1989 Dawn of Freedom") + setup_game() + game.active = COM + start_turn() + return game +} + +function setup_game() { + // init card desks & shuffle + +} + + +function init_player_cards(first_card) { + let c = first_card + let deck = [] + + for (let n = 0; n < era_cards_count; ++n) + deck.push(++c) + + shuffle(deck) + + return deck +} + + + + + + +function shuffle(list) { + // Fisher-Yates shuffle + for (let i = list.length - 1; i > 0; --i) { + let j = random(i + 1) + let tmp = list[j] + list[j] = list[i] + list[i] = tmp + } + return list +} \ No newline at end of file -- cgit v1.2.3