12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- //海龟汤游戏特定的 API
- import { TurtleSoupGame } from '@/stores/games/turtlesoup'
- import { callCloudFunction } from '../../cloud'
- import { type ITurtleSoupGame, type ITurtleSoupQuestion, type ITurtleSoupGameResult } from '@/types/games/turtlesoup'
- // 海龟汤游戏相关API
- export const turtleSoupService = {
- /**
- * 获取游戏数据
- * @param gameId 游戏ID
- * @param role 用户角色
- */
- getGameData(gameId: string, role: string) {
- return callCloudFunction<{ game: TurtleSoupGame }>('getTurtleSoupGame', { gameId, role })
- },
- /**
- * 提交问题
- * @param gameId 游戏ID
- * @param content 问题内容
- */
- submitQuestion(gameId: string, content: string) {
- return callCloudFunction<{ questionId: string }>('submitTurtleSoupQuestion', { gameId, content })
- },
- /**
- * 回答问题
- * @param questionId 问题ID
- * @param answer 答案
- */
- answerQuestion(questionId: string, answer: string) {
- return callCloudFunction<{ success: boolean }>('answerTurtleSoupQuestion', { questionId, answer })
- },
- /**
- * 公开提示
- * @param gameId 游戏ID
- * @param hintIndex 提示索引
- */
- revealHint(gameId: string, hintIndex: number) {
- return callCloudFunction<{ success: boolean }>('revealTurtleSoupHint', { gameId, hintIndex })
- },
- /**
- * 结束游戏
- * @param gameId 游戏ID
- * @param result 游戏结果
- */
- endGame(gameId: string, result: { solved: boolean; solvedBy?: string }) {
- return callCloudFunction<{ gameResult: ITurtleSoupGameResult }>('endTurtleSoupGame', { gameId, result })
- }
- }
|