完善下随从逻辑

This commit is contained in:
zhl 2020-12-04 16:25:50 +08:00
parent 78298aebe2
commit 5f7990ed8c
5 changed files with 139 additions and 10 deletions

View File

@ -1 +1,82 @@
[{"id":99001,"type_id":1,"value":6},{"id":99002,"type_id":1,"value":2},{"id":99003,"type_id":2,"value":20},{"id":99004,"type_id":1,"value":2},{"id":99005,"type_id":1,"value":3},{"id":99006,"type_id":1,"value":4},{"id":99007,"type_id":1,"value":12},{"id":99008,"type_id":2,"value":8},{"id":99009,"type_id":2,"value":8},{"id":99010,"type_id":2,"value":15},{"id":99011,"type_id":2,"value":20},{"id":99012,"type_id":2,"value":5},{"id":99013,"type_id":1,"value":5},{"id":99014,"type_id":2,"value":5}]
[
{
"id": 99001,
"type_id": 1,
"value": 6
},
{
"id": 99002,
"type_id": 1,
"value": 2
},
{
"id": 99003,
"type_id": 2,
"value": 20
},
{
"id": 99004,
"type_id": 1,
"value": 2
},
{
"id": 99005,
"type_id": 1,
"value": 3
},
{
"id": 99006,
"type_id": 1,
"value": 4
},
{
"id": 99007,
"type_id": 1,
"value": 12
},
{
"id": 99008,
"type_id": 2,
"value": 8
},
{
"id": 99009,
"type_id": 2,
"value": 8
},
{
"id": 99010,
"type_id": 2,
"value": 15
},
{
"id": 99011,
"type_id": 2,
"value": 20
},
{
"id": 99012,
"type_id": 2,
"value": 5
},
{
"id": 99013,
"type_id": 1,
"value": 5
},
{
"id": 99014,
"type_id": 2,
"value": 5
},
{
"id": 99015,
"type_id": 1,
"value": 10
},
{
"id": 99016,
"type_id": 1,
"value": 10
}
]

View File

@ -30,6 +30,10 @@ export class GameEnv {
public maxPlayerPetCount: number;
// 结算显示时间
public resultShowTime: number;
// 基本奖励分
public baseAddScore: number;
// 额外奖励分
public extraAddScore: number;
public init(data: Map<number, BaseCfg>) {
this.initCardNum = data.get(BaseConst.INIT_CARD_NUM).value;
@ -46,5 +50,7 @@ export class GameEnv {
this.roundExtTime = data.get(BaseConst.ROUND_EXT_TIME).value;
this.maxPlayerPetCount = data.get(BaseConst.MAX_PLAYER_PET_COUNT).value;
this.resultShowTime = data.get(BaseConst.ROUND_SHOW_TIME).value;
this.baseAddScore = data.get(BaseConst.BASE_ADD_SCORE).value;
this.extraAddScore = data.get(BaseConst.EXTRA_ADD_SCORE).value;
}
}

View File

@ -27,6 +27,11 @@ export class BaseConst {
public static readonly MAX_PLAYER_PET_COUNT = 99013;
// 结算时间
public static readonly ROUND_SHOW_TIME = 99014;
// 基本奖励分
public static readonly BASE_ADD_SCORE = 99015;
// 额外奖励分
public static readonly EXTRA_ADD_SCORE = 99016;
public static readonly COMPOUND = "compound";

View File

@ -6,6 +6,7 @@ import {singleton} from "../../common/Singleton";
import {GameEnv} from "../../cfg/GameEnv";
import {NextTurnCommand} from "./NextTurnCommand";
import {Wait} from "./Wait";
import {PlayerStateConst} from "../../constants/PlayerStateConst";
/**
*
@ -16,16 +17,18 @@ export class PartResultCommand extends Command<CardGameState, {}> {
execute() {
this.state.gameState = GameStateConst.STATE_ROUND_RESULT;
const time = singleton(GameEnv).resultShowTime || 1;
let team0 = [];
let team1 = [];
let team2 = [];
for (let [sessionId, player] of this.state.players) {
if (player.team == 0) {
team1.push(player);
team0.push(player);
} else {
team2.push(player);
team1.unshift(player);
}
}
return [new Wait().setPayload(time*1000) ,new NextTurnCommand()];
}

View File

@ -6,6 +6,8 @@ import {TurnEndCommand} from "./TurnEndCommand";
import {Player} from "../schema/Player";
import {Card} from "../schema/Card";
import {Pet} from "../schema/Pet";
import {singleton} from "../../common/Singleton";
import {GameEnv} from "../../cfg/GameEnv";
/**
*
@ -23,11 +25,44 @@ export class SelectPetCommand extends Command<CardGameState, {client: Client,
let moreAp = 0;
let count = 0;
let targetCard;
let hasEffectSkill = this.room.battleMan.hasTransEffCardSkill(player);
// 检查效果卡, 并从玩家手牌中移除
let eff_cnt = 0; // 效果卡数量
let dbpt_cnt = 0; // 点数翻倍卡数量
for (let cardId of effCards) {
if (!player.cards.has(cardId + '')) {
continue;
}
let card = player.cards.get(cardId + '');
let neetRemove = false;
if (hasEffectSkill) {
neetRemove = true;
if (card.type === 3) {
dbpt_cnt ++;
} else {
eff_cnt ++;
}
} else {
if (card.type === 3) {
dbpt_cnt ++;
neetRemove = true;
} else if (card.type === 2) {
eff_cnt ++;
neetRemove = true;
}
}
if (neetRemove) {
player.cards.delete(cardId + '');
player.cardSet.delete(cardId + '');
}
}
for (let card of this.state.cards.values()) {
ap += card.number;
count ++;
if (count > 2) {
moreAp += 10;
if (count === 3) {
moreAp += singleton(GameEnv).baseAddScore;
} else if (count > 3) {
moreAp += singleton(GameEnv).extraAddScore;
}
if (card.id == cardId) {
targetCard = card;
@ -36,16 +71,15 @@ export class SelectPetCommand extends Command<CardGameState, {client: Client,
if (!targetCard) {
return;
}
let eff_cnt = effCards.length;
let dstplayer = this.state.players.get(playerId);
let dstpet;
if (pos != undefined) {
dstpet = dstplayer.pets.get(pos+'');
}
let cardpoint = moreAp;
//TODO:
let data = {srcplayer: player, card: targetCard.effect, cardpoint, eff_cnt, dstplayer, dstpet, dbpt_cnt: 0}
let cardpoint = moreAp + ap;
let data = {srcplayer: player, card: targetCard.effect, cardpoint, eff_cnt, dstplayer, dstpet, dbpt_cnt}
this.room.battleMan.useCard(data);
return [new TurnEndCommand()];