队友死后,不再将队友的牌移至自己手中,改为抽2张卡
This commit is contained in:
parent
3c56f0140d
commit
a10b071c69
@ -46,6 +46,8 @@ export class GameEnv {
|
||||
public robotActTimeMin: number;
|
||||
// 机器人操作最大时间
|
||||
public robotActTimeMax: number;
|
||||
// 队友死亡后,补牌数量
|
||||
public teamDeadAddNum: number;
|
||||
|
||||
public init(data: Map<number, BaseCfg>) {
|
||||
this.initCardNum = data.get(BaseConst.INIT_CARD_NUM).value;
|
||||
@ -70,5 +72,6 @@ export class GameEnv {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -43,6 +43,8 @@ export class BaseConst {
|
||||
public static readonly ROBOT_ACTTIME_MIN = 99021;
|
||||
// 机器人操作最大时间
|
||||
public static readonly ROBOT_ACTTIME_MAX = 99022;
|
||||
// 队友死亡后,补牌数量
|
||||
public static readonly TEAM_DEAD_ADDNUM = 99023
|
||||
|
||||
|
||||
|
||||
|
@ -9,13 +9,16 @@ let delayRun = function (max: number, min?: number) {
|
||||
}
|
||||
const baseCfg = singleton(GameEnv);
|
||||
|
||||
|
||||
/**
|
||||
* 根据配置项延迟执行的修饰器
|
||||
* @param type GameEnv中的字段名
|
||||
*/
|
||||
export function wait(type: string) {
|
||||
return (target: any,
|
||||
propertyKey: string,
|
||||
descriptor: PropertyDescriptor) => {
|
||||
const method = descriptor.value;
|
||||
descriptor.value = function(...args: any[]) {
|
||||
descriptor.value = function (...args: any[]) {
|
||||
// @ts-ignore
|
||||
let time = baseCfg[type] as number;
|
||||
const minDelay = baseCfg.robotActTimeMin;
|
||||
@ -33,12 +36,16 @@ export function wait(type: string) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据参数延迟执行的修饰器
|
||||
* @param num 最大延迟n秒
|
||||
*/
|
||||
export function delay(num: number) {
|
||||
return (target: any,
|
||||
propertyKey: string,
|
||||
descriptor: PropertyDescriptor) => {
|
||||
const method = descriptor.value;
|
||||
descriptor.value = function(...args: any[]) {
|
||||
descriptor.value = function (...args: any[]) {
|
||||
delayRun(num, 0)
|
||||
.then(() => {
|
||||
return method!.apply(this, args);
|
||||
|
@ -1,17 +1,9 @@
|
||||
import {Client, Room} from "colyseus.js";
|
||||
import {error, robotLog as log, robotLog as debug} from "../common/Debug";
|
||||
import {HeroCfg} from "../cfg/parsers/HeroCfg";
|
||||
import {BaseConst} from "../constants/BaseConst";
|
||||
import arrUtil from "../utils/array.util";
|
||||
import {GameStateConst} from "../constants/GameStateConst";
|
||||
import {Card} from "../rooms/schema/Card";
|
||||
import {Player} from "../rooms/schema/Player";
|
||||
import {EffectCardCfg} from "../cfg/parsers/EffectCardCfg";
|
||||
import {SkillTargetType} from "../rooms/logic/skill/SkillConst";
|
||||
import CfgMan from "../rooms/logic/CfgMan";
|
||||
import gameUtil from "../utils/game.util";
|
||||
import assistantUtil from "../utils/assistant.util";
|
||||
import {wait,delay} from "../decorators/cfg";
|
||||
import {delay, wait} from "../decorators/cfg";
|
||||
|
||||
export class Robot {
|
||||
host: string;
|
||||
@ -27,6 +19,7 @@ export class Robot {
|
||||
this.roomId = roomId;
|
||||
this.client = new Client(host);
|
||||
}
|
||||
|
||||
async connect() {
|
||||
try {
|
||||
this.room = await this.client.joinById(this.roomId);
|
||||
@ -218,7 +211,7 @@ export class Robot {
|
||||
* 放弃吃牌
|
||||
* @private
|
||||
*/
|
||||
private giveup () {
|
||||
private giveup() {
|
||||
this.reply('give_up_eat_c2s', {});
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {Client, Room} from "colyseus";
|
||||
import {Client} from "colyseus";
|
||||
import {ClientState, ISendOptions} from "colyseus/lib/transport/Transport";
|
||||
import {EventEmitter} from 'events';
|
||||
import {assistLog as log} from '../common/Debug';
|
||||
@ -9,6 +9,13 @@ import {Player} from "../rooms/schema/Player";
|
||||
import assistantUtil from "../utils/assistant.util";
|
||||
import {wait} from "../decorators/cfg";
|
||||
|
||||
/**
|
||||
* 服务端辅助机器人
|
||||
* 每个player加入房间后, 生成一个辅助机器人, 同时将active置为false
|
||||
* 玩家掉线后, 将对应的机器人active置为true, 机器人开始接手
|
||||
* 玩家重连后, 将对应的机器人active置为false, 机器人停止工作, 玩家接手
|
||||
* TODO: 根据客户端指令来关闭开启辅助机器人
|
||||
*/
|
||||
export class RobotClient implements Client {
|
||||
id: string;
|
||||
readyState: number;
|
||||
|
@ -2,6 +2,8 @@ import {Command} from "@colyseus/command";
|
||||
import {CardGameState} from "../schema/CardGameState";
|
||||
import {Player} from "../schema/Player";
|
||||
import {PlayerStateConst} from "../../constants/PlayerStateConst";
|
||||
import {singleton} from "../../common/Singleton";
|
||||
import {GameEnv} from "../../cfg/GameEnv";
|
||||
|
||||
/**
|
||||
* 玩家死亡
|
||||
@ -14,8 +16,10 @@ export class PlayDeadCommand extends Command<CardGameState, {player: Player}> {
|
||||
for (let [, p] of this.state.players) {
|
||||
if (p.id !== player.id && p.team == player.team) {
|
||||
if (p.state !== PlayerStateConst.PLAYER_DEAD) {
|
||||
let amount = p.cards.size;
|
||||
this.room.drawCardFromPlayer(p.id, player.id, amount);
|
||||
// let amount = p.cards.size;
|
||||
// this.room.drawCardFromPlayer(p.id, player.id, amount);
|
||||
// 20201216 18:32 修改
|
||||
this.room.addCard(p.id, singleton(GameEnv).teamDeadAddNum, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -9,11 +9,7 @@ import {Player} from "../rooms/schema/Player";
|
||||
import {HeroCfg} from "../cfg/parsers/HeroCfg";
|
||||
|
||||
let assistantUtil = {
|
||||
delay(max: number, min?: number) {
|
||||
min = min || 0;
|
||||
let milliseconds = (Math.random() * (max - min) + min) * 1000 | 0;
|
||||
return new Promise(resolve => setTimeout(resolve, milliseconds));
|
||||
},
|
||||
|
||||
/**
|
||||
* 检查是否可以吃牌
|
||||
* @param cardArr 待检查的卡组
|
||||
|
Loading…
x
Reference in New Issue
Block a user