diff --git a/env.d.ts b/env.d.ts
index 773d2bb..11f02fe 100644
--- a/env.d.ts
+++ b/env.d.ts
@@ -1,45 +1 @@
///
-export type User = {
- id: number;
- username: string;
- password: string;
- characters: Character[];
-};
-
-export type Character = {
- id: number;
- userId: number;
- user: User;
- name: string;
- hitpoints: number;
- mana: number;
- level: number;
- experience: number;
- role: string;
- position_x: number;
- position_y: number;
- rotation: number;
- zoneId: number;
- zone: Zone;
- chats: Chat[];
-};
-
-export type Zone = {
- id: number;
- name: string;
- width: number;
- height: number;
- tiles: Record;
- characters: Character[];
- chats: Chat[];
-};
-
-export type Chat = {
- id: number;
- characterId: number;
- character: Character;
- zoneId: number;
- zone: Zone;
- message: string;
- createdAt: Date;
-};
diff --git a/src/App.vue b/src/App.vue
index 3317109..0f18d2d 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -1,4 +1,5 @@
+
@@ -8,6 +9,7 @@
\ No newline at end of file
diff --git a/src/engine/Player/IPlayer.ts b/src/engine/Player/IPlayer.ts
index f7be52a..5654212 100644
--- a/src/engine/Player/IPlayer.ts
+++ b/src/engine/Player/IPlayer.ts
@@ -1,6 +1,6 @@
export default interface IPlayer {
readonly id: number;
- username: string;
+ name: string;
coords: {
x: number;
y: number;
diff --git a/src/engine/Player/Player.ts b/src/engine/Player/Player.ts
index 753fde8..cdd0337 100644
--- a/src/engine/Player/Player.ts
+++ b/src/engine/Player/Player.ts
@@ -2,12 +2,12 @@ import type IPlayer from '@/engine/Player/IPlayer';
export default class Player implements IPlayer {
id: number;
- username: string;
+ name: string;
coords: { x: number; y: number; };
- constructor(id: number, username: string, coords: { x: number; y: number; }) {
+ constructor(id: number, name: string, coords: { x: number; y: number; }) {
this.id = id;
- this.username = username;
+ this.name = name;
this.coords = coords;
}
}
\ No newline at end of file
diff --git a/src/stores/notifications.ts b/src/stores/notifications.ts
new file mode 100644
index 0000000..a49a273
--- /dev/null
+++ b/src/stores/notifications.ts
@@ -0,0 +1,19 @@
+import { defineStore, type StoreDefinition } from 'pinia'
+import type { Notification } from '@/types'
+
+export const useNotificationStore: StoreDefinition = defineStore('notifications', {
+ state: () => ({
+ notifications: [] as Notification[]
+ }),
+ getters: {
+ getNotifications: (state: any) => state.notifications
+ },
+ actions: {
+ addNotification(notification: Notification) {
+ this.notifications.push(notification);
+ },
+ removeNotification(index: number) {
+ this.notifications.splice(index, 1);
+ }
+ }
+});
\ No newline at end of file
diff --git a/src/stores/socket.ts b/src/stores/socket.ts
index 6d52f35..a3fc9d6 100644
--- a/src/stores/socket.ts
+++ b/src/stores/socket.ts
@@ -2,9 +2,10 @@ import { defineStore, type StoreDefinition } from 'pinia'
import { io, Socket } from 'socket.io-client';
import {useCookies} from '@vueuse/integrations/useCookies'
import config from '@/config';
-import type { Character, User } from '../../env'
+import type { Character, User } from '@/types'
+import { useNotificationStore } from '@/stores/notifications'
-export const useSocketStore: StoreDefinition = defineStore('socket', {
+export const useSocketStore: StoreDefinition = defineStore('socket', {
state: () => ({
connection: null as Socket | null,
user: null as User | null,
@@ -36,12 +37,6 @@ export const useSocketStore: StoreDefinition = defineStore('socket', {
console.log("Reconnect failed")
this.disconnectSocket();
})
-
- this.connection.on('notification', (data: any) => {
- if(data.error) console.error(data.error);
- if (data.success) console.log(data.success);
- if (data.message) console.log(data.message);
- });
},
disconnectSocket() {
if (!this.connection) return;
diff --git a/src/types.ts b/src/types.ts
new file mode 100644
index 0000000..70073b2
--- /dev/null
+++ b/src/types.ts
@@ -0,0 +1,50 @@
+export type Notification = {
+ id?: number;
+ message: string;
+ type?: string;
+};
+
+export type User = {
+ id: number;
+ username: string;
+ password: string;
+ characters: Character[];
+};
+
+export type Character = {
+ id: number;
+ userId: number;
+ user: User;
+ name: string;
+ hitpoints: number;
+ mana: number;
+ level: number;
+ experience: number;
+ role: string;
+ position_x: number;
+ position_y: number;
+ rotation: number;
+ zoneId: number;
+ zone: Zone;
+ chats: Chat[];
+};
+
+export type Zone = {
+ id: number;
+ name: string;
+ width: number;
+ height: number;
+ tiles: Record;
+ characters: Character[];
+ chats: Chat[];
+};
+
+export type Chat = {
+ id: number;
+ characterId: number;
+ character: Character;
+ zoneId: number;
+ zone: Zone;
+ message: string;
+ createdAt: Date;
+};
\ No newline at end of file