diff options
Diffstat (limited to 'play.js')
-rw-r--r-- | play.js | 29 |
1 files changed, 16 insertions, 13 deletions
@@ -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}
}
|