选卡后调用skill处理逻辑
This commit is contained in:
parent
60a708f82d
commit
583aa8b61c
2
src/global.d.ts
vendored
2
src/global.d.ts
vendored
@ -16,8 +16,10 @@ declare global {
|
|||||||
*/
|
*/
|
||||||
import {Client, Room} from "colyseus";
|
import {Client, Room} from "colyseus";
|
||||||
import {PetInfoMsg} from "./message/PetInfo";
|
import {PetInfoMsg} from "./message/PetInfo";
|
||||||
|
import {BattleHandler} from "./rooms/logic/Handler/BattleHandler";
|
||||||
declare module "colyseus" {
|
declare module "colyseus" {
|
||||||
interface Room {
|
interface Room {
|
||||||
|
battleMan: BattleHandler;
|
||||||
/**
|
/**
|
||||||
* 广播玩家加入房间
|
* 广播玩家加入房间
|
||||||
* @param data
|
* @param data
|
||||||
|
@ -3,17 +3,20 @@ import { CardGameState } from "../schema/CardGameState";
|
|||||||
import {Client} from "colyseus";
|
import {Client} from "colyseus";
|
||||||
import {NextTurnCommand} from "./NextTurnCommand";
|
import {NextTurnCommand} from "./NextTurnCommand";
|
||||||
import {TurnEndCommand} from "./TurnEndCommand";
|
import {TurnEndCommand} from "./TurnEndCommand";
|
||||||
|
import {Player} from "../schema/Player";
|
||||||
|
import {Card} from "../schema/Card";
|
||||||
|
import {Pet} from "../schema/Pet";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 选择随从或者法术
|
* 选择随从或者法术
|
||||||
*/
|
*/
|
||||||
export class SelectPetCommand extends Command<CardGameState, {client: Client,
|
export class SelectPetCommand extends Command<CardGameState, {client: Client,
|
||||||
cardId: string,
|
cardId: number,
|
||||||
playerId: string,
|
playerId: string,
|
||||||
pos: number,
|
pos: number,
|
||||||
effCards: string[]
|
effCards: string[]
|
||||||
}> {
|
}> {
|
||||||
execute({client, cardId, playerId, pos, effCards}: {client: Client, cardId: string, playerId: string, pos: number, effCards: string[]}) {
|
execute({client, cardId, playerId, pos, effCards} = this.payload) {
|
||||||
let sessionId = this.state.currentTurn;
|
let sessionId = this.state.currentTurn;
|
||||||
let player = this.state.players.get(sessionId);
|
let player = this.state.players.get(sessionId);
|
||||||
let ap = 0;
|
let ap = 0;
|
||||||
@ -32,6 +35,15 @@ export class SelectPetCommand extends Command<CardGameState, {client: Client,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
let dstplayer = this.state.players.get(playerId);
|
||||||
|
let dstpet;
|
||||||
|
if (pos != undefined) {
|
||||||
|
dstpet = dstplayer.pets.get(pos+'');
|
||||||
|
}
|
||||||
|
let cardpoint = 10;
|
||||||
|
let eff_cnt = effCards.length;
|
||||||
|
let data = {srcplayer: player, card: cardId, cardpoint, eff_cnt, dstplayer, dstpet}
|
||||||
|
this.room.battleMan.useCard(data);
|
||||||
return [new TurnEndCommand()];
|
return [new TurnEndCommand()];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ export class BattleHandler {
|
|||||||
private _cs: CardGameState;
|
private _cs: CardGameState;
|
||||||
|
|
||||||
private _players: Map<Player, PlayerHandler> = new Map();
|
private _players: Map<Player, PlayerHandler> = new Map();
|
||||||
|
|
||||||
_room: Room;
|
_room: Room;
|
||||||
|
|
||||||
public init(cs: CardGameState, room: Room){
|
public init(cs: CardGameState, room: Room){
|
||||||
@ -43,14 +43,14 @@ export class BattleHandler {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 使用卡片
|
* 使用卡片
|
||||||
* @param obj
|
* @param obj
|
||||||
*/
|
*/
|
||||||
public useCard(obj:
|
public useCard(obj:
|
||||||
{srcplayer: Player, card: Card, cardpoint: number, eff_cnt: number, dstplayer: Player, dstpet: Pet})
|
{srcplayer: Player, card: number, cardpoint: number, eff_cnt: number, dstplayer: Player, dstpet: Pet})
|
||||||
{
|
{
|
||||||
if(!obj || obj.card){
|
if(!obj || obj.card){
|
||||||
return false;
|
return false;
|
||||||
@ -66,14 +66,14 @@ export class BattleHandler {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
let ps = new SkillParam(obj.card.id, obj.cardpoint, obj.eff_cnt, ph, dstph, dstpt);
|
let ps = new SkillParam(obj.card, obj.cardpoint, obj.eff_cnt, ph, dstph, dstpt);
|
||||||
|
|
||||||
ph.useCard(ps);
|
ph.useCard(ps);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 使用技能
|
* 使用技能
|
||||||
* @param obj
|
* @param obj
|
||||||
*/
|
*/
|
||||||
public useSkill(obj:{
|
public useSkill(obj:{
|
||||||
srcplayer: Player, skillid: number, dstplayer: Player, dstpet: Pet
|
srcplayer: Player, skillid: number, dstplayer: Player, dstpet: Pet
|
||||||
@ -98,7 +98,7 @@ export class BattleHandler {
|
|||||||
public onCardLinkOver(aplayer: Player, linkcards: Card[]){
|
public onCardLinkOver(aplayer: Player, linkcards: Card[]){
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 使用卡牌结束(暂时自动回调,无需外部触发)
|
* 使用卡牌结束(暂时自动回调,无需外部触发)
|
||||||
* @param obj :使用卡牌相关操作
|
* @param obj :使用卡牌相关操作
|
||||||
@ -131,7 +131,7 @@ export class BattleHandler {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 玩家回合开始
|
* 玩家回合开始
|
||||||
* @param aplayer
|
* @param aplayer
|
||||||
*/
|
*/
|
||||||
public onPlayerRoundStart(aplayer: Player){
|
public onPlayerRoundStart(aplayer: Player){
|
||||||
|
|
||||||
@ -139,9 +139,9 @@ export class BattleHandler {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 玩家回合结束
|
* 玩家回合结束
|
||||||
* @param aplayer
|
* @param aplayer
|
||||||
*/
|
*/
|
||||||
public onPlayerRoundEnd(aplayer: Player){
|
public onPlayerRoundEnd(aplayer: Player){
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user