增加一些流程中对BattleHandler的回调
This commit is contained in:
parent
b130453718
commit
1febf4ee13
@ -7,6 +7,7 @@ import {PlayerStateConst} from "../../constants/PlayerStateConst";
|
||||
import {singleton} from "../../common/Singleton";
|
||||
import {GameEnv} from "../../cfg/GameEnv";
|
||||
import {GameStateConst} from "../../constants/GameStateConst";
|
||||
import {NextTurnCommand} from "./NextTurnCommand";
|
||||
|
||||
/**
|
||||
* 开局换卡
|
||||
@ -37,11 +38,9 @@ export class ChangeCardCommand extends Command<CardGameState, { client: Client,
|
||||
if (finishCount >= this.room.maxClients) {
|
||||
// TODO:: 延后开始 根据 this.state.firstPlayer确定先手
|
||||
// 正式开始游戏, 第一个玩家出牌
|
||||
let curClient = this.room.clients[0];
|
||||
this.state.currentTurn = curClient.sessionId;
|
||||
this.state.round = 0;
|
||||
this.room.addCard(curClient.sessionId, singleton(GameEnv).roundDrawNum, 0);
|
||||
this.state.gameState = GameStateConst.STATE_BEGIN_DRAW;
|
||||
return [new NextTurnCommand()];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,13 @@ export class EatCardCommand extends Command<CardGameState, { client: Client, car
|
||||
player.cardSet.delete(id+'');
|
||||
}
|
||||
this.state.gameState = GameStateConst.STATE_PICK_PET;
|
||||
//TODO:: 调用 onCardLinkReady()
|
||||
let fromPlayer = this.state.players.get(this.state.currentTurn);
|
||||
if (fromPlayer.id !== player.id) {
|
||||
this.room.battleMan.onCardLinkReady(player, fromPlayer);
|
||||
} else {
|
||||
this.room.battleMan.onCardLinkReady(player);
|
||||
}
|
||||
|
||||
// 成功后广播吃牌成功消息
|
||||
this.room.broadcast('eat_card_s2c', {player: client.sessionId, errocode: 0, errmsg: ''})
|
||||
}
|
||||
|
@ -14,6 +14,9 @@ export class NextTurnCommand extends Command<CardGameState, {}> {
|
||||
execute() {
|
||||
this.state.gameState = GameStateConst.STATE_BEGIN_DRAW;
|
||||
const sessionIds = [...this.state.players.keys()];
|
||||
if (!this.state.currentTurn) {
|
||||
this.state.round = 0;
|
||||
}
|
||||
// 如果上一轮是最后一个玩家, 则round + 1;
|
||||
if (this.state.currentTurn
|
||||
&& sessionIds.indexOf(this.state.currentTurn) == (sessionIds.length - 1)) {
|
||||
@ -26,6 +29,7 @@ export class NextTurnCommand extends Command<CardGameState, {}> {
|
||||
if (!player) {
|
||||
error('未找到玩家');
|
||||
}
|
||||
this.room.battleMan.onPlayerRoundStart(player);
|
||||
if (player.state == PlayerStateConst.PLAYER_DEAD) {
|
||||
return [new TurnEndCommand()];
|
||||
} else {
|
||||
|
@ -14,6 +14,12 @@ export class TurnEndCommand extends Command<CardGameState, {}> {
|
||||
execute() {
|
||||
// @ts-ignore
|
||||
const sessionIds = [...this.state.players.keys()];
|
||||
if (this.state.currentTurn) {
|
||||
let player = this.state.players.get(this.state.currentTurn);
|
||||
if (player) {
|
||||
this.room.battleMan.onPlayerRoundEnd(player);
|
||||
}
|
||||
}
|
||||
if (this.state.currentTurn
|
||||
&& sessionIds.indexOf(this.state.currentTurn) == (sessionIds.length - 1)) {
|
||||
// 每n轮结束的时候结算一次
|
||||
|
@ -222,7 +222,7 @@ export class BattleHandler {
|
||||
};
|
||||
|
||||
/**
|
||||
* 吃牌/胡牌结束(暂时不用)
|
||||
* 吃牌/胡牌结束(暂时不用)??
|
||||
* @param aplayer :玩家
|
||||
* @param linkcards :吃到的牌组信息
|
||||
*/
|
||||
@ -246,7 +246,7 @@ export class BattleHandler {
|
||||
};
|
||||
|
||||
/**
|
||||
* 弃牌完成
|
||||
* 弃牌完成 ??
|
||||
* @param aplayer :玩家
|
||||
* @param fromplayer : 谁使玩家弃牌的(自己主动弃牌的传空)
|
||||
* @param dropcards : 弃掉的牌组
|
||||
@ -258,7 +258,7 @@ export class BattleHandler {
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取牌完成
|
||||
* 获取牌完成 ??
|
||||
* @param aplayer :玩家
|
||||
* @param fromplayer : 谁使玩家获得牌的(自己主动获得牌的传空)
|
||||
* @param dropcards : 获得的牌组
|
||||
|
@ -9,7 +9,7 @@ import { EnhanceEffectType, PowerValueType } from "../skill/SkillConst";
|
||||
import { PlayerHandler } from "./PlayerHandler";
|
||||
import { PetInfoMsg } from "../../../message/PetInfo";
|
||||
import { SkillParam } from "../skill/SkillParam";
|
||||
import { RemovePetMsg } from "message/RemovePetMsg";
|
||||
import { RemovePetMsg } from "../../../message/RemovePetMsg";
|
||||
|
||||
export class PetHandler {
|
||||
_pet: Pet;
|
||||
|
Loading…
x
Reference in New Issue
Block a user