选卡后调用skill处理逻辑

This commit is contained in:
zhl 2020-12-03 20:31:52 +08:00
parent 60a708f82d
commit 583aa8b61c
3 changed files with 26 additions and 12 deletions

2
src/global.d.ts vendored
View File

@ -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

View File

@ -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()];
} }

View File

@ -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){
}; };
} }