比大小出牌后, 将card信息存入player.cardQueue
This commit is contained in:
parent
072d7092ba
commit
e7021949a6
@ -4,6 +4,7 @@ import { Client } from 'colyseus'
|
||||
import { error } from '../../common/Debug'
|
||||
import { DiceResultCommand } from './DiceResultCommand'
|
||||
import { GameStateConst } from '../../constants/GameStateConst'
|
||||
import gameUtil from '../../utils/game.util'
|
||||
|
||||
/**
|
||||
* 出一张牌比大小
|
||||
@ -28,6 +29,7 @@ export class DiceCommand extends Command<CardGameState, { client: Client, cards:
|
||||
}
|
||||
|
||||
let cardIds = []
|
||||
|
||||
for (let id of cards) {
|
||||
if (player.cards.has(id + '')) {
|
||||
if (!player.cards.get(id + '').number) {
|
||||
@ -35,7 +37,8 @@ export class DiceCommand extends Command<CardGameState, { client: Client, cards:
|
||||
continue
|
||||
}
|
||||
const card = player.cards.get(id + '').clone()
|
||||
player.cards.delete(id + '')
|
||||
player.cardQueue.push(card)
|
||||
gameUtil.deleteCardFromPlayer(player, card.id)
|
||||
cardIds.push(card)
|
||||
} else {
|
||||
error(`${ player.id } 出的牌 ${ id } 在手牌中不存在`)
|
||||
|
@ -7,6 +7,9 @@ export class DiceNextTurnCommand extends Command<CardGameState, {}> {
|
||||
async execute() {
|
||||
this.state.round += 1
|
||||
this.state.updateGameState(GameStateConst.STATE_DICE_TURN)
|
||||
for (let [,player] of this.state.players) {
|
||||
player.cardQueue.clear()
|
||||
}
|
||||
return [new DiceDrawCommand()]
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,16 @@
|
||||
import { Command } from '@colyseus/command'
|
||||
import { CardGameState } from '../schema/CardGameState'
|
||||
import { DiceNextTurnCommand } from './DiceNextTurnCommand'
|
||||
import gameUtil from '../../utils/game.util'
|
||||
import { GameResultCommand } from './GameResultCommand'
|
||||
|
||||
export class DiceTurnEndCommand extends Command<CardGameState, {}> {
|
||||
async execute() {
|
||||
// 判断是否胜利
|
||||
let result = gameUtil.checkGameEnd(this.state)
|
||||
if (result) {
|
||||
return [new GameResultCommand()]
|
||||
}
|
||||
return [new DiceNextTurnCommand()]
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user