summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriainp5 <iain.pearce.ip@gmail.com>2024-11-12 17:50:16 +0000
committeriainp5 <iain.pearce.ip@gmail.com>2024-11-12 17:50:16 +0000
commit05e3bce5f852bd18b470e9b1bdc9e10ee0e8ef89 (patch)
treebd19c366204b031a3ffe141645020e82d888ab12
parent8a420102f020d35d41b3b40023db9a5641e88ffe (diff)
download1989-dawn-of-freedom-05e3bce5f852bd18b470e9b1bdc9e10ee0e8ef89.tar.gz
Simplifying code
-rw-r--r--rules.js28
1 files changed, 10 insertions, 18 deletions
diff --git a/rules.js b/rules.js
index 0e5ce04..76627f0 100644
--- a/rules.js
+++ b/rules.js
@@ -2361,7 +2361,6 @@ function valid_spaces_infl() {
let space = spaces[i]
let player_influence = game.active === COM ? game.comInfl[i] : game.demInfl[i];
-
// If the piece has the player's influence, add it and its adjacent spaces to the set
if (player_influence > 0) {
valid_spaces_set.add(space.space_id);
@@ -2440,24 +2439,20 @@ function do_valid_cards() {
valid_cards(game.com_pwr_hand, presence.com_leaders)}
}
-function count_adj(id) {
- const space = spaces[id]
+function count_adj(space_id) {
let dem_adj = 0
let com_adj = 0
- let adjacent_spaces = get_adjusted_adjacency(space.space_id)
+ let adjacent_spaces = get_adjusted_adjacency(space_id)
for (let adj_space_id of adjacent_spaces) {
- const adj_piece = spaces.find(piece => piece.space_id === adj_space_id);
- if (adj_piece.space_id !== space.space_id) {
- if (check_dem_control(adj_piece.space_id)) {
- dem_adj++
- }
- if (check_com_control(adj_piece.space_id)) {
- com_adj++
- }
- }
- }
+ if (check_dem_control(adj_space_id)) {
+ dem_adj++
+ }
+ if (check_com_control(adj_space_id)) {
+ com_adj++
+ }
+ }
return {dem_adj, com_adj}
}
@@ -4301,10 +4296,7 @@ function vm_valid_spaces_solidarity_legalised() {
}
function vm_active_country () {
- game.valid_spaces = game.valid_spaces.filter(space_id => {
- let space = spaces.find(s => s && s.space_id === space_id);
- return space && space.country === game.vm_active_country;
- });
+ game.valid_spaces = game.valid_spaces.filter(space_id => spaces[space_id].country === game.vm_active_country)
vm_next()
}