Fixed game sending player stats when not logged in
This commit is contained in:
parent
3befee6fdd
commit
c2bb6c104a
3 changed files with 142 additions and 126 deletions
|
|
@ -153,6 +153,9 @@ function collisionCheck(o) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function die(){
|
function die(){
|
||||||
|
if(localStorage.getItem("frontend-ready") == "false")
|
||||||
|
return;
|
||||||
|
|
||||||
ready = false;
|
ready = false;
|
||||||
hasDied = true;
|
hasDied = true;
|
||||||
playTime = Date.now() - startTime;
|
playTime = Date.now() - startTime;
|
||||||
|
|
@ -205,14 +208,15 @@ function checkRaspberryScore() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function resetScore(){
|
function resetScore(){
|
||||||
if (hasDied) {
|
if(!hasDied || localStorage.getItem("frontend-ready") == "false")
|
||||||
|
return;
|
||||||
|
|
||||||
hasDied = false;
|
hasDied = false;
|
||||||
score = 0;
|
score = 0;
|
||||||
hasAlreadyScored = false;
|
hasAlreadyScored = false;
|
||||||
startTime = Date.now();
|
startTime = Date.now();
|
||||||
exportToLocalStorage();
|
exportToLocalStorage();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
function keyPressed(){
|
function keyPressed(){
|
||||||
if(!ready)
|
if(!ready)
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
<Login v-if="!user" @userChange="(event) => {this.updateUser(event);}">
|
<Login v-if="!user" @userChange="(event) => {this.updateUser(event);}">
|
||||||
</Login>
|
</Login>
|
||||||
<div v-if="user" class="logout-wrapper offset-10 col-2">
|
<div v-if="user" class="logout-wrapper offset-10 col-2">
|
||||||
<RRButton @click="this.user = null; this.userId = -1;" text="Logout"></RRButton>
|
<RRButton @click="logOut()" text="Logout"></RRButton>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
@ -59,7 +59,9 @@ export default defineComponent({
|
||||||
leaderboardEvent: new Event('reloadLeaderboard')
|
leaderboardEvent: new Event('reloadLeaderboard')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
created() {
|
||||||
|
localStorage.setItem("frontend-ready", "false");
|
||||||
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
async fetchFromApi(path: string, method: "GET" | "POST") {
|
async fetchFromApi(path: string, method: "GET" | "POST") {
|
||||||
|
|
@ -80,6 +82,11 @@ export default defineComponent({
|
||||||
await this.updateUserScores();
|
await this.updateUserScores();
|
||||||
}
|
}
|
||||||
window.dispatchEvent(this.leaderboardEvent);
|
window.dispatchEvent(this.leaderboardEvent);
|
||||||
|
},
|
||||||
|
logOut(){
|
||||||
|
this.user = null;
|
||||||
|
this.userId = -1;
|
||||||
|
localStorage.setItem('frontend-ready', 'false');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
@ -99,9 +106,11 @@ export default defineComponent({
|
||||||
.everything {
|
.everything {
|
||||||
margin-bottom: 4em;
|
margin-bottom: 4em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.hidden {
|
.hidden {
|
||||||
visibility: hidden;
|
visibility: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.logout-wrapper {
|
.logout-wrapper {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: right;
|
justify-content: right;
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ export default {
|
||||||
data(){
|
data(){
|
||||||
return {
|
return {
|
||||||
username: '',
|
username: '',
|
||||||
user: null,
|
_user: null,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
emits: ['userChange'],
|
emits: ['userChange'],
|
||||||
|
|
@ -33,14 +33,17 @@ export default {
|
||||||
|
|
||||||
if(user.errors){
|
if(user.errors){
|
||||||
console.error("Something when wrong when logging in, please contact admin!")
|
console.error("Something when wrong when logging in, please contact admin!")
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(user){
|
if(user){
|
||||||
this.user = user;
|
this.user(user);
|
||||||
this.$emit('userChange', this.user);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
user(user){
|
||||||
|
this._user = user;
|
||||||
|
localStorage.setItem("frontend-ready", "true");
|
||||||
|
this.$emit('userChange', this._user);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue