summaryrefslogtreecommitdiff
path: root/play.js
diff options
context:
space:
mode:
authoriainp5 <iain.pearce.ip@gmail.com>2024-09-29 13:38:09 +0100
committeriainp5 <iain.pearce.ip@gmail.com>2024-09-29 13:38:09 +0100
commit1f47dc63b4aaf7f52334d702ae2de8dc69fcf2ee (patch)
treecc14bb13518cc8e70ad045c082e2d15e34a4d4a7 /play.js
parent794f1b8e6d6cb7d58c3036241e2bd355bc55ece6 (diff)
download1989-dawn-of-freedom-1f47dc63b4aaf7f52334d702ae2de8dc69fcf2ee.tar.gz
Carry changes to play.js
Diffstat (limited to 'play.js')
-rw-r--r--play.js29
1 files changed, 16 insertions, 13 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}
}