mirror of
https://github.com/MarioSpore/Grinch-AP.git
synced 2025-10-21 20:21:32 -06:00
Pokemon Emerald: Randomize rock smash encounters (#3912)
* Pokemon Emerald: WIP add rock smash encounter randomization * Pokemon Emerald: Refactor encounter data on maps * Pokemon Emerald: Remove unused import * Pokemon Emerald: Swap StrEnum for regular Enum and use .value
This commit is contained in:
@@ -5,7 +5,7 @@ defined data (like location labels or usable pokemon species), some cleanup
|
||||
and sorting, and Warp methods.
|
||||
"""
|
||||
from dataclasses import dataclass
|
||||
from enum import IntEnum
|
||||
from enum import IntEnum, Enum
|
||||
import orjson
|
||||
from typing import Dict, List, NamedTuple, Optional, Set, FrozenSet, Tuple, Any, Union
|
||||
import pkgutil
|
||||
@@ -148,14 +148,20 @@ class EncounterTableData(NamedTuple):
|
||||
address: int
|
||||
|
||||
|
||||
# class EncounterType(StrEnum): # StrEnum introduced in python 3.11
|
||||
class EncounterType(Enum):
|
||||
LAND = "LAND"
|
||||
WATER = "WATER"
|
||||
FISHING = "FISHING"
|
||||
ROCK_SMASH = "ROCK_SMASH"
|
||||
|
||||
|
||||
@dataclass
|
||||
class MapData:
|
||||
name: str
|
||||
label: str
|
||||
header_address: int
|
||||
land_encounters: Optional[EncounterTableData]
|
||||
water_encounters: Optional[EncounterTableData]
|
||||
fishing_encounters: Optional[EncounterTableData]
|
||||
encounters: Dict[EncounterType, EncounterTableData]
|
||||
|
||||
|
||||
class EventData(NamedTuple):
|
||||
@@ -348,25 +354,27 @@ def _init() -> None:
|
||||
if map_name in IGNORABLE_MAPS:
|
||||
continue
|
||||
|
||||
land_encounters = None
|
||||
water_encounters = None
|
||||
fishing_encounters = None
|
||||
|
||||
encounter_tables: Dict[EncounterType, EncounterTableData] = {}
|
||||
if "land_encounters" in map_json:
|
||||
land_encounters = EncounterTableData(
|
||||
encounter_tables[EncounterType.LAND] = EncounterTableData(
|
||||
map_json["land_encounters"]["slots"],
|
||||
map_json["land_encounters"]["address"]
|
||||
)
|
||||
if "water_encounters" in map_json:
|
||||
water_encounters = EncounterTableData(
|
||||
encounter_tables[EncounterType.WATER] = EncounterTableData(
|
||||
map_json["water_encounters"]["slots"],
|
||||
map_json["water_encounters"]["address"]
|
||||
)
|
||||
if "fishing_encounters" in map_json:
|
||||
fishing_encounters = EncounterTableData(
|
||||
encounter_tables[EncounterType.FISHING] = EncounterTableData(
|
||||
map_json["fishing_encounters"]["slots"],
|
||||
map_json["fishing_encounters"]["address"]
|
||||
)
|
||||
if "rock_smash_encounters" in map_json:
|
||||
encounter_tables[EncounterType.ROCK_SMASH] = EncounterTableData(
|
||||
map_json["rock_smash_encounters"]["slots"],
|
||||
map_json["rock_smash_encounters"]["address"]
|
||||
)
|
||||
|
||||
# Derive a user-facing label
|
||||
label = []
|
||||
@@ -398,9 +406,7 @@ def _init() -> None:
|
||||
map_name,
|
||||
" ".join(label),
|
||||
map_json["header_address"],
|
||||
land_encounters,
|
||||
water_encounters,
|
||||
fishing_encounters
|
||||
encounter_tables
|
||||
)
|
||||
|
||||
# Load/merge region json files
|
||||
|
Reference in New Issue
Block a user