From a218a253d80225896dac72c6ecf6a403ea6fd911 Mon Sep 17 00:00:00 2001 From: zhl Date: Thu, 24 Dec 2020 19:20:20 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E7=8E=A9=E5=AE=B6?= =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8D=A1=E7=89=87=E9=94=99=E8=AF=AF=E7=9A=84?= =?UTF-8?q?bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/rooms/commands/BeginGameCommand.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rooms/commands/BeginGameCommand.ts b/src/rooms/commands/BeginGameCommand.ts index b067897..8f637c2 100644 --- a/src/rooms/commands/BeginGameCommand.ts +++ b/src/rooms/commands/BeginGameCommand.ts @@ -20,7 +20,7 @@ export class BeginGameCommand extends Command { let cardAll = card0.concat(card1); cardAll.randomSort(); this.state.cardQueue = cardAll; - let i = 1; + let i = 0; for (let [id] of this.state.players) { this.room.addCard(id, new GameEnv().playerInitNums[i++], 0); } From 4889699e71bd237f39128a0173f213090ac667e3 Mon Sep 17 00:00:00 2001 From: zhl Date: Thu, 24 Dec 2020 20:14:43 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E9=9A=8F=E4=BB=8E=E5=87=BA=E9=94=99=E7=9A=84=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/assistant.util.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/utils/assistant.util.ts b/src/utils/assistant.util.ts index 85b8c9a..e333eda 100644 --- a/src/utils/assistant.util.ts +++ b/src/utils/assistant.util.ts @@ -10,6 +10,7 @@ import {HeroCfg} from "../cfg/parsers/HeroCfg"; import {EffectType} from "../cfg/enums/EffectType"; import {CardType} from "../cfg/enums/CardType"; import {GameEnv} from "../cfg/GameEnv"; +import {error} from "../common/Debug"; let assistantUtil = { @@ -160,7 +161,7 @@ let assistantUtil = { for (let card of cards) { let effect = effectMap.get(card.effect); // if (effect.type_id == EffectType.unit && dstPlayer.unitCfgs.has(card.effect + '')) { - if (effect.type_id == EffectType.unit && !noMorePet) { + if (card.type == CardType.variable_unit && !noMorePet) { result = card; break; } else if (effect.type_id == EffectType.skill) { @@ -171,6 +172,7 @@ let assistantUtil = { result = spellCards.randomOne(); } if (!result) { + error(`无法选择随从或法术, 随从数: ${petCount}, 法术牌数量: ${spellCards.length}`); return null; } let targetType: SkillTargetType = CfgMan.getTargetByCard(result.effect); From e0b76dc2a63f973199b9bff891eeef283f3cb685 Mon Sep 17 00:00:00 2001 From: zhl Date: Thu, 24 Dec 2020 20:23:57 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=9C=BA=E5=99=A8?= =?UTF-8?q?=E4=BA=BA=E7=9A=84=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/robot/Robot.ts | 2 +- src/robot/RobotClient.ts | 2 +- src/utils/assistant.util.ts | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/robot/Robot.ts b/src/robot/Robot.ts index 262b7be..619295a 100644 --- a/src/robot/Robot.ts +++ b/src/robot/Robot.ts @@ -46,7 +46,6 @@ export class Robot { addListeners() { let self = this; this.room.onMessage("*", (type, data) => { - debug("[ROBOT] received message:", type, "=>", data); switch (type) { case 'draw_card_s2c': // if (data.player == self.sessionId) { @@ -56,6 +55,7 @@ export class Robot { case 'player_ready_s2c': break; case 'eat_card_s2c': + debug("[ROBOT] received message:", type, "=>", data); if (data.errcode == 0 && data.player == self.sessionId) { self.selectPet(); } diff --git a/src/robot/RobotClient.ts b/src/robot/RobotClient.ts index b268ab3..568d6c1 100644 --- a/src/robot/RobotClient.ts +++ b/src/robot/RobotClient.ts @@ -100,7 +100,7 @@ export class RobotClient implements Client { } public send(messageOrType: any, messageOrOptions?: any | ISendOptions, options?: ISendOptions) { - log(`receive server msg: ${messageOrType}, ${messageOrOptions}`); + // log(`receive server msg: ${messageOrType}, ${messageOrOptions}`); let self = this; if (!this.active) { return; diff --git a/src/utils/assistant.util.ts b/src/utils/assistant.util.ts index e333eda..440b68c 100644 --- a/src/utils/assistant.util.ts +++ b/src/utils/assistant.util.ts @@ -10,7 +10,7 @@ import {HeroCfg} from "../cfg/parsers/HeroCfg"; import {EffectType} from "../cfg/enums/EffectType"; import {CardType} from "../cfg/enums/CardType"; import {GameEnv} from "../cfg/GameEnv"; -import {error} from "../common/Debug"; +import {error, robotLog} from "../common/Debug"; let assistantUtil = { @@ -175,6 +175,7 @@ let assistantUtil = { error(`无法选择随从或法术, 随从数: ${petCount}, 法术牌数量: ${spellCards.length}`); return null; } + robotLog(`选择: ${result.effect} 类型: ${effectMap.get(result.effect).type_id}`) let targetType: SkillTargetType = CfgMan.getTargetByCard(result.effect); let targetPlayer; let targetPos; From 54fc69d9ef81085ef649f52940d4d815f3236eb8 Mon Sep 17 00:00:00 2001 From: zhl Date: Thu, 24 Dec 2020 20:33:50 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9C=BA=E5=99=A8?= =?UTF-8?q?=E4=BA=BA=E9=80=89=E6=8B=A9=E6=B3=95=E6=9C=AF=E6=88=96=E9=9A=8F?= =?UTF-8?q?=E4=BB=8E=E7=9A=84=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/assistant.util.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/utils/assistant.util.ts b/src/utils/assistant.util.ts index 440b68c..170b406 100644 --- a/src/utils/assistant.util.ts +++ b/src/utils/assistant.util.ts @@ -153,15 +153,16 @@ let assistantUtil = { let effectMap: Map = global.$cfg.get(BaseConst.EFFECTCARD); let spellCards: Card[] = []; // 优先取随从 - let petCount = 1; + let petCount = 0; for (let [,pet] of dstPlayer.pets) { - if (pet.state == 1) petCount ++; + if (pet.state == 1 && !pet.isHero) petCount ++; } let noMorePet = petCount >= new GameEnv().maxPlayerPetCount; + let noPet = Math.random2(0, 100) > 70; for (let card of cards) { let effect = effectMap.get(card.effect); // if (effect.type_id == EffectType.unit && dstPlayer.unitCfgs.has(card.effect + '')) { - if (card.type == CardType.variable_unit && !noMorePet) { + if (card.type == CardType.variable_unit && !noMorePet && !noPet) { result = card; break; } else if (effect.type_id == EffectType.skill) { From 517e622fa6e6ee7b8eefbc1829257ab07d53fc64 Mon Sep 17 00:00:00 2001 From: zhl Date: Thu, 24 Dec 2020 20:41:59 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9C=BA=E5=99=A8?= =?UTF-8?q?=E4=BA=BA=E9=80=89=E6=8B=A9=E6=B3=95=E6=9C=AF=E6=88=96=E9=9A=8F?= =?UTF-8?q?=E4=BB=8E=E7=9A=84=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/assistant.util.ts | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/utils/assistant.util.ts b/src/utils/assistant.util.ts index 170b406..ae6154e 100644 --- a/src/utils/assistant.util.ts +++ b/src/utils/assistant.util.ts @@ -152,26 +152,39 @@ let assistantUtil = { let result: Card; let effectMap: Map = global.$cfg.get(BaseConst.EFFECTCARD); let spellCards: Card[] = []; + let petCards: Card[] = []; + // 优先取随从 let petCount = 0; for (let [,pet] of dstPlayer.pets) { if (pet.state == 1 && !pet.isHero) petCount ++; } let noMorePet = petCount >= new GameEnv().maxPlayerPetCount; + let noPet = Math.random2(0, 100) > 70; + for (let card of cards) { - let effect = effectMap.get(card.effect); - // if (effect.type_id == EffectType.unit && dstPlayer.unitCfgs.has(card.effect + '')) { - if (card.type == CardType.variable_unit && !noMorePet && !noPet) { - result = card; - break; - } else if (effect.type_id == EffectType.skill) { + if (card.type == CardType.variable_unit) { + petCards.push(card); + } else if (card.type == CardType.general) { spellCards.push(card); } } - if (!result) { + if (!noMorePet && !noPet && petCards.length > 0) { + result = petCards.randomOne(); + } + + if (!result && spellCards.length > 0) { result = spellCards.randomOne(); } + let oldpos = -1; + if (!result && petCards.length > 0) { + result = petCards.randomOne(); + if (noMorePet) { + oldpos = 1; + } + } + if (!result) { error(`无法选择随从或法术, 随从数: ${petCount}, 法术牌数量: ${spellCards.length}`); return null; @@ -228,7 +241,8 @@ let assistantUtil = { card: result.id, player: targetPlayer?.id, pos: targetPos, - effCards + effCards, + oldpos } }, From af8dccbe27e22eeed5c6b49427acba1a74443be5 Mon Sep 17 00:00:00 2001 From: zhl Date: Fri, 25 Dec 2020 11:07:35 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9C=BA=E5=99=A8?= =?UTF-8?q?=E4=BA=BA=E7=9B=B8=E5=85=B3=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/robot/Robot.ts | 7 ++++--- src/robot/RobotClient.ts | 1 + src/utils/assistant.util.ts | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/robot/Robot.ts b/src/robot/Robot.ts index 619295a..81e5005 100644 --- a/src/robot/Robot.ts +++ b/src/robot/Robot.ts @@ -55,8 +55,8 @@ export class Robot { case 'player_ready_s2c': break; case 'eat_card_s2c': - debug("[ROBOT] received message:", type, "=>", data); if (data.errcode == 0 && data.player == self.sessionId) { + debug(`吃牌成功: ${self.sessionId}`); self.selectPet(); } break; @@ -64,7 +64,7 @@ export class Robot { }); this.room.onLeave(function () { - debug("[ROBOT] LEFT ROOM", arguments); + debug("LEFT ROOM", arguments); self.room.removeAllListeners(); self.room.leave(); }); @@ -165,6 +165,7 @@ export class Robot { return; } let cardIds = cards.map(o => o.id); + log(`discard: ${self.sessionId} ${cardIds}`); self.reply('discard_card_c2s', { cards: cardIds }); @@ -200,7 +201,7 @@ export class Robot { * @private */ private eatCard(cardIds: number[], target: number) { - log(`${this.sessionId} 吃牌 ${cardIds} -> ${target}`); + log(`吃牌: ${this.sessionId} ${cardIds} -> ${target}`); this.reply('eat_card_c2s', { cards: cardIds, target diff --git a/src/robot/RobotClient.ts b/src/robot/RobotClient.ts index 568d6c1..bda767b 100644 --- a/src/robot/RobotClient.ts +++ b/src/robot/RobotClient.ts @@ -142,6 +142,7 @@ export class RobotClient implements Client { return; } let cardIds = cards.map(o => o.id); + log(`discard: ${self.sessionId} ${cardIds}`); self.reply('discard_card_c2s', { cards: cardIds }); diff --git a/src/utils/assistant.util.ts b/src/utils/assistant.util.ts index ae6154e..9baff0d 100644 --- a/src/utils/assistant.util.ts +++ b/src/utils/assistant.util.ts @@ -189,7 +189,7 @@ let assistantUtil = { error(`无法选择随从或法术, 随从数: ${petCount}, 法术牌数量: ${spellCards.length}`); return null; } - robotLog(`选择: ${result.effect} 类型: ${effectMap.get(result.effect).type_id}`) + robotLog(`选择随从或法术 ${dstPlayer.id}: ${result.effect} 类型: ${effectMap.get(result.effect).type_id == EffectType.variable_unit ? '随从' : '法术'}`) let targetType: SkillTargetType = CfgMan.getTargetByCard(result.effect); let targetPlayer; let targetPos; From 9bb5c397cc22b71658ab925fa012291d3c75ea17 Mon Sep 17 00:00:00 2001 From: zhl Date: Fri, 25 Dec 2020 11:19:28 +0800 Subject: [PATCH 7/8] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9C=BA=E5=99=A8?= =?UTF-8?q?=E4=BA=BA=E7=9B=B8=E5=85=B3=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/robot/Robot.ts | 4 ++-- src/utils/assistant.util.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/robot/Robot.ts b/src/robot/Robot.ts index 81e5005..4a51c13 100644 --- a/src/robot/Robot.ts +++ b/src/robot/Robot.ts @@ -56,7 +56,7 @@ export class Robot { break; case 'eat_card_s2c': if (data.errcode == 0 && data.player == self.sessionId) { - debug(`吃牌成功: ${self.sessionId}`); + debug(`eat_success: ${self.sessionId}`); self.selectPet(); } break; @@ -201,7 +201,7 @@ export class Robot { * @private */ private eatCard(cardIds: number[], target: number) { - log(`吃牌: ${this.sessionId} ${cardIds} -> ${target}`); + log(`eta_card: ${this.sessionId} ${cardIds} -> ${target}`); this.reply('eat_card_c2s', { cards: cardIds, target diff --git a/src/utils/assistant.util.ts b/src/utils/assistant.util.ts index 9baff0d..5d900ab 100644 --- a/src/utils/assistant.util.ts +++ b/src/utils/assistant.util.ts @@ -189,7 +189,7 @@ let assistantUtil = { error(`无法选择随从或法术, 随从数: ${petCount}, 法术牌数量: ${spellCards.length}`); return null; } - robotLog(`选择随从或法术 ${dstPlayer.id}: ${result.effect} 类型: ${effectMap.get(result.effect).type_id == EffectType.variable_unit ? '随从' : '法术'}`) + robotLog(`select_pet ${dstPlayer.id}: ${result.effect} 类型: ${effectMap.get(result.effect).type_id == EffectType.skill ? '法术' : '随从'}`) let targetType: SkillTargetType = CfgMan.getTargetByCard(result.effect); let targetPlayer; let targetPos; From b6a90db8672d8f61102f3fa0f17a166012e9cf35 Mon Sep 17 00:00:00 2001 From: zhl Date: Fri, 25 Dec 2020 11:29:57 +0800 Subject: [PATCH 8/8] =?UTF-8?q?=E8=8B=B1=E9=9B=84=E8=A1=80=E9=87=8F?= =?UTF-8?q?=E5=8F=98=E5=8C=96=E5=A2=9E=E5=8A=A0=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/rooms/RoomExtMethod.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rooms/RoomExtMethod.ts b/src/rooms/RoomExtMethod.ts index bbe16f7..3c0f262 100644 --- a/src/rooms/RoomExtMethod.ts +++ b/src/rooms/RoomExtMethod.ts @@ -113,6 +113,7 @@ Object.defineProperties(Room.prototype, { return 0; } else { let dstHp = player.hp + (hp | 0); + debugRoom(`更新血量: ${player.id} ${player.hp} -> ${hp}`); if (dstHp <= 0) { dstHp = 0; this.dispatcher.dispatch(new PlayDeadCommand(), {player: player});