From 54e3d589c13b0fb4c3b723af8d07fef637ddfa68 Mon Sep 17 00:00:00 2001 From: zhl Date: Wed, 23 Dec 2020 17:23:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=A4=E6=96=AD=E5=90=83?= =?UTF-8?q?=E5=92=8C=E8=83=A1=E6=A0=B9=E6=8D=AE=E9=85=8D=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/cfg/GameEnv.ts | 9 +++++++++ src/constants/BaseConst.ts | 8 ++++++++ src/rooms/commands/DiscardCommand.ts | 16 +++++++++------- src/rooms/commands/EatCardCommand.ts | 3 ++- src/utils/assistant.util.ts | 11 ++++++----- src/utils/game.util.ts | 18 ++++++++++-------- 6 files changed, 44 insertions(+), 21 deletions(-) diff --git a/src/cfg/GameEnv.ts b/src/cfg/GameEnv.ts index a196826..196ac69 100644 --- a/src/cfg/GameEnv.ts +++ b/src/cfg/GameEnv.ts @@ -50,6 +50,12 @@ export class GameEnv { public robotActTimeMax: number; // 队友死亡后,补牌数量 public teamDeadAddNum: number; + // 胡牌张数(自摸) + public selfEatCount: number; + // 胡牌张数(吃牌) + public otherEatCount: number; + // 轮空轮的间隔时间 + public emptyRoundTime: number; public init(data: Map) { this.initCardNum = data.get(BaseConst.INIT_CARD_NUM).value; @@ -75,5 +81,8 @@ export class GameEnv { this.robotActTimeMin = data.get(BaseConst.ROBOT_ACTTIME_MIN).value; this.robotActTimeMax = data.get(BaseConst.ROBOT_ACTTIME_MAX).value; this.teamDeadAddNum = data.get(BaseConst.TEAM_DEAD_ADDNUM).value; + this.selfEatCount = data.get(BaseConst.SELF_EAT_COUNT).value; + this.otherEatCount = data.get(BaseConst.OTHER_EAT_COUNT).value; + this.emptyRoundTime = data.get(BaseConst.EMPTY_ROUND_TIME).value; } } diff --git a/src/constants/BaseConst.ts b/src/constants/BaseConst.ts index bbb67f6..e515fa0 100644 --- a/src/constants/BaseConst.ts +++ b/src/constants/BaseConst.ts @@ -45,6 +45,14 @@ export class BaseConst { public static readonly ROBOT_ACTTIME_MAX = 99022; // 队友死亡后,补牌数量 public static readonly TEAM_DEAD_ADDNUM = 99023 + // 胡牌张数(自摸) + public static readonly SELF_EAT_COUNT = 99024 + // 胡牌张数(吃牌) + public static readonly OTHER_EAT_COUNT = 99025 + // 轮空轮的间隔时间 + public static readonly EMPTY_ROUND_TIME = 99026 + + diff --git a/src/rooms/commands/DiscardCommand.ts b/src/rooms/commands/DiscardCommand.ts index bed0169..ab6dc26 100644 --- a/src/rooms/commands/DiscardCommand.ts +++ b/src/rooms/commands/DiscardCommand.ts @@ -8,6 +8,8 @@ import {GameEnv} from "../../cfg/GameEnv"; import {debugRoom} from "../../common/Debug"; import {TurnEndCommand} from "./TurnEndCommand"; import {Card} from "../schema/Card"; +import {Wait} from "./Wait"; +import {CardType} from "../../cfg/enums/CardType"; /** * 出牌 @@ -38,7 +40,7 @@ export class DiscardCommand extends Command = new Map(); let cardIdSet: Set = new Set(); for (let c of cardArr) { @@ -40,13 +41,13 @@ let assistantUtil = { // 优先出对子 for (let [point, arr] of pointMap) { if (card) { - if (point == card.number && arr.length >= 3) { + if (point == card.number && arr.length >= maxCount) { fetched = true; result = arr; break; } } else { - if (arr.length >= 3) { + if (arr.length >= maxCount) { fetched = true; result = arr; break; @@ -71,17 +72,17 @@ let assistantUtil = { tmp.push(cur); } if (card) { - if (tmp.indexOf(card.number) >= 0 && tmp.length >= 3) { + if (tmp.indexOf(card.number) >= 0 && tmp.length >= maxCount) { break; } } else { - if (tmp.length >= 3) { + if (tmp.length >= maxCount) { break; } } } - if (tmp.length >= 3) { + if (tmp.length >= maxCount) { let subTmp = []; for (let i = tmp[0] - 1; i > 0; i--) { if (cardIdSet.has(i)) { diff --git a/src/utils/game.util.ts b/src/utils/game.util.ts index 3daf104..afa4443 100644 --- a/src/utils/game.util.ts +++ b/src/utils/game.util.ts @@ -8,8 +8,9 @@ import {error} from "../common/Debug"; import {Room} from "colyseus"; import {PlayerStateConst} from "../constants/PlayerStateConst"; import {GameEnv} from "../cfg/GameEnv"; -import {GameResultCommand} from "../rooms/commands/GameResultCommand"; import {CardGameState} from "../rooms/schema/CardGameState"; +import {CardType} from "../cfg/enums/CardType"; +import {EffectType} from "../cfg/enums/EffectType"; let gameUtil = { /** @@ -27,8 +28,8 @@ let gameUtil = { let [effid, effType] = this.getRandomEffect(cfg.weightArr, effCfgMap, countMap); let type = cfg.type_id; // 如果效果的type_id为11, 说明是自选随从卡, 则将card的type改为11 - if (effType == 11) { - type = 11; + if (effType == EffectType.variable_unit) { + type = CardType.variable_unit; } let card = new Card(localId++, cfg.point, type, effid); cards.push(card); @@ -202,7 +203,7 @@ let gameUtil = { addCardToPlayer(room: Room, player: Player, cards: Card[], fromplayer?: Player) { for (let card of cards) { // 如果card的type == 11, 说明是自选随从卡, 则替换成玩家牌组中的卡 - if (card.type == 11) { + if (card.type == CardType.variable_unit) { card.effect = this.getRandomServant(player); } player.cards.set(card.id + '', card); @@ -227,7 +228,7 @@ let gameUtil = { let count = targetCards.length; for (let i = 0; i < count; i++) { let card = cardArr.pop(); - if (card.type == 11) { + if (card.type == CardType.variable_unit) { card.effect = this.getRandomServant(player); } cards.push(card); @@ -239,8 +240,9 @@ let gameUtil = { /** * 检查出牌是否符合规则 * @param cardsLst + * @param maxCount */ - checkDiscard(cardsLst: Card[]) { + checkDiscard(cardsLst: Card[], maxCount: number) { if (cardsLst.length == 0 || cardsLst.length == 2) { return false } else if (cardsLst.length == 1) { @@ -248,14 +250,14 @@ let gameUtil = { } let numSet: number[] = []; cardsLst.forEach(function (value) { - if (value.number < 11) { + if (value.type == CardType.general || value.type == CardType.variable_unit) { numSet.push(value.number); } }); if (numSet.length === 1) { return true; } - if (numSet.length < 3) { + if (numSet.length < maxCount) { return false; } numSet.sort((a, b) => {