106 lines
4.5 KiB
TypeScript
106 lines
4.5 KiB
TypeScript
import {BaseCfg} from "./parsers/BaseCfg";
|
|
import {BaseConst} from "../constants/BaseConst";
|
|
import {singleton} from "../decorators/singleton.decorator";
|
|
|
|
@singleton
|
|
export class GameEnv {
|
|
// 初始手牌数量
|
|
public initCardNum: number;
|
|
// 可更换的初始手牌上限
|
|
public cardChangeNum : number;
|
|
// 更换初始手牌时限
|
|
public cardChangeTime: number;
|
|
// 每回合发牌数量
|
|
public roundDrawNum: number;
|
|
// 每满几论决斗一次
|
|
public duelRoundNum: number;
|
|
// 第几次决斗后游戏结束
|
|
public maxDuelNum: number;
|
|
// 玩家手牌数量上限
|
|
public maxCardNum: number;
|
|
// 出牌公共时限
|
|
public maxDiscardTime: number;
|
|
// 吃牌公共时限
|
|
public maxEatTime: number;
|
|
// 操作公共时限
|
|
public playerActTime: number;
|
|
// 玩家灵活时限
|
|
public maxExtTime: number;
|
|
// 每回合增加玩家灵活时限数值
|
|
public roundExtTime: number;
|
|
// 玩家随从上限
|
|
public maxPlayerPetCount: number;
|
|
// 结算显示时间
|
|
public resultShowTime: number;
|
|
// 基本奖励分
|
|
public baseAddScore: number;
|
|
// 额外奖励分
|
|
public extraAddScore: number;
|
|
// 游戏结果显示时间, 也是游戏重开等待时间
|
|
public gameResultTime: number;
|
|
// 匹配等待时间, 时间结束后, 填充机器人;
|
|
public waitingPlayerTime: number;
|
|
// 匹配等待时, 每进入一个玩家, 等待时间延长n秒
|
|
public waitingPlayerOnePlus: number;
|
|
// 英雄选择时间
|
|
public pickHeroTime: number;
|
|
// 机器人操作最小时间
|
|
public robotActTimeMin: number;
|
|
// 机器人操作最大时间
|
|
public robotActTimeMax: number;
|
|
// 队友死亡后,补牌数量
|
|
public teamDeadAddNum: number;
|
|
// 胡牌张数(自摸)
|
|
public selfEatCount: number;
|
|
// 胡牌张数(吃牌)
|
|
public otherEatCount: number;
|
|
// 轮空轮的间隔时间
|
|
public emptyRoundTime: number;
|
|
// 玩家初始卡牌数
|
|
public playerInitNums: number[] = [];
|
|
// 初级场能否吃牌
|
|
public canEatBase: boolean;
|
|
// 进阶场能否吃牌
|
|
public canEatAdv: boolean;
|
|
// 随从继承战力的比率
|
|
public petInheritRate: number;
|
|
|
|
public init(data: Map<number, BaseCfg>) {
|
|
this.initCardNum = data.get(BaseConst.INIT_CARD_NUM).value;
|
|
this.cardChangeNum = data.get(BaseConst.CARD_CHANGE_NUM).value;
|
|
this.cardChangeTime = data.get(BaseConst.CARD_CHANGE_TIME).value;
|
|
this.roundDrawNum = data.get(BaseConst.ROUND_DRAW_NUM).value;
|
|
this.duelRoundNum = data.get(BaseConst.DUEL_ROUND_NUM).value;
|
|
this.maxDuelNum = data.get(BaseConst.MAX_DUEL_NUM).value;
|
|
this.maxCardNum = data.get(BaseConst.MAX_CARD_NUM).value;
|
|
this.maxDiscardTime = data.get(BaseConst.MAX_DISCARD_TIME).value;
|
|
this.maxEatTime = data.get(BaseConst.MAX_EAT_TIME).value;
|
|
this.playerActTime = data.get(BaseConst.PLAYER_ACT_TIME).value;
|
|
this.maxExtTime = data.get(BaseConst.MAX_EXT_TIME).value;
|
|
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;
|
|
this.gameResultTime = data.get(BaseConst.GAME_RESULT_TIME).value;
|
|
this.waitingPlayerTime = data.get(BaseConst.WAITING_PLAYER_TIME).value;
|
|
this.waitingPlayerOnePlus = data.get(BaseConst.WAITING_PLAYER_ONEPLUS).value;
|
|
this.pickHeroTime = data.get(BaseConst.PICK_HERO_TIME).value;
|
|
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;
|
|
this.playerInitNums = [
|
|
data.get(BaseConst.PLAYER1_INIT_NUM).value,
|
|
data.get(BaseConst.PLAYER2_INIT_NUM).value,
|
|
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;
|
|
this.petInheritRate = data.get(BaseConst.PET_INHERIT_RATE).value / 100;
|
|
}
|
|
}
|