1
0
forked from noxious/client

My 13th reason (2.0)

This commit is contained in:
2024-09-20 16:34:17 +02:00
parent b9bb55cf49
commit be4c201d81
21 changed files with 129 additions and 131 deletions

View File

@ -42,7 +42,6 @@ import { Game, Scene } from 'phavuer'
import { useGameStore } from '@/stores/game'
import { useZoneStore } from '@/stores/zone'
import { useZoneEditorStore } from '@/stores/zoneEditor'
import { useAssetStore } from '@/stores/assets'
import Hud from '@/components/gui/Hud.vue'
import Zone from '@/components/zone/Zone.vue'
import Chat from '@/components/gui/Chat.vue'
@ -51,12 +50,10 @@ import GmTools from '@/components/gameMaster/GmTools.vue'
import ZoneEditor from '@/components/gameMaster/zoneEditor/ZoneEditor.vue'
import GmPanel from '@/components/gameMaster/GmPanel.vue'
import Inventory from '@/components/gui/UserPanel.vue'
import { loadAssets } from '@/services/zone'
import { loadAssets } from '@/composables/zoneComposable'
const gameStore = useGameStore()
const zoneStore = useZoneStore()
const zoneEditorStore = useZoneEditorStore()
const assetStore = useAssetStore()
const isLoaded = ref(false)
const gameConfig = {
@ -138,7 +135,7 @@ const createScene = (scene: Phaser.Scene) => {
/**
* Create sprite animations
*/
assetStore.assets.forEach((asset) => {
gameStore.assets.forEach((asset) => {
if (asset.group !== 'sprite_animations') return
scene.anims.create({
key: asset.key,

View File

@ -30,21 +30,19 @@
<script setup lang="ts">
import { onMounted, ref } from 'vue'
import { login, register } from '@/services/authentication'
import { useNotificationStore } from '@/stores/notifications'
import { useGameStore } from '@/stores/game'
import { useAssetStore } from '@/stores/assets'
import { useCookies } from '@vueuse/integrations/useCookies'
const gameStore = useGameStore()
const notifications = useNotificationStore()
const username = ref('')
const password = ref('')
// automatic login because of development
onMounted(async () => {
/**
* Fetch assets from the server
* Fetch sprite assets from the server
*/
await gameStore.fetchSpriteAssets()
const token = useCookies().get('token')
if (token) {
@ -56,7 +54,7 @@ onMounted(async () => {
async function loginFunc() {
// check if username and password are valid
if (username.value === '' || password.value === '') {
notifications.addNotification({ message: 'Please enter a valid username and password' })
gameStore.addNotification({ message: 'Please enter a valid username and password' })
return
}
@ -64,7 +62,7 @@ async function loginFunc() {
const response = await login(username.value, password.value)
if (response.success === undefined) {
notifications.addNotification({ message: response.error })
gameStore.addNotification({ message: response.error })
return
}
@ -76,7 +74,7 @@ async function loginFunc() {
async function registerFunc() {
// check if username and password are valid
if (username.value === '' || password.value === '') {
notifications.addNotification({ message: 'Please enter a valid username and password' })
gameStore.addNotification({ message: 'Please enter a valid username and password' })
return
}
@ -84,13 +82,13 @@ async function registerFunc() {
const response = await register(username.value, password.value)
if (response.success === undefined) {
notifications.addNotification({ message: response.error })
gameStore.addNotification({ message: response.error })
return
}
const loginSuccess = await loginFunc()
if (!loginSuccess) {
notifications.addNotification({ message: 'Login after registration failed. Please try logging in manually.' })
gameStore.addNotification({ message: 'Login after registration failed. Please try logging in manually.' })
}
}
</script>