refactor: Replace HashMap with Map in GameConstants & CombineManager

This commit is contained in:
Phong 2024-07-25 09:01:35 +07:00
parent 8cdf7a2e85
commit 0b8f9ad851
No known key found for this signature in database
GPG Key ID: E1E0260A8DE0C25D
2 changed files with 5 additions and 5 deletions

View File

@ -59,7 +59,7 @@ public final class GameConstants {
public static final int[] DEFAULT_ABILITY_HASHES = public static final int[] DEFAULT_ABILITY_HASHES =
Arrays.stream(DEFAULT_ABILITY_STRINGS).mapToInt(Utils::abilityHash).toArray(); Arrays.stream(DEFAULT_ABILITY_STRINGS).mapToInt(Utils::abilityHash).toArray();
public static final int DEFAULT_ABILITY_NAME = Utils.abilityHash("Default"); public static final int DEFAULT_ABILITY_NAME = Utils.abilityHash("Default");
public static final HashMap<Integer, Integer> YAE_MIKO_ITEM_TO_REGION_COMBINE_BONUS = new HashMap<>() {{ public static final Map<Integer, Integer> YAE_MIKO_ITEM_TO_REGION_COMBINE_BONUS = new HashMap<>() {{
put(104304, 1); put(104304, 1);
put(104307, 1); put(104307, 1);
put(104310, 2); put(104310, 2);
@ -72,7 +72,7 @@ public final class GameConstants {
put(104332, 4); put(104332, 4);
put(104335, 4); put(104335, 4);
}}; }};
public static final HashMap<Integer, List<Integer>> YAE_MIKO_REGION_TO_ITEM_COMBINE_BONUS = new HashMap<>() {{ public static final Map<Integer, List<Integer>> YAE_MIKO_REGION_TO_ITEM_COMBINE_BONUS = new HashMap<>() {{
put(1, List.of(104304, 104307)); put(1, List.of(104304, 104307));
put(2, List.of(104310, 104313, 104316)); put(2, List.of(104310, 104313, 104316));
put(3, List.of(104320, 104323, 104326)); put(3, List.of(104320, 104323, 104326));

View File

@ -128,7 +128,7 @@ public class CombineManger extends BaseGameSystem {
player.getInventory().addItem(combineBack); player.getInventory().addItem(combineBack);
result.getBack().add(combineBack); result.getBack().add(combineBack);
} else { } else {
HashMap<Integer, Integer> mapIdCount = new HashMap<>(); Map<Integer, Integer> mapIdCount = new HashMap<>();
for (int i = 0; i < luckyCount; i++) { for (int i = 0; i < luckyCount; i++) {
var randomId = combineData var randomId = combineData
.getMaterialItems() .getMaterialItems()
@ -152,10 +152,10 @@ public class CombineManger extends BaseGameSystem {
// material excluded) when crafting. The rarity is that of the base material." // material excluded) when crafting. The rarity is that of the base material."
// from wiki // from wiki
// map of material id to region id // map of material id to region id
HashMap<Integer, Integer> itemToRegion = GameConstants.YAE_MIKO_ITEM_TO_REGION_COMBINE_BONUS; Map<Integer, Integer> itemToRegion = GameConstants.YAE_MIKO_ITEM_TO_REGION_COMBINE_BONUS;
// get list of material id with every region // get list of material id with every region
HashMap<Integer, List<Integer>> regionToId = GameConstants.YAE_MIKO_REGION_TO_ITEM_COMBINE_BONUS; Map<Integer, List<Integer>> regionToId = GameConstants.YAE_MIKO_REGION_TO_ITEM_COMBINE_BONUS;
// check material id in itemToRegion // check material id in itemToRegion
int itemId = combineData.getMaterialItems().get(0).getItemId(); int itemId = combineData.getMaterialItems().get(0).getItemId();