add score calculation in drag all games all varient

This commit is contained in:
dev sp
2024-01-18 13:37:13 +00:00
parent 94e1b772aa
commit 15b8c1e803
4 changed files with 102 additions and 265 deletions

View File

@@ -81,6 +81,8 @@ import Layout from '../../layouts/Layout.astro';
let shortUniqueID;
let retryButton;
let blockMatches;
let scoreTotal = 0;
let resultView; // scoreTotal resultView
gameResult = [];
window.onload = function() {
// Get the current date and time
@@ -513,6 +515,27 @@ import Layout from '../../layouts/Layout.astro';
window.location.reload();
})
retryButton.setVisible(false);
let score = 0;
let counter = 0;
const isMatch = (blockName, targetName) => {
if(isMatch){
counter++;
// console.log(counter)
}
const match = blockMatches.find((m) => m.blockName === blockName && m.targetName === targetName);
// console.log(match)
if(match !== undefined){
scoreTotal++;
resultView = this.add.text(window.innerWidth / 2 - 100, window.innerHeight / 2 - 100, `Your Score: ${scoreTotal}`, {font: `24px`, fill: `#7c4c23`}).setVisible(false);
console.log("Score Total", scoreTotal)
}
if(counter === 8){
// console.log(counter)
submitButton.setVisible(true);
retryButton.setVisible(true);
resultView.setVisible(true);
}
};
}
}
const displayResult = (droppedBlocks) => {
@@ -520,30 +543,6 @@ import Layout from '../../layouts/Layout.astro';
const targetZone = targetZones.find((zone) => zone.name === block.texture.key);
});
};
let score = 0;
let counter = 0;
const isMatch = (blockName, targetName) => {
if(isMatch){
counter++;
console.log(counter)
if(counter === 8){
const overlap = document.getElementById("overlap");
overlap.style.display = "block";
console.log(counter)
submitButton.setVisible(true);
retryButton.setVisible(true);
}
}
const match = blockMatches.find((m) => m.blockName === blockName && m.targetName === targetName);
console.log(match)
let scoreTotal=0;
if(match !== undefined){
scoreTotal++;
console.log("Score Total", scoreTotal)
}
};
</script>
<style href="https://fonts.googleapis.com/css?family=Quicksand&display=swap" rel="stylesheet" >