diff options
Diffstat (limited to 'play.js')
-rw-r--r-- | play.js | 136 |
1 files changed, 71 insertions, 65 deletions
@@ -1,7 +1,8 @@ -const dem = 0
-const com = 1
-const dem_name= "Democrat"
-const com_name= "Communist"
+const seed = 'none'
+const scenario = 'standard'
+const options = 'none'
+//const rules = require("./rules")
+
const stability=0
const US_tiananmen=0
const USSR_tiananmen=0
@@ -33,7 +34,6 @@ let czechHeld=0 let hungaryHeld=0
let romaniaHeld=0
let bulgariaHeld=0
-let presidentialVisit=0
const countryNames= [
@@ -60,81 +60,66 @@ const spaceCharacteristicsElement = document.getElementById('space-characteristi })
+// Call game setup material
- // Create map areas dynamically based on coordinates
+// const game = rules.setup(seed, scenario, options)
+ // Create map areas dynamically based on coordinates
function createMap() {
- mapContainer.querySelectorAll('.space-area').forEach(spaceArea => {
- spaceArea.remove()
- })
spaces.forEach((space) => {
if (space && space.box) {
- const { x, y, h, w } = space.box;
- const spaceArea = document.createElement('div');
- spaceArea.classList.add('space-area', space.country)
- spaceArea.id=space.name;
- spaceArea.style.left = x + 'px';
- spaceArea.style.top = y + 'px';
- spaceArea.style.width = w + 'px';
- spaceArea.style.height = h + 'px';
- spaceArea.addEventListener('click', changeInfl)
- spaceArea.addEventListener('click', finishSupportCheck)
- spaceArea.querySelectorAll('img').forEach(img => {
- img.remove();
- });
- spaceArea.querySelectorAll('p').forEach(p => {
- p.remove();
- });
-
- if (space.demInfl > 0 && space.demInfl - space.comInfl >= space.stability) {
+ const { x, y, h, w } = space.box;
+ const spaceArea = document.createElement('div');
+ spaceArea.classList.add('space-area', space.country)
+ spaceArea.id=space.name;
+ spaceArea.style.left = x + 'px';
+ spaceArea.style.top = y + 'px';
+ spaceArea.style.width = w + 'px';
+ spaceArea.style.height = h + 'px';
+ spaceArea.addEventListener('click', changeInfl)
+ spaceArea.addEventListener('click', finishSupportCheck)
+
+ /*if (space.demInfl > 0 && space.demInfl - space.comInfl >= space.stability) {
const img = document.createElement('img')
img.classList.add('demInfl', space.country)
img.id=space.name
img.src = `images/US_${space.demInfl}.gif`
spaceArea.appendChild(img)
- } else if (space.demInfl > 0) {
- const img = document.createElement('img')
- img.classList.add('demInfl', space.country)
- img.id=space.name
- img.src = `images/USd_blank.gif`
- spaceArea.appendChild(img)
+ } else if (space.demInfl > 0) {*/
+ const dem_img = document.createElement('img')
+ dem_img.classList.add('demInfl', space.country)
+ dem_img.id=space.name
+ dem_img.src = `images/USd_blank.gif`
+ spaceArea.appendChild(dem_img)
const demInflValue = document.createElement('p')
demInflValue.className='demInflValue'
demInflValue.id=space.name
demInflValue.innerText=space.demInfl
spaceArea.appendChild(demInflValue)
- }
-
- spaceArea.querySelectorAll('img.comInfl').forEach(img => {
- img.remove(); })
+ //}
- if (space.comInfl === 0) {
-
- spaceArea.querySelectorAll('img.comInfl').forEach(img => {
- img.remove(); })
-
- } else if (space.comInfl > 0 && space.comInfl - space.demInfl >= space.stability) {
+ /*} else if (space.comInfl > 0 && space.comInfl - space.demInfl >= space.stability) {
const img = document.createElement('img')
img.className='comInfl'
img.id=space.name
img.src = `images/SV_${space.comInfl}.gif`
spaceArea.appendChild(img)
- } else if (space.comInfl > 0) {
- const img = document.createElement('img')
- img.className='comInfl'
- img.id=space.name
- img.src = `images/SVd_blank.gif`
- spaceArea.appendChild(img)
+ } else if (space.comInfl > 0) {*/
+ const com_img = document.createElement('img')
+ com_img.className='comInfl'
+ com_img.id=space.name
+ com_img.src = `images/SVd_blank.gif`
+ spaceArea.appendChild(com_img)
const comInflValue = document.createElement('p')
comInflValue.className='comInflValue'
comInflValue.id=space.name
comInflValue.innerText=space.comInfl
spaceArea.appendChild(comInflValue)
- }
+ //}
mapContainer.appendChild(spaceArea);
}
@@ -142,17 +127,23 @@ function createMap() { }
+createMap()
+console.log('Hello')
+console.log(game)
+function changeInfl() {}
+function finishSupportCheck() {}
-/* Create hands */
+
+/* Create hands
const handLimit = 8;
-const comHandLimit = 8 + presidentialVisit;
+const comHandLimit = 8; //Will be needed for Presidential Visit
const hand =[];
const discard =[];
-/* Step 1 create a draw deck */
+/* Step 1 create a draw deck
const deck = cards
.filter(card => card.period === 1)
@@ -174,13 +165,23 @@ drawCards(deck, handLimit); function displayHand(hand) {
const handDiv = document.getElementById('hand');
hand.forEach(card => {
- const img = document.createElement('img')
- img.src = `cards/e${card}.gif`
- img.className='handCard'
- img.alt = `Card ${card}`
- img.addEventListener('click', playCard)
- handDiv.appendChild(img)
- })
+ if (card < 100) {
+ const img = document.createElement('img')
+ img.src = `cards/e${card}.gif`
+ img.className='handCard'
+ img.alt = `Card ${card}`
+ img.addEventListener('click', playCard)
+ handDiv.appendChild(img)
+ }
+ else {
+ const img = document.createElement('img')
+ img.src = `cards2/e${card}.gif`
+ img.className='handCard'
+ img.alt = `Card ${card}`
+ img.addEventListener('click', playCard)
+ handDiv.appendChild(img)
+ }
+ })
}
@@ -195,7 +196,7 @@ displayHand(hand); -/*---------- INITIALIZE GAME ---------------*/
+/*---------- INITIALIZE GAME ---------------
function startNewRound() {
toolbar.querySelectorAll('button').forEach(button => {
@@ -215,7 +216,7 @@ function startNewRound() { function playCard(event) {
if (handActive===1) {
-/* Update the toolbar */
+/* Update the toolbar
toolbar.querySelectorAll('button').forEach(button => {
button.remove();
});
@@ -251,7 +252,7 @@ function playCard(event) { buttonPoland.onclick = scorePoland;
toolbar.appendChild(buttonPoland);
-/* Update the hand */
+/* Update the hand
const getLink = event.target.src;
const match = getLink.match(/\/e(\d+)\.gif$/);
const playedCard = parseInt(match[1]);
@@ -276,7 +277,12 @@ function playCard(event) { const eventPanel = document.getElementById('events');
const activeCard = document.createElement('img')
- activeCard.src = `cards/e${playedCard}.gif`
+
+ if (playedCard<100) {
+ activeCard.src = `cards/e${playedCard}.gif`
+ } else {
+ activeCard.src = `cards2/e${playedCard}.gif`
+ }
activeCard.className='playedCard'
activeCard.alt = `Card ${playedCard}`
eventPanel.appendChild(activeCard)
@@ -578,4 +584,4 @@ function isNegativeAndOdd(number) { }
startNewRound()
-
+*/
|