Skip to content

Commit

Permalink
优化危机合约地图信息的 CatTwo 字段,使其为本次危机合约的赛季名称
Browse files Browse the repository at this point in the history
  • Loading branch information
Lixuhuilll committed Dec 12, 2023
1 parent 09219c5 commit 30116a6
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
package plus.maa.backend.service.model.parser;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
import plus.maa.backend.repository.entity.ArkLevel;
import plus.maa.backend.repository.entity.gamedata.ArkCrisisV2Info;
import plus.maa.backend.repository.entity.gamedata.ArkTilePos;
import plus.maa.backend.service.ArkGameDataService;
import plus.maa.backend.service.model.ArkLevelType;

import java.util.Optional;

@Component
@RequiredArgsConstructor
public class RuneParser implements ArkLevelParser {

private final ArkGameDataService dataService;

@Override
public boolean supportType(ArkLevelType type) {
return ArkLevelType.RUNE.equals(type);
Expand All @@ -15,7 +24,12 @@ public boolean supportType(ArkLevelType type) {
@Override
public ArkLevel parseLevel(ArkLevel level, ArkTilePos tilePos) {
level.setCatOne(ArkLevelType.RUNE.getDisplay());
level.setCatTwo(tilePos.getCode());
level.setCatTwo(
Optional.ofNullable(level.getStageId())
.map(dataService::findCrisisV2InfoById)
.map(ArkCrisisV2Info::getName)
.orElse(tilePos.getCode())
);
level.setCatThree(level.getName());
return level;
}
Expand Down

0 comments on commit 30116a6

Please sign in to comment.