diff options
author | Tor Andersson <tor@ccxvii.net> | 2022-02-06 16:06:16 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2023-02-18 11:54:52 +0100 |
commit | 544a20b11f464df10a07c4d9cf9185fe69f8deb9 (patch) | |
tree | 63b4b41098dd88f96769436264aacfecfb5b1e4e /rules.js | |
parent | bcfab31d9779c45717d23a3b2228357c3acc4644 (diff) | |
download | wilderness-war-544a20b11f464df10a07c4d9cf9185fe69f8deb9.tar.gz |
Update VP when taking/losing fortresses.
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 39 |
1 files changed, 33 insertions, 6 deletions
@@ -1495,18 +1495,28 @@ function find_enemy_commanding_leader_in_space(space) { // GAME STATE CHANGE HELPERS -function award_vp(n) { +function log_vp(n) { if (game.active === FRANCE) { if (n < 0) log(`France loses ${-n} VP.`); else log(`France gains ${n} VP.`); - game.tracks.vp += n; } else { if (n < 0) - log(`Britain loses ${-n} VP.`); + log(`Britain gains ${-n} VP.`); else - log(`Britain gains ${n} VP.`); + log(`Britain loses ${n} VP.`); + } +} + +function award_vp(n) { + if (game.active === FRANCE) { + log_vp(n); + game.tracks.gvp += n; + game.tracks.vp += n; + } else { + log_vp(-n); + game.tracks.gvp -= n; game.tracks.vp -= n; } } @@ -1696,7 +1706,7 @@ function is_vacant_of_besieging_units(space) { } function lift_sieges_and_amphib() { - console.log("LIFT SIEGES AND AMPHIB"); + console.log("LIFT SIEGES AND AMPHIB AND RECALC VP"); for_each_siege(space => { if (is_vacant_of_besieging_units(space)) { @@ -1718,6 +1728,20 @@ function lift_sieges_and_amphib() { } } } + + update_vp(); +} + +function update_vp() { + let save_vp = game.tracks.vp; + game.tracks.vp = game.tracks.gvp - 6; + for (let i = 0; i < fortresses.length; ++i) { + let s = fortresses[i]; + if (is_french_controlled_space(s)) + game.tracks.vp += 2; + } + if (game.tracks.vp != save_vp) + log_vp(game.tracks.vp - save_vp); } // PATH FINDING @@ -6889,6 +6913,7 @@ function setup_1757(end_year) { game.tracks.end_year = end_year; game.tracks.season = EARLY; game.tracks.vp = 4; + game.tracks.gvp = 4; game.tracks.pa = SUPPORTIVE; // TODO: optional rule start at 2VP for balance @@ -7061,6 +7086,7 @@ function setup_1755() { game.tracks.year = 1755; game.tracks.season = EARLY; game.tracks.vp = 0; + game.tracks.gvp = 0; game.tracks.pa = SUPPORTIVE; for (let i = 1; i <= 70; ++i) @@ -7195,7 +7221,8 @@ exports.setup = function (seed, scenario, options) { year: 1755, end_year: 1762, season: 0, - vp: 0, + gvp: 0, // gained vp + vp: 0, // fortress vp + gained vp pa: 0, }, events: {}, |