重构一些方法
This commit is contained in:
parent
a573dc4be6
commit
002cc8fc35
@ -44,7 +44,7 @@ export class DiscardCommand extends Command<CardGameState, { client: Client, car
|
||||
}
|
||||
this.state.cards.clear();
|
||||
//停止出牌计时, 并更新player.extraTime;
|
||||
if (this.room.mainClock && this.room.mainClock.active) {
|
||||
if (this.room.mainClock?.active) {
|
||||
let maxTime = singleton(GameEnv).maxDiscardTime * 1000;
|
||||
let count = this.room.mainClock.elapsedTime - maxTime;
|
||||
let newCount = player.extraTime - count;
|
||||
|
@ -32,7 +32,7 @@ export class EatConfirmCommand extends Command<CardGameState, { timeUp: boolean
|
||||
}
|
||||
if (giveUpCount >= playerCount) {
|
||||
// 所有人都放弃了, 则取消定时, 直接进入下一轮
|
||||
if (this.room.mainClock && this.room.mainClock.active) {
|
||||
if (this.room.mainClock?.active) {
|
||||
this.room.mainClock.clear();
|
||||
}
|
||||
return [new TurnEndCommand()];
|
||||
@ -67,7 +67,7 @@ export class EatConfirmCommand extends Command<CardGameState, { timeUp: boolean
|
||||
// 吃牌逻辑
|
||||
if (player != null && (isFirst || timeUp)) {
|
||||
// 如果有吃牌计时的话,停止吃牌计时
|
||||
if (this.room.mainClock && this.room.mainClock.active) {
|
||||
if (this.room.mainClock?.active) {
|
||||
this.room.mainClock.clear();
|
||||
}
|
||||
for (let id of cards) {
|
||||
|
@ -72,7 +72,7 @@ export class SelectPetCommand extends Command<CardGameState, {client: Client,
|
||||
return;
|
||||
}
|
||||
//停止选随从计时, 并更新player.extraTime;
|
||||
if (this.room.mainClock && this.room.mainClock.active) {
|
||||
if (this.room.mainClock?.active) {
|
||||
let count = this.room.mainClock.elapsedTime - singleton(GameEnv).playerActTime * 1000;
|
||||
let newCount = player.extraTime - count;
|
||||
player.extraTime = Math.max(newCount, 0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user