Skip to content

Commit

Permalink
Merge pull request #14 from DodoBirby/main
Browse files Browse the repository at this point in the history
Added additional traps for 1.0
  • Loading branch information
Ehseezed authored Feb 25, 2024
2 parents b69c5a5 + 16fba39 commit 34487dc
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 13 deletions.
7 changes: 6 additions & 1 deletion worlds/am2r/Client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import copy
import json
import time
import random
from asyncio import StreamReader, StreamWriter
from typing import List
from worlds.am2r.items import item_table
Expand Down Expand Up @@ -91,7 +92,10 @@ def get_payload(ctx: AM2RContext):
for locationid, netitem in ctx.locations_info.items():
gamelocation = location_id_to_game_id[locationid]
if netitem.item in item_id_to_game_id:
gameitem = item_id_to_game_id[netitem.item]
if netitem.flags & 0b100 != 0:
gameitem = random.randint(0, 20)
else:
gameitem = item_id_to_game_id[netitem.item]
else:
gameitem = 20
itemdict[gamelocation] = gameitem
Expand Down Expand Up @@ -185,6 +189,7 @@ def launch():
options = Utils.get_options()

async def main(args):
random.seed()
ctx = AM2RContext(args.connect, args.password)
ctx.server_task = asyncio.create_task(server_loop(ctx), name="ServerLoop")
if gui_enabled:
Expand Down
24 changes: 17 additions & 7 deletions worlds/am2r/items.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import Dict, List, NamedTuple, Set

from BaseClasses import Item, ItemClassification, MultiWorld
from .options import MetroidsAreChecks, MetroidsRequired, get_option_value, TrapFillPercentage, RemoveEquipmentTrap, RemoveTossTrap, RemoveShortBeam, RemoveEMPTrap
from .options import MetroidsAreChecks, MetroidsRequired, get_option_value, TrapFillPercentage, RemoveFloodTrap, RemoveTossTrap, RemoveShortBeam, RemoveEMPTrap, RemoveOHKOTrap, RemoveTouhouTrap


class ItemData(NamedTuple):
Expand Down Expand Up @@ -40,8 +40,8 @@ def create_metroid_items(MetroidsRequired: MetroidsRequired, MetroidsAreChecks:
def create_trap_items(multiworld: MultiWorld, player: int, locations_to_trap: int) -> List[str]:
trap_pool = trap_weights.copy()

if multiworld.RemoveEquipmentTrap[player].value == 1:
del trap_pool["Equipment Trap"]
if multiworld.RemoveFloodTrap[player].value == 1:
del trap_pool["Flood Trap"]

if multiworld.RemoveTossTrap[player].value == 1:
del trap_pool["Big Toss Trap"]
Expand All @@ -51,6 +51,12 @@ def create_trap_items(multiworld: MultiWorld, player: int, locations_to_trap: in

if multiworld.RemoveEMPTrap[player].value == 1:
del trap_pool["EMP Trap"]

if multiworld.RemoveTouhouTrap[player].value == 1:
del trap_pool["Touhou Trap"]

if multiworld.RemoveOHKOTrap[player].value == 1:
del trap_pool["OHKO Trap"]

return multiworld.random.choices(
population=list(trap_pool.keys()),
Expand Down Expand Up @@ -112,10 +118,12 @@ def create_all_items(multiworld: MultiWorld, player: int) -> None:
"Spazer": ItemData(8678018, "Beam", ItemClassification.useful, 13, 1),
"Plasma Beam": ItemData(8678019, "Beam", ItemClassification.useful, 14, 1),
"Ice Beam": ItemData(8678020, "Beam", ItemClassification.progression, 11, 1),
"Equipment Trap": ItemData(8678021, "Trap", ItemClassification.trap, 21),
"Big Toss Trap": ItemData(8678022, "Trap", ItemClassification.trap, 22),
"Flood Trap": ItemData(8678021, "Trap", ItemClassification.trap, 21),
"Big Toss Trap": ItemData(8678022, "Trap", ItemClassification.trap, 22),
"Short Beam": ItemData(8678023, "Trap", ItemClassification.trap, 23),
"EMP Trap": ItemData(8678024, "Trap", ItemClassification.trap, 24),
"OHKO Trap": ItemData(8678026, "Trap", ItemClassification.trap, 25),
"Touhou Trap": ItemData(8678027, "Trap", ItemClassification.trap, 26),
"Metroid": ItemData(8678025, "MacGuffin", ItemClassification.progression_skip_balancing, 19),
"The Galaxy is at Peace": ItemData(None, "Victory", ItemClassification.progression)

Expand All @@ -128,10 +136,12 @@ def create_all_items(multiworld: MultiWorld, player: int) -> None:
}

trap_weights: Dict[str, int] = {
"Equipment Trap": 1,
"Flood Trap": 1,
"Big Toss Trap": 1,
"Short Beam": 1,
"EMP Trap": 1
"EMP Trap": 1,
"Touhou Trap": 1,
"OHKO Trap": 1
}


Expand Down
20 changes: 15 additions & 5 deletions worlds/am2r/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ class TrapFillPercentage(Range):
default = 0


class RemoveEquipmentTrap(Toggle):
"""Removes Equipment Traps from trap fill"""
display_name = "Remove Equipment Trap"
class RemoveFloodTrap(Toggle):
"""Removes Flood Traps from trap fill"""
display_name = "Remove Flood Trap"


class RemoveTossTrap(Toggle):
Expand All @@ -39,14 +39,22 @@ class RemoveTossTrap(Toggle):


class RemoveShortBeam(Toggle):
"""Removes Short Bema from trap fill"""
"""Removes Short Beam from trap fill"""
display_name = "Remove Short Beam"


class RemoveEMPTrap(Toggle):
"""Removes EMP Traps from trap fill"""
display_name = "Remove EMP Trap"

class RemoveTouhouTrap(Toggle):
"""Removes Touhou Traps from trap fill"""
display_name = "Remove Touhou Trap"

class RemoveOHKOTrap(Toggle):
"""Removes OHKO Traps from trap fill"""
display_name = "Remove OHKO Trap"


#class ItemSprites(OptionList):
# """Changes Item Sprites. Does not affect gameplay
Expand Down Expand Up @@ -101,10 +109,12 @@ class RemoveEMPTrap(Toggle):
"MetroidsRequired": MetroidsRequired,
"MetroidsAreChecks": MetroidsAreChecks,
"TrapFillPercentage": TrapFillPercentage,
"RemoveEquipmentTrap": RemoveEquipmentTrap,
"RemoveFloodTrap": RemoveFloodTrap,
"RemoveTossTrap": RemoveTossTrap,
"RemoveShortBeam": RemoveShortBeam,
"RemoveEMPTrap": RemoveEMPTrap,
"RemoveTouhouTrap": RemoveTouhouTrap,
"RemoveOHKOTrap": RemoveOHKOTrap,
# "Item Sprites": ItemSprites,
# "Starting Weapons": StartingWeapons,
# "Randomize Baby", RandomizeBaby
Expand Down

0 comments on commit 34487dc

Please sign in to comment.