summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--play.js29
-rw-r--r--rules.js7
2 files changed, 20 insertions, 16 deletions
diff --git a/play.js b/play.js
index e2a5dc8..3c0e71d 100644
--- a/play.js
+++ b/play.js
@@ -299,10 +299,13 @@ function on_update() {
});
//Check influence values
- const pieces = view.pieces
- pieces.forEach((piece, index) => {
- if (!piece) return
- const space = spaces[index]
+ //const pieces = view.pieces
+
+ for (let i = 1; spaces.length; i ++) {
+
+ const space = spaces[i]
+ const demInfl = view.demInfl[i]
+ const comInfl = view.comInfl[i]
//console.log('piece', piece)
//console.log('space', space)
const dem_marker = document.getElementById(`${space.name_unique}_demInfl`);
@@ -311,11 +314,11 @@ function on_update() {
const com_number = document.getElementById(`${space.name_unique}_comInflValue`);
dem_number.innerText=piece.demInfl
- if (piece.demInfl > 0) {
+ if (demInfl > 0) {
dem_marker.style.display = 'block';
dem_number.style.display = 'block';
- if(check_dem_control(piece, space)){
+ if(check_dem_control(demInfl, comInfl, space)){
dem_marker.classList.add('controlled')
dem_number.classList.add('outlined_text')
dem_marker.classList.remove('uncontrolled')
@@ -329,11 +332,11 @@ function on_update() {
dem_number.style.display = 'none';
}
com_number.innerText=piece.comInfl
- if (piece.comInfl > 0) {
+ if (comInfl > 0) {
com_marker.style.display = 'block';
com_number.style.display = 'block';
- if(check_com_control(piece, space)){
+ if(check_com_control(demInfl, comInfl, space)){
com_marker.classList.add('controlled')
com_number.classList.add('controlled')
com_marker.classList.remove('uncontrolled')
@@ -349,7 +352,7 @@ function on_update() {
com_number.style.display = 'none';
}
- });
+ }
// UPDATE COUNTRY MARKERS
for (let i = 1; i < countries.length; i++) {
@@ -688,14 +691,14 @@ function toggle_discard() {
document.getElementById("discard_panel").classList.toggle("hide")
}
-function check_dem_control(piece, space) {
- if ((piece.demInfl - piece.comInfl) >= space.stability) {
+function check_dem_control(demInfl, comInfl, space) {
+ if ((demInfl - comInfl) >= space.stability) {
return true
} else{ false}
}
-function check_com_control(piece, space) {
- if ((piece.comInfl - piece.demInfl) >= space.stability) {
+function check_com_control(demInfl, comInfl, space) {
+ if ((comInfl - demInfl) >= space.stability) {
return true
} else{ false}
}
diff --git a/rules.js b/rules.js
index 1b8b52a..f2f7b51 100644
--- a/rules.js
+++ b/rules.js
@@ -77,7 +77,8 @@ exports.setup = function (seed, scenario, options) {
tst_8: false,
vp: 0,
- pieces: [null],
+ demInfl: spaces.demInfl,
+ comInfl: spaces.comInfl,
strategy_deck: [],
strategy_discard: [],
@@ -163,8 +164,8 @@ exports.view = function(state, player) {
valid_spaces: game.valid_spaces,
valid_cards: game.valid_cards,
- demInfl: spaces.demInfl,
- comInfl: spaces.comInfl,
+ demInfl: game.demInfl,
+ comInfl: game.comInfl,
turn: game.turn,
round: game.round,
round_player: game.round_player,