Skip to content

Commit

Permalink
refactor: Replace HashMap with Map in GameConstants & CombineManager
Browse files Browse the repository at this point in the history
  • Loading branch information
Phong940253 committed Jul 25, 2024
1 parent 8cdf7a2 commit 0b8f9ad
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/main/java/emu/grasscutter/GameConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public final class GameConstants {
public static final int[] DEFAULT_ABILITY_HASHES =
Arrays.stream(DEFAULT_ABILITY_STRINGS).mapToInt(Utils::abilityHash).toArray();
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(104307, 1);
put(104310, 2);
Expand All @@ -72,7 +72,7 @@ public final class GameConstants {
put(104332, 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(2, List.of(104310, 104313, 104316));
put(3, List.of(104320, 104323, 104326));
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/emu/grasscutter/game/combine/CombineManger.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public CombineResult combineItem(Player player, int cid, int count, long avatarG
player.getInventory().addItem(combineBack);
result.getBack().add(combineBack);
} else {
HashMap<Integer, Integer> mapIdCount = new HashMap<>();
Map<Integer, Integer> mapIdCount = new HashMap<>();
for (int i = 0; i < luckyCount; i++) {
var randomId = combineData
.getMaterialItems()
Expand All @@ -152,10 +152,10 @@ public CombineResult combineItem(Player player, int cid, int count, long avatarG
// material excluded) when crafting. The rarity is that of the base material."
// from wiki
// 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
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
int itemId = combineData.getMaterialItems().get(0).getItemId();
Expand Down

0 comments on commit 0b8f9ad

Please sign in to comment.