机器人出牌时, 增加根据配置来判断是否能吃牌

This commit is contained in:
zhl 2021-02-26 12:03:24 +08:00
parent 9ba8ef5b67
commit b57070a799
5 changed files with 31 additions and 3 deletions

View File

@ -58,6 +58,10 @@ export class GameEnv {
public emptyRoundTime: number;
// 玩家初始卡牌数
public playerInitNums: number[] = [];
// 初级场能否吃牌
public canEatBase: boolean;
// 进阶场能否吃牌
public canEatAdv: boolean;
public init(data: Map<number, BaseCfg>) {
this.initCardNum = data.get(BaseConst.INIT_CARD_NUM).value;
@ -92,5 +96,7 @@ export class GameEnv {
data.get(BaseConst.PLAYER3_INIT_NUM).value,
data.get(BaseConst.PLAYER4_INIT_NUM).value,
]
this.canEatBase = !!data.get(BaseConst.CAN_EAT_BASE).value;
this.canEatAdv = !!data.get(BaseConst.CAN_EAT_ADV).value;
}
}

View File

@ -56,7 +56,10 @@ export class BaseConst {
public static readonly PLAYER2_INIT_NUM = 99028
public static readonly PLAYER3_INIT_NUM = 99029
public static readonly PLAYER4_INIT_NUM = 99030
// 初级场能否吃牌
public static readonly CAN_EAT_BASE = 99039
// 进阶场能否吃牌
public static readonly CAN_EAT_ADV = 99040
public static readonly COMPOUND = 'compound'
public static readonly EFFECTCARD = 'effectcard'

View File

@ -4,6 +4,7 @@ import {GameStateConst} from "../constants/GameStateConst";
import {Player} from "../rooms/schema/Player";
import assistantUtil from "../utils/assistant.util";
import {delay, wait} from "../decorators/cfg";
import { GameEnv } from '../cfg/GameEnv'
export class Robot {
host: string;
@ -159,7 +160,13 @@ export class Robot {
@wait('maxDiscardTime')
private async discard() {
let targetCard
if (this.room.state.cards.size == 1) {
let canEat = false
if (this.room.state.advMode && new GameEnv().canEatAdv) {
canEat = true
} else if (!this.room.state.advMode && new GameEnv().canEatBase) {
canEat = true
}
if (this.room.state.cards.size == 1 && canEat) {
targetCard =[...this.room.state.cards.values()][0];
}
let self = this;

View File

@ -8,6 +8,7 @@ import {Card} from "../rooms/schema/Card";
import {Player} from "../rooms/schema/Player";
import assistantUtil from "../utils/assistant.util";
import {wait} from "../decorators/cfg";
import { GameEnv } from '../cfg/GameEnv'
/**
*
@ -136,7 +137,14 @@ export class RobotClient implements Client {
@wait('maxDiscardTime')
private async discard() {
let targetCard
if (this.svrstate.cards.size == 1) {
let canEat = false
if (this.svrstate.advMode && new GameEnv().canEatAdv) {
canEat = true
} else if (!this.svrstate.advMode && new GameEnv().canEatBase) {
canEat = true
}
if (this.svrstate.cards.size == 1 && canEat) {
targetCard =[...this.svrstate.cards.values()][0];
}
let self = this;

View File

@ -81,4 +81,8 @@ export class CardGameState extends Schema {
this.currentTurn = val;
this.$listeners?.currentTurn?.invoke(val, preVal);
}
get advMode() {
return this.mode == 1 || this.mode == 2
}
}