refactor: split engine/gamemaster.ts into gameState.ts

This commit is contained in:
Settel 2022-09-09 08:36:12 +02:00
parent 79d56e801f
commit 2fb3833dd8
3 changed files with 39 additions and 36 deletions

View File

@ -0,0 +1,37 @@
import { EngineContext } from '@/composables/useEngine'
import { useUserinfoStore } from "@/stores/UserinfoStore"
export async function collectQuotes(this: EngineContext): Promise<void> {
const userInfoStore = useUserinfoStore()
await this.callApi('/api/collectQuotes', {
g: userInfoStore.gameId,
})
}
export async function startGame(this: EngineContext): Promise<void> {
const userInfoStore = useUserinfoStore()
await this.callApi('/api/startGame', {
g: userInfoStore.gameId,
})
}
export async function continueGame(this: EngineContext): Promise<void> {
const userInfoStore = useUserinfoStore()
await this.callApi('/api/continueGame', {
g: userInfoStore.gameId,
})
}
export async function resetGame(this: EngineContext): Promise<void> {
const userInfoStore = useUserinfoStore()
await this.callApi('/api/resetGame', {
g: userInfoStore.gameId,
})
}
export async function finishGame(this: EngineContext): Promise<void> {
const userInfoStore = useUserinfoStore()
await this.callApi('/api/finishGame', {
g: userInfoStore.gameId,
})
}

View File

@ -2,41 +2,6 @@ import { EngineContext } from '@/composables/useEngine'
import type { GameInfo, PlayerEdit } from '@/composables/engine.d'
import { useUserinfoStore } from "@/stores/UserinfoStore"
export async function collectQuotes(this: EngineContext): Promise<void> {
const userInfoStore = useUserinfoStore()
await this.callApi('/api/collectQuotes', {
g: userInfoStore.gameId,
})
}
export async function startGame(this: EngineContext): Promise<void> {
const userInfoStore = useUserinfoStore()
await this.callApi('/api/startGame', {
g: userInfoStore.gameId,
})
}
export async function continueGame(this: EngineContext): Promise<void> {
const userInfoStore = useUserinfoStore()
await this.callApi('/api/continueGame', {
g: userInfoStore.gameId,
})
}
export async function resetGame(this: EngineContext): Promise<void> {
const userInfoStore = useUserinfoStore()
await this.callApi('/api/resetGame', {
g: userInfoStore.gameId,
})
}
export async function finishGame(this: EngineContext): Promise<void> {
const userInfoStore = useUserinfoStore()
await this.callApi('/api/finishGame', {
g: userInfoStore.gameId,
})
}
export async function fetchGameInfo(this: EngineContext): Promise<GameInfo> {
const userInfoStore = useUserinfoStore()
return await this.callApi('/api/gameinfo', {

View File

@ -3,7 +3,8 @@ import { callApi, QueryParams } from '@/composables/engine/callApi'
import { start, stop } from '@/composables/engine/startStop'
import { fetchUpdate } from '@/composables/engine/fetchUpdate'
import { loadQuotes, getQuotesRef, deleteQuote, saveQuote } from '@/composables/engine/quotes'
import { collectQuotes, startGame, continueGame, resetGame, finishGame, fetchGameInfo, setGameLang, setGameName, savePlayer, deletePlayer } from '@/composables/engine/gamemaster'
import { fetchGameInfo, setGameLang, setGameName, savePlayer, deletePlayer } from '@/composables/engine/gamemaster'
import { collectQuotes, startGame, continueGame, resetGame, finishGame } from '@/composables/engine/gameState'
import { saveSelection } from '@/composables/engine/play'
import type { Quotes, GameInfo, PlayerEdit } from '@/composables/engine.d'