Removed conflicting and redundant logic
This commit is contained in:
parent
9413fdbb2f
commit
592d1df9bf
@ -1,20 +1,18 @@
|
||||
<template>
|
||||
<div class="absolute top-0 right-4 hidden lg:block">
|
||||
<p class="text-white text-lg">{{ gameStore.world.date.toLocaleString() }}</p>
|
||||
<p class="text-white text-lg">
|
||||
{{ useDateFormat(gameStore.world.date ?? new Date(), 'YYYY:MM:DD HH:mm:ss') }}
|
||||
</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useGameStore } from '@/stores/gameStore'
|
||||
import { useDateFormat } from '@vueuse/core'
|
||||
import { onUnmounted } from 'vue'
|
||||
|
||||
const gameStore = useGameStore()
|
||||
|
||||
// Listen for new date from socket
|
||||
gameStore.connection?.on('date', (data: Date) => {
|
||||
gameStore.world.date = new Date(data)
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
gameStore.connection?.off('date')
|
||||
})
|
||||
|
@ -46,7 +46,7 @@ const previewPlacedMapObject = computed(() => ({
|
||||
|
||||
function updatePreviewPosition(pointer: Phaser.Input.Pointer) {
|
||||
const tile = getTile(props.tileMap, pointer.worldX, pointer.worldY)
|
||||
if (!tile || previewPosition.value.x === tile.x && previewPosition.value.y === tile.y) return
|
||||
if (!tile || (previewPosition.value.x === tile.x && previewPosition.value.y === tile.y)) return
|
||||
|
||||
previewPosition.value = { x: tile.x, y: tile.y }
|
||||
}
|
||||
|
@ -39,15 +39,6 @@ const password = ref('')
|
||||
const formError = ref('')
|
||||
const showPassword = ref(false)
|
||||
|
||||
// automatic login because of development
|
||||
onMounted(async () => {
|
||||
const token = useCookies().get('token')
|
||||
if (token) {
|
||||
gameStore.setToken(token)
|
||||
gameStore.initConnection()
|
||||
}
|
||||
})
|
||||
|
||||
async function submit() {
|
||||
// check if username and password are valid
|
||||
if (username.value === '' || password.value === '') {
|
||||
|
@ -34,15 +34,6 @@ const password = ref('')
|
||||
const newPasswordError = ref('')
|
||||
const showPassword = ref(false)
|
||||
|
||||
// automatic login because of development
|
||||
onMounted(async () => {
|
||||
const token = useCookies().get('token')
|
||||
if (token) {
|
||||
gameStore.setToken(token)
|
||||
gameStore.initConnection()
|
||||
}
|
||||
})
|
||||
|
||||
async function newPasswordFunc() {
|
||||
// check if username and password are valid
|
||||
if (password.value === '') {
|
||||
|
@ -40,15 +40,6 @@ const email = ref('')
|
||||
const formError = ref('')
|
||||
const showPassword = ref(false)
|
||||
|
||||
// automatic login because of development
|
||||
onMounted(async () => {
|
||||
const token = useCookies().get('token')
|
||||
if (token) {
|
||||
gameStore.setToken(token)
|
||||
gameStore.initConnection()
|
||||
}
|
||||
})
|
||||
|
||||
async function submit() {
|
||||
// check if username and password are valid
|
||||
if (username.value === '' || email.value === '' || password.value === '') {
|
||||
|
@ -44,13 +44,4 @@ function switchToLogin() {
|
||||
currentForm.value = 'login'
|
||||
doesUrlHaveToken.value = false
|
||||
}
|
||||
|
||||
// automatic login because of development
|
||||
onMounted(async () => {
|
||||
const token = useCookies().get('token')
|
||||
if (token) {
|
||||
gameStore.setToken(token)
|
||||
gameStore.initConnection()
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
@ -96,8 +96,17 @@ export const useGameStore = defineStore('game', {
|
||||
this.connection.on('reconnect_failed', () => {
|
||||
this.disconnectSocket()
|
||||
})
|
||||
|
||||
// Listen for new date from socket
|
||||
this.connection.on('date', (data: Date) => {
|
||||
this.world.date = new Date(data)
|
||||
})
|
||||
},
|
||||
disconnectSocket() {
|
||||
// Remove event listeners
|
||||
this.connection?.off('connect_error')
|
||||
this.connection?.off('reconnect_failed')
|
||||
this.connection?.off('date')
|
||||
this.connection?.disconnect()
|
||||
|
||||
useCookies().remove('token', {
|
||||
|
Loading…
x
Reference in New Issue
Block a user