Skip to content

Commit

Permalink
[Fix] Activate the "Dig" button when the zone is really diggable
Browse files Browse the repository at this point in the history
  • Loading branch information
Nadawoo committed Jan 10, 2025
1 parent 48ed878 commit 3634f8e
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 13 deletions.
2 changes: 1 addition & 1 deletion core/view/HtmlActionCards.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function card_building() {
function card_dig() {

return '
<a id="card_dig" class="card animate__animated animate__slideInLeft"
<a id="card_dig" class="hidden card animate__animated animate__slideInLeft"
onclick="toggleActionBlock(\'dig\'); updateBlockAction(\'dig\')">
<img src="/resources/img/copyrighted/pickaxe_48px.png" alt="&#9935;&#65039;" height="48">
La zone peut être fouillée.
Expand Down
2 changes: 1 addition & 1 deletion core/view/HtmlPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class HtmlPage
// Increment those variables when you modify the CSS or JS files. This ensures
// that the users' browsers reload the up-to-date files, instead of using
// the obsolete ones stored in their cache.
private $css_js_version = 56.1;
private $css_js_version = 56.2;

/**
* Sets HTTP headers to secure the website
Expand Down
18 changes: 10 additions & 8 deletions public/resources/js/actionBlocks.func.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ async function updateBlockAction(blockAlias) {
}
else if(blockAlias === "dig") {

let mapId = document.querySelector("#mapId").innerHTML,
myZone = document.querySelector("#me").parentNode.dataset;
updateBlockActionDig(mapId, myZone.coordx, myZone.coordy);
let mapId = Number(document.querySelector("#mapId").innerHTML),
coordX = Number(document.querySelector("#citizenCoordX").innerHTML),
coordY = Number(document.querySelector("#citizenCoordY").innerHTML);
updateBlockActionDig(mapId, coordX, coordY);
}
}

Expand Down Expand Up @@ -291,15 +292,16 @@ async function updateBlockActionDig(mapId, coordX, coordY) {
let block = document.querySelector("#items_ground .items_list");

// Update the data only one time per zone
if(block.dataset.coordx !== coordX || block.dataset.coordy !== coordY
|| block.innerHTML.length === 0) {

if(Number(block.dataset.coordx) !== coordX
|| Number(block.dataset.coordy) !== coordY
|| block.innerHTML.length === 0
) {
// Clear the obsolete items list from the previous zone
block.innerHTML = "";
// Get the items in the zone by calling the Azimutant's API
_myZone = await getMyZoneOnce(mapId, coordX, coordY);
_myZone = await getMyZoneOnce(mapId, coordX, coordY);
// Set the digging button to grey if the player can't dig
updateDigButtons(_myZone.user_specific.is_visited_today);
updateDigButtons(await _myZone.user_specific.is_visited_today);

if(_myZone.items.length === 0) {
// Show the default text if no items on the ground
Expand Down
8 changes: 7 additions & 1 deletion public/resources/js/mapInit.func.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,10 +355,16 @@ function switchToActionView() {
}

// Activate the "Move" tab action
setTimeout(() => {
setTimeout(async () => {
document.querySelector("#round_move").classList.add("active");
toggleActionBlock('move');
updateBlockAction('move');
// Hide the card for digging if the zone is not diggable
let mapId = Number(document.querySelector("#mapId").innerHTML),
coordX = Number(document.querySelector("#citizenCoordX").innerHTML),
coordY = Number(document.querySelector("#citizenCoordY").innerHTML);
_myZone = await getMyZoneOnce(mapId, coordX, coordY);
updateDigButtons(_myZone.user_specific.is_visited_today);
}, 1000);

// Hide some elements of the GUI to make the interface look lighter
Expand Down
5 changes: 3 additions & 2 deletions public/resources/js/misc.func.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ function animateCss(cssSelector, effectName) {
* @param {int} newCoordY
* @returns {undefined}
*/
function updateMeAfterMoving(newCoordX, newCoordY) {
async function updateMeAfterMoving(newCoordX, newCoordY) {

// Delete the informations about the previous zone (obsolete)
_myZone = null;
Expand All @@ -380,6 +380,7 @@ function updateMeAfterMoving(newCoordX, newCoordY) {
updateEnterBuildingButton(myZone.dataset.citytypeid, myZone.dataset.controlpointscitizens, myZone.dataset.zombies);
updateMoveCost(parseInt(myZone.dataset.zombies));
updateCardCitizensInZone(myZone.dataset.citizens);
updateBlockAction('dig');

setTimeout(()=>{ centerMapOnMe(10) }, 1000);
}
Expand Down Expand Up @@ -457,7 +458,7 @@ async function killZombies(apiAction) {
let myZone = document.querySelector("#me").parentNode;
let oldNbrZombies = myZone.dataset.zombies,
newNbrZombies = Math.max(0, oldNbrZombies - json.datas.nbr_zombies_removed);
let mapId = document.querySelector("#gameData #mapId").innerHTML;
let mapId = Number(document.querySelector("#gameData #mapId").innerHTML);

// Update the action blocks (round buttons next to the map)
updateBlockActionZombies(newNbrZombies);
Expand Down

0 comments on commit 3634f8e

Please sign in to comment.