增加抽卡后超时自动出卡的设定
This commit is contained in:
parent
3e506bad45
commit
09480cd4c0
@ -36,7 +36,7 @@ export class GeneralRoom extends Room {
|
|||||||
});
|
});
|
||||||
this.onMessage("discard_card_c2s", (client, message) => {
|
this.onMessage("discard_card_c2s", (client, message) => {
|
||||||
debugRoom('discard_card from ', client.sessionId, message);
|
debugRoom('discard_card from ', client.sessionId, message);
|
||||||
this.dispatcher.dispatch(new DiscardCommand(), {client, cards: message.cards});
|
this.dispatcher.dispatch(new DiscardCommand(), {client, cards: message.cards, dtype: 0});
|
||||||
});
|
});
|
||||||
this.onMessage("eat_card_c2s", (client, message) => {
|
this.onMessage("eat_card_c2s", (client, message) => {
|
||||||
debugRoom('eat_card from ', client.sessionId, message);
|
debugRoom('eat_card from ', client.sessionId, message);
|
||||||
|
@ -7,14 +7,16 @@ import {GameStateConst} from "../../constants/GameStateConst";
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 出牌
|
* 出牌
|
||||||
|
* type: 0, 正常的抽牌
|
||||||
|
* type: 1, 到时间后, 自动的抽牌
|
||||||
*/
|
*/
|
||||||
export class DiscardCommand extends Command<CardGameState, { client: Client, cards: [string] }> {
|
export class DiscardCommand extends Command<CardGameState, { client: Client, cards: [string], dtype: number }> {
|
||||||
// validate({ client, cards } = this.payload) {
|
// validate({ client, cards } = this.payload) {
|
||||||
// const player = this.state.players.get(client.sessionId);
|
// const player = this.state.players.get(client.sessionId);
|
||||||
// return player !== undefined && gameUtil.checkCardsExists(player.cards, cards);
|
// return player !== undefined && gameUtil.checkCardsExists(player.cards, cards);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
execute({ client, cards } = this.payload) {
|
execute({ client, cards , dtype} = this.payload) {
|
||||||
const player = this.state.players.get(client.sessionId);
|
const player = this.state.players.get(client.sessionId);
|
||||||
if (!player) {
|
if (!player) {
|
||||||
client.send('discard_card_s2c', {errcode: 1, errmsg: 'player不存在'});
|
client.send('discard_card_s2c', {errcode: 1, errmsg: 'player不存在'});
|
||||||
@ -47,6 +49,7 @@ export class DiscardCommand extends Command<CardGameState, { client: Client, car
|
|||||||
* 如果出一张牌的话, 进入胡牌轮
|
* 如果出一张牌的话, 进入胡牌轮
|
||||||
* 否则直接进入选随从轮
|
* 否则直接进入选随从轮
|
||||||
*/
|
*/
|
||||||
|
client.send('discard_card_s2c', {errcode: 0, cards: cards, type: dtype})
|
||||||
if (cards.length === 1) {
|
if (cards.length === 1) {
|
||||||
return [new NextSubCommand()];
|
return [new NextSubCommand()];
|
||||||
} else {
|
} else {
|
||||||
|
@ -4,6 +4,7 @@ import {singleton} from "../../common/Singleton";
|
|||||||
import {GameEnv} from "../../cfg/GameEnv";
|
import {GameEnv} from "../../cfg/GameEnv";
|
||||||
import gameUtil from "../../utils/game.util";
|
import gameUtil from "../../utils/game.util";
|
||||||
import {error} from "../../common/Debug";
|
import {error} from "../../common/Debug";
|
||||||
|
import {DiscardCommand} from "./DiscardCommand";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 正常的抽卡
|
* 正常的抽卡
|
||||||
@ -15,8 +16,11 @@ export class DrawCommand extends Command<CardGameState, {}> {
|
|||||||
let maxTime = singleton(GameEnv).maxDiscardTime;
|
let maxTime = singleton(GameEnv).maxDiscardTime;
|
||||||
await this.delay(maxTime * 1000);
|
await this.delay(maxTime * 1000);
|
||||||
if (sessionId == this.state.currentTurn) {
|
if (sessionId == this.state.currentTurn) {
|
||||||
|
let client = this.room.getClient(sessionId);
|
||||||
error('出牌时间到, 自动出牌');
|
error('出牌时间到, 自动出牌');
|
||||||
//TODO: 自动出牌
|
let player = this.state.players.get(sessionId);
|
||||||
|
let card = player.cards.values().next().value;
|
||||||
|
return [new DiscardCommand().setPayload({client, cards: [card.id], dtype: 1})]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user