forked from Electro1512/MetroidAPrime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathItemPool.py
179 lines (157 loc) · 6.17 KB
/
ItemPool.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
from typing import TYPE_CHECKING, List
from BaseClasses import ItemClassification
from .Items import (
PROGRESSIVE_ITEM_MAPPING,
MetroidPrimeItem,
ProgressiveUpgrade,
SuitUpgrade,
get_item_for_options,
artifact_table,
)
from .Items import MetroidPrimeItem
if TYPE_CHECKING:
from . import MetroidPrimeWorld
def generate_start_inventory(world: "MetroidPrimeWorld") -> List[str]:
assert world.starting_room_data.selected_loadout
starting_items = [
get_item_for_options(
world, world.starting_room_data.selected_loadout.starting_beam
).value
]
starting_items.extend(
get_item_for_options(world, item).value
for item in world.starting_room_data.selected_loadout.loadout
)
if not world.options.shuffle_scan_visor.value:
starting_items.append(SuitUpgrade.Scan_Visor.value)
return starting_items
def generate_item_pool(world: "MetroidPrimeWorld") -> List[MetroidPrimeItem]:
# These are items that are only added if certain options are set
items: List[MetroidPrimeItem] = [
*[world.create_item(artifact) for artifact in artifact_table],
world.create_item(SuitUpgrade.Morph_Ball.value),
world.create_item(SuitUpgrade.Morph_Ball_Bomb.value),
world.create_item(SuitUpgrade.Thermal_Visor.value),
world.create_item(SuitUpgrade.X_Ray_Visor.value),
world.create_item(SuitUpgrade.Scan_Visor.value),
world.create_item(SuitUpgrade.Grapple_Beam.value),
world.create_item(SuitUpgrade.Space_Jump_Boots.value),
world.create_item(SuitUpgrade.Spider_Ball.value),
world.create_item(SuitUpgrade.Boost_Ball.value),
world.create_item(SuitUpgrade.Varia_Suit.value),
world.create_item(SuitUpgrade.Gravity_Suit.value),
world.create_item(SuitUpgrade.Phazon_Suit.value),
]
# Add missiles
progressive_missiles = 8
for _ in range(progressive_missiles):
items.append(
world.create_item(SuitUpgrade.Missile_Expansion.value, ItemClassification.progression)
)
items.append(
world.create_item(
get_item_for_options(world, SuitUpgrade.Missile_Launcher).value,
ItemClassification.progression,
)
)
# Add power bombs
max_power_bombs = 5
for _ in range(0, max_power_bombs - 1): # Main PB option will add one more
items.append(
world.create_item(
SuitUpgrade.Power_Bomb_Expansion.value, ItemClassification.useful
)
)
items.append(
world.create_item(
get_item_for_options(world, SuitUpgrade.Main_Power_Bomb).value,
ItemClassification.progression,
)
)
# Add energy tanks
max_tanks = 14
progression_tanks = 8
for i in range(0, max_tanks):
items.append(
world.create_item(
"Energy Tank",
(
ItemClassification.progression
if i < progression_tanks
else ItemClassification.useful
),
)
)
# Add beams and combos
if world.options.progressive_beam_upgrades.value:
for progressive_item in PROGRESSIVE_ITEM_MAPPING:
for index in range(3):
items.append(
world.create_item(
progressive_item.value,
get_progressive_beam_classification(
world, progressive_item, index
),
)
)
else:
items.append(world.create_item(SuitUpgrade.Power_Beam.value))
items.append(world.create_item(SuitUpgrade.Wave_Beam.value))
items.append(world.create_item(SuitUpgrade.Ice_Beam.value))
items.append(world.create_item(SuitUpgrade.Plasma_Beam.value))
items.append(world.create_item(SuitUpgrade.Charge_Beam.value))
items.append(world.create_item(SuitUpgrade.Super_Missile.value))
combo_classification = (
ItemClassification.progression
if requires_beam_combos_for_progression(world)
else ItemClassification.useful
)
items.append(
world.create_item(SuitUpgrade.Wavebuster.value, combo_classification)
)
items.append(
world.create_item(SuitUpgrade.Ice_Spreader.value, combo_classification)
)
items.append(
world.create_item(SuitUpgrade.Flamethrower.value, combo_classification)
)
assert world.starting_room_data.selected_loadout
items_to_remove: List[str] = [
# starting items
*[item for item in generate_start_inventory(world)],
# prefilled items
*[item for item in world.prefilled_item_map.values()],
]
for item in items_to_remove:
for i in range(len(items)):
if items[i].name == item:
items.pop(i)
break
# Fill Missiles for rest
for _ in range(len(items), 100 - len(world.prefilled_item_map.values())):
items.append(
world.create_item(
SuitUpgrade.Missile_Expansion.value, ItemClassification.filler
)
)
return items
def requires_beam_combos_for_progression(world: "MetroidPrimeWorld") -> bool:
return (
world.options.blast_shield_available_types.value
== world.options.blast_shield_available_types.option_all
and world.options.blast_shield_randomization.value
!= world.options.blast_shield_randomization.option_none # type: ignore
)
def get_progressive_beam_classification(
world: "MetroidPrimeWorld", progressive_item: ProgressiveUpgrade, index: int
) -> ItemClassification:
# Charge Beam
if index < 2:
return ItemClassification.progression
# Beam Combos
if index == 2 and (
progressive_item == ProgressiveUpgrade.Progressive_Power_Beam
or requires_beam_combos_for_progression(world)
):
return ItemClassification.progression
return ItemClassification.useful