三级火箭边界值更改

This commit is contained in:
tianfeng 2025-12-01 11:30:22 +08:00
parent 84f57ee119
commit e3aef26f0e
3 changed files with 7 additions and 2 deletions

View File

@ -264,7 +264,7 @@ public class RocketEnergyAggregator {
// 校验状态 // 校验状态
if (!rocketStatus.canAddEnergy()) { if (!rocketStatus.canAddEnergy()) {
log.warn("火箭不可充能, roomId={}, status={}", roomId, rocketStatus.getStatus()); log.warn("火箭不可充能, roomId={}, status={}", roomId, rocketStatus.getStatus());
throw new RuntimeException("火箭状态不允许充能"); return;
} }
// 记录增加前的状态 // 记录增加前的状态

View File

@ -63,7 +63,7 @@ public enum RocketLevel {
return switch (this) { return switch (this) {
case LEVEL_1 -> LEVEL_2; case LEVEL_1 -> LEVEL_2;
case LEVEL_2 -> LEVEL_3; case LEVEL_2 -> LEVEL_3;
case LEVEL_3 -> LEVEL_3; // 三级是最高级返回null表示需要重置 case LEVEL_3 -> null; // 三级是最高级返回null表示需要重置
}; };
} }

View File

@ -175,6 +175,11 @@ public class RocketStatus {
* @param targetLevel 目标等级 * @param targetLevel 目标等级
*/ */
public void upgradeToLevel(RocketConfigGateway configGateway, RocketLevel targetLevel) { public void upgradeToLevel(RocketConfigGateway configGateway, RocketLevel targetLevel) {
if (targetLevel == null) {
this.status = RocketStatusEnum.LAUNCHED;
return;
}
// 查询目标等级的配置 // 查询目标等级的配置
RocketConfig targetConfig = configGateway.findByLevel(targetLevel.getLevel()); RocketConfig targetConfig = configGateway.findByLevel(targetLevel.getLevel());
if (targetConfig == null || targetConfig.getStatus() != 1) { if (targetConfig == null || targetConfig.getStatus() != 1) {