added game-store
This commit is contained in:
12
index.html
12
index.html
@@ -2,15 +2,15 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8"/>
|
||||||
<link rel="icon" href="/favicon.ico" />
|
<link href="/favicon.ico" rel="icon"/>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta content="width=device-width, initial-scale=1.0" name="viewport"/>
|
||||||
<title>Welcome to Vuetify 3</title>
|
<title>Tik Tak Blow</title>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
<script type="module" src="/src/main.ts"></script>
|
<script src="/src/main.ts" type="module"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
@@ -3,6 +3,6 @@ import { defineStore } from 'pinia'
|
|||||||
|
|
||||||
export const useAppStore = defineStore('app', {
|
export const useAppStore = defineStore('app', {
|
||||||
state: () => ({
|
state: () => ({
|
||||||
//
|
isPlaying: false
|
||||||
}),
|
})
|
||||||
})
|
})
|
||||||
|
94
src/stores/game.ts
Normal file
94
src/stores/game.ts
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
// Utilities
|
||||||
|
import { defineStore } from 'pinia'
|
||||||
|
|
||||||
|
export const useGameStore = defineStore('game', {
|
||||||
|
state: (): GameState => ({
|
||||||
|
board: [
|
||||||
|
{ row: 'A', fields: [0, 0, 0] },
|
||||||
|
{ row: 'B', fields: [0, 0, 0] },
|
||||||
|
{ row: 'C', fields: [0, 0, 0] }
|
||||||
|
],
|
||||||
|
round: 1,
|
||||||
|
totalRounds: 5,
|
||||||
|
teams: [
|
||||||
|
{
|
||||||
|
team: 1,
|
||||||
|
wonRounds: [],
|
||||||
|
joker: [
|
||||||
|
{ name: 'shield', isAvailable: true },
|
||||||
|
{ name: 'bomb', isAvailable: true },
|
||||||
|
{ name: 'retry', isAvailable: true }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
team: 2,
|
||||||
|
wonRounds: [],
|
||||||
|
joker: [
|
||||||
|
{ name: 'shield', isAvailable: true },
|
||||||
|
{ name: 'bomb', isAvailable: true },
|
||||||
|
{ name: 'retry', isAvailable: true }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}),
|
||||||
|
actions: {
|
||||||
|
initGame() {
|
||||||
|
this.board = [
|
||||||
|
{ row: 'A', fields: [0, 0, 0] },
|
||||||
|
{ row: 'B', fields: [0, 0, 0] },
|
||||||
|
{ row: 'C', fields: [0, 0, 0] }
|
||||||
|
]
|
||||||
|
this.round = 1
|
||||||
|
this.totalRounds = 5
|
||||||
|
this.teams = [
|
||||||
|
{
|
||||||
|
team: 1,
|
||||||
|
wonRounds: [],
|
||||||
|
joker: [
|
||||||
|
{ name: 'shield', isAvailable: true },
|
||||||
|
{ name: 'bomb', isAvailable: true },
|
||||||
|
{ name: 'retry', isAvailable: true }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
team: 2,
|
||||||
|
wonRounds: [],
|
||||||
|
joker: [
|
||||||
|
{ name: 'shield', isAvailable: true },
|
||||||
|
{ name: 'bomb', isAvailable: true },
|
||||||
|
{ name: 'retry', isAvailable: true }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
this.selectedField = undefined
|
||||||
|
this.question = undefined
|
||||||
|
this.answer = undefined
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
interface GameState {
|
||||||
|
board: Array<{
|
||||||
|
row: 'A' | 'B' | 'C'
|
||||||
|
fields: Array<number>
|
||||||
|
}>
|
||||||
|
round: number
|
||||||
|
totalRounds: number
|
||||||
|
teams: Array<{
|
||||||
|
team: 1 | 2
|
||||||
|
wonRounds: Array<number | undefined>
|
||||||
|
joker: Array<{
|
||||||
|
name: string
|
||||||
|
isAvailable: boolean
|
||||||
|
}>
|
||||||
|
}>
|
||||||
|
selectedField?: {
|
||||||
|
row: 'A' | 'B' | 'C' | undefined
|
||||||
|
field: number
|
||||||
|
}
|
||||||
|
question?: {
|
||||||
|
question: string
|
||||||
|
answers: Array<{ key: string; value: string } | undefined>
|
||||||
|
}
|
||||||
|
answer?: string
|
||||||
|
}
|
Reference in New Issue
Block a user