重构代码, 将游戏规则相关常量放入RoomOptions
This commit is contained in:
parent
7dcf2aff0a
commit
de77d8cbae
@ -1,11 +1,28 @@
|
||||
import { singleton } from '../decorators/singleton.decorator'
|
||||
import { GameEnv } from './GameEnv'
|
||||
import { CardGameState } from '../rooms/schema/CardGameState'
|
||||
import {
|
||||
RULE_CANEAT,
|
||||
RULE_DROPCARD,
|
||||
RULE_MULTIPLEEAT, RULE_SINGLEEAT
|
||||
} from '../constants/GameRuleConst'
|
||||
|
||||
/**
|
||||
* 一个回合是否能多次吃牌
|
||||
* @type {string}
|
||||
*/
|
||||
export const RULE_MULTIPLEEAT = 'multipeat'
|
||||
/**
|
||||
* 是否必须弃牌
|
||||
* @type {string}
|
||||
*/
|
||||
export const RULE_DROPCARD = 'dropcard'
|
||||
/**
|
||||
* 当前游戏能否吃牌
|
||||
* @type {string}
|
||||
*/
|
||||
export const RULE_CANEAT = 'caneat'
|
||||
|
||||
/**
|
||||
* 单张牌能否下随从
|
||||
* @type {string}
|
||||
*/
|
||||
export const RULE_SINGLEEAT = 'singleeat'
|
||||
|
||||
@singleton
|
||||
export class RoomOptions {
|
||||
|
@ -1,21 +0,0 @@
|
||||
/**
|
||||
* 一个回合是否能多次吃牌
|
||||
* @type {string}
|
||||
*/
|
||||
export const RULE_MULTIPLEEAT = 'multipeat'
|
||||
/**
|
||||
* 是否必须弃牌
|
||||
* @type {string}
|
||||
*/
|
||||
export const RULE_DROPCARD = 'dropcard'
|
||||
/**
|
||||
* 当前游戏能否吃牌
|
||||
* @type {string}
|
||||
*/
|
||||
export const RULE_CANEAT = 'caneat'
|
||||
|
||||
/**
|
||||
* 单张牌能否下随从
|
||||
* @type {string}
|
||||
*/
|
||||
export const RULE_SINGLEEAT = 'singleeat'
|
@ -4,8 +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 { RoomOptions } from '../cfg/RoomOptions'
|
||||
import { RULE_CANEAT } from '../constants/GameRuleConst'
|
||||
import { RULE_CANEAT } from '../cfg/RoomOptions'
|
||||
|
||||
export class Robot {
|
||||
host: string
|
||||
|
@ -8,8 +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 { RoomOptions } from '../cfg/RoomOptions'
|
||||
import { RULE_CANEAT } from '../constants/GameRuleConst'
|
||||
import { RULE_CANEAT } from '../cfg/RoomOptions'
|
||||
|
||||
/**
|
||||
* 服务端辅助机器人
|
||||
|
@ -9,10 +9,9 @@ import { TurnEndCommand } from './TurnEndCommand'
|
||||
import { Card } from '../schema/Card'
|
||||
import { Wait } from './Wait'
|
||||
import { StateTypeEnum } from '../enums/StateTypeEnum'
|
||||
import { RoomOptions } from '../../cfg/RoomOptions'
|
||||
import { RULE_CANEAT, RULE_SINGLEEAT } from '../../cfg/RoomOptions'
|
||||
import { ClockNameConst } from '../../constants/ClockNameConst'
|
||||
import { stopDrawCardClock } from '../../utils/clock.util'
|
||||
import { RULE_CANEAT, RULE_SINGLEEAT } from '../../constants/GameRuleConst'
|
||||
|
||||
/**
|
||||
* 出牌
|
||||
|
@ -4,13 +4,12 @@ import { Client } from 'colyseus'
|
||||
import { TurnEndCommand } from './TurnEndCommand'
|
||||
import { GameEnv } from '../../cfg/GameEnv'
|
||||
import gameUtil from '../../utils/game.util'
|
||||
import { RoomOptions } from '../../cfg/RoomOptions'
|
||||
import { RULE_MULTIPLEEAT } from '../../cfg/RoomOptions'
|
||||
import assistantUtil from '../../utils/assistant.util'
|
||||
import { GameStateConst } from '../../constants/GameStateConst'
|
||||
import { debugRoom } from '../../common/Debug'
|
||||
import { ClockNameConst } from '../../constants/ClockNameConst'
|
||||
import { addDrawCardClock } from '../../utils/clock.util'
|
||||
import { RULE_MULTIPLEEAT } from '../../constants/GameRuleConst'
|
||||
|
||||
/**
|
||||
* 选择随从或者法术
|
||||
|
@ -1,12 +1,11 @@
|
||||
import { Room } from 'colyseus'
|
||||
import { RoomOptions } from '../cfg/RoomOptions'
|
||||
import { RULE_DROPCARD } from '../cfg/RoomOptions'
|
||||
import { debugRoom } from '../common/Debug'
|
||||
import { DiscardCommand } from '../rooms/commands/DiscardCommand'
|
||||
import { TurnEndCommand } from '../rooms/commands/TurnEndCommand'
|
||||
import { ClockNameConst } from '../constants/ClockNameConst'
|
||||
import { GameEnv } from '../cfg/GameEnv'
|
||||
import { Player } from '../rooms/schema/Player'
|
||||
import { RULE_DROPCARD } from '../constants/GameRuleConst'
|
||||
|
||||
/**
|
||||
* 添加出牌计时器
|
||||
|
Loading…
x
Reference in New Issue
Block a user