Skip to content

Commit

Permalink
The Messenger: Make modules and tests PEP8 (ArchipelagoMW#2276)
Browse files Browse the repository at this point in the history
* The Messenger: PEP8 module and test names

* fix dumb

* whitespace
  • Loading branch information
alwaysintreble authored Oct 8, 2023
1 parent cc2247b commit 6f9484f
Show file tree
Hide file tree
Showing 13 changed files with 65 additions and 71 deletions.
30 changes: 13 additions & 17 deletions worlds/messenger/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import logging
from typing import Dict, Any, List, Optional
from typing import Any, Dict, List, Optional

from BaseClasses import Tutorial, ItemClassification, CollectionState, Item, MultiWorld
from worlds.AutoWorld import World, WebWorld
from .Constants import NOTES, PHOBEKINS, ALL_ITEMS, ALWAYS_LOCATIONS, BOSS_LOCATIONS, FILLER
from .Options import messenger_options, NotesNeeded, Goal, PowerSeals, Logic
from .Regions import REGIONS, REGION_CONNECTIONS, SEALS, MEGA_SHARDS
from .Shop import SHOP_ITEMS, shuffle_shop_prices, FIGURINES
from .SubClasses import MessengerRegion, MessengerItem
from . import Rules
from BaseClasses import CollectionState, Item, ItemClassification, Tutorial
from worlds.AutoWorld import WebWorld, World
from .constants import ALL_ITEMS, ALWAYS_LOCATIONS, BOSS_LOCATIONS, FILLER, NOTES, PHOBEKINS
from .options import Goal, Logic, NotesNeeded, PowerSeals, messenger_options
from .regions import MEGA_SHARDS, REGIONS, REGION_CONNECTIONS, SEALS
from .rules import MessengerHardRules, MessengerOOBRules, MessengerRules
from .shop import FIGURINES, SHOP_ITEMS, shuffle_shop_prices
from .subclasses import MessengerItem, MessengerRegion


class MessengerWeb(WebWorld):
Expand Down Expand Up @@ -68,15 +68,11 @@ class MessengerWorld(World):

total_seals: int = 0
required_seals: int = 0
total_shards: int
total_shards: int = 0
shop_prices: Dict[str, int]
figurine_prices: Dict[str, int]
_filler_items: List[str]

def __init__(self, multiworld: MultiWorld, player: int):
super().__init__(multiworld, player)
self.total_shards = 0

def generate_early(self) -> None:
if self.multiworld.goal[self.player] == Goal.option_power_seal_hunt:
self.multiworld.shuffle_seals[self.player].value = PowerSeals.option_true
Expand Down Expand Up @@ -144,11 +140,11 @@ def create_items(self) -> None:
def set_rules(self) -> None:
logic = self.multiworld.logic_level[self.player]
if logic == Logic.option_normal:
Rules.MessengerRules(self).set_messenger_rules()
MessengerRules(self).set_messenger_rules()
elif logic == Logic.option_hard:
Rules.MessengerHardRules(self).set_messenger_rules()
MessengerHardRules(self).set_messenger_rules()
else:
Rules.MessengerOOBRules(self).set_messenger_rules()
MessengerOOBRules(self).set_messenger_rules()

def fill_slot_data(self) -> Dict[str, Any]:
shop_prices = {SHOP_ITEMS[item].internal_name: price for item, price in self.shop_prices.items()}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# items
# listing individual groups first for easy lookup
from .Shop import SHOP_ITEMS, FIGURINES
from .shop import SHOP_ITEMS, FIGURINES

NOTES = [
"Key of Hope",
Expand Down
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions worlds/messenger/Rules.py → worlds/messenger/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

from BaseClasses import CollectionState, MultiWorld
from worlds.generic.Rules import set_rule, allow_self_locking_items, add_rule
from .Options import MessengerAccessibility, Goal
from .Constants import NOTES, PHOBEKINS
from .SubClasses import MessengerShopLocation
from .options import MessengerAccessibility, Goal
from .constants import NOTES, PHOBEKINS
from .subclasses import MessengerShopLocation

if TYPE_CHECKING:
from . import MessengerWorld
Expand Down Expand Up @@ -119,7 +119,7 @@ def can_destroy_projectiles(self, state: CollectionState) -> bool:
def can_dboost(self, state: CollectionState) -> bool:
return state.has_any({"Path of Resilience", "Meditation"}, self.player) and \
state.has("Second Wind", self.player)

def is_aerobatic(self, state: CollectionState) -> bool:
return self.has_wingsuit(state) and state.has("Aerobatics Warrior", self.player)

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
from typing import Optional, TYPE_CHECKING, cast

from BaseClasses import CollectionState, Item, ItemClassification, Location, Region
from .Constants import NOTES, PHOBEKINS, PROG_ITEMS, USEFUL_ITEMS
from .Options import Goal
from .Regions import MEGA_SHARDS, REGIONS, SEALS
from .Shop import FIGURINES, PROG_SHOP_ITEMS, SHOP_ITEMS, USEFUL_SHOP_ITEMS
from .constants import NOTES, PHOBEKINS, PROG_ITEMS, USEFUL_ITEMS
from .options import Goal
from .regions import MEGA_SHARDS, REGIONS, SEALS
from .shop import FIGURINES, PROG_SHOP_ITEMS, SHOP_ITEMS, USEFUL_SHOP_ITEMS

if TYPE_CHECKING:
from . import MessengerWorld
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from . import MessengerTestBase
from ..Constants import NOTES, PHOBEKINS
from ..constants import NOTES, PHOBEKINS


class AccessTest(MessengerTestBase):
options = {
"shuffle_shards": "true",
}

def testTabi(self) -> None:
def test_tabi(self) -> None:
"""locations that hard require the Lightfoot Tabi"""
locations = [
"Searing Crags - Pyro", "Underworld - Key of Chaos", "Underworld Seal - Sharp and Windy Climb",
Expand All @@ -19,7 +19,7 @@ def testTabi(self) -> None:
items = [["Lightfoot Tabi"]]
self.assertAccessDependency(locations, items)

def testDart(self) -> None:
def test_dart(self) -> None:
"""locations that hard require the Rope Dart"""
locations = [
"Ninja Village Seal - Tree House", "Autumn Hills - Key of Hope", "Howling Grotto Seal - Crushing Pits",
Expand All @@ -31,7 +31,7 @@ def testDart(self) -> None:
items = [["Rope Dart"]]
self.assertAccessDependency(locations, items)

def testWingsuit(self) -> None:
def test_wingsuit(self) -> None:
"""locations that hard require the Wingsuit"""
locations = [
"Ninja Village - Candle", "Ninja Village Seal - Tree House", "Autumn Hills - Climbing Claws",
Expand All @@ -57,7 +57,7 @@ def testWingsuit(self) -> None:
items = [["Wingsuit"]]
self.assertAccessDependency(locations, items)

def testVertical(self) -> None:
def test_vertical(self) -> None:
"""locations that require either the Rope Dart or the Wingsuit"""
locations = [
"Ninja Village Seal - Tree House", "Howling Grotto Seal - Crushing Pits",
Expand Down Expand Up @@ -92,7 +92,7 @@ def testVertical(self) -> None:
items = [["Wingsuit", "Rope Dart"]]
self.assertAccessDependency(locations, items)

def testAmulet(self) -> None:
def test_amulet(self) -> None:
"""Locations that require Ruxxtin's Amulet"""
locations = [
"Cloud Ruins - Acro", "Cloud Ruins Seal - Ghost Pit", "Cloud Ruins Seal - Toothbrush Alley",
Expand All @@ -103,7 +103,7 @@ def testAmulet(self) -> None:
items = [["Ruxxtin's Amulet"]]
self.assertAccessDependency(locations, items)

def testFirefly(self) -> None:
def test_firefly(self) -> None:
"""Elemental Skylands and Corrupted Future require the Magic Firefly"""
locations = [
"Elemental Skylands - Key of Symbiosis", "Elemental Skylands Seal - Air", "Elemental Skylands Seal - Fire",
Expand All @@ -113,7 +113,7 @@ def testFirefly(self) -> None:
items = [["Magic Firefly"]]
self.assertAccessDependency(locations, items)

def testCrests(self) -> None:
def test_crests(self) -> None:
"""Test Key of Love nonsense"""
locations = ["Sunken Shrine - Key of Love"]
items = [["Sun Crest", "Moon Crest"]]
Expand All @@ -124,19 +124,19 @@ def testCrests(self) -> None:
self.collect_by_name("Sun Crest")
self.assertEqual(self.can_reach_location("Sunken Shrine - Key of Love"), False)

def testThistle(self) -> None:
def test_thistle(self) -> None:
"""I'm a chuckster!"""
locations = ["Searing Crags - Key of Strength"]
items = [["Power Thistle"]]
self.assertAccessDependency(locations, items)

def testCrown(self) -> None:
def test_crown(self) -> None:
"""Crocomire but not"""
locations = ["Corrupted Future - Key of Courage"]
items = [["Demon King Crown"]]
self.assertAccessDependency(locations, items)

def testGoal(self) -> None:
def test_goal(self) -> None:
"""Test some different states to verify goal requires the correct items"""
self.collect_all_but([*NOTES, "Rescue Phantom"])
self.assertEqual(self.can_reach_location("Rescue Phantom"), False)
Expand All @@ -153,7 +153,7 @@ class ItemsAccessTest(MessengerTestBase):
"accessibility": "items",
}

def testSelfLockingItems(self) -> None:
def test_self_locking_items(self) -> None:
"""Force items that can be self locked to ensure it's valid placement."""
location_lock_pairs = {
"Searing Crags - Key of Strength": ["Power Thistle"],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from . import MessengerTestBase
from ..SubClasses import MessengerLocation
from ..subclasses import MessengerLocation


class LocationsTest(MessengerTestBase):
Expand All @@ -10,7 +10,7 @@ class LocationsTest(MessengerTestBase):
@property
def run_default_tests(self) -> bool:
return False
def testLocationsExist(self):

def test_locations_exist(self) -> None:
for location in self.multiworld.worlds[1].location_name_to_id:
self.assertIsInstance(self.multiworld.get_location(location, self.player), MessengerLocation)
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Iterable, List

from BaseClasses import ItemClassification
from . import MessengerTestBase

Expand All @@ -10,7 +8,7 @@ class HardLogicTest(MessengerTestBase):
"shuffle_shards": "true",
}

def testVertical(self) -> None:
def test_vertical(self) -> None:
"""Test the locations that still require wingsuit or rope dart."""
locations = [
# tower of time
Expand Down Expand Up @@ -54,7 +52,7 @@ def testVertical(self) -> None:
items = [["Wingsuit", "Rope Dart"]]
self.assertAccessDependency(locations, items)

def testWindmill(self) -> None:
def test_windmill(self) -> None:
"""Windmill Shuriken isn't progression on normal difficulty, so test it's marked correctly and required."""
self.assertEqual(ItemClassification.progression, self.get_item_by_name("Windmill Shuriken").classification)
windmill_locs = [
Expand All @@ -81,8 +79,8 @@ def testWindmill(self) -> None:
item = self.get_item_by_name("Rope Dart")
self.collect(item)
self.assertTrue(self.can_reach_location(special_loc))
def testGlacial(self) -> None:

def test_glacial(self) -> None:
"""Test Glacial Peak locations."""
self.assertAccessDependency(["Glacial Peak Seal - Ice Climbers"],
[["Second Wind", "Meditation"], ["Rope Dart"], ["Wingsuit"]],
Expand All @@ -100,7 +98,7 @@ class NoLogicTest(MessengerTestBase):
"logic_level": "oob",
}

def testAccess(self) -> None:
def test_access(self) -> None:
"""Test the locations with rules still require things."""
all_locations = [
"Bamboo Creek - Claustro", "Searing Crags - Key of Strength", "Elemental Skylands - Key of Symbiosis",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from . import MessengerTestBase
from ..Constants import NOTES
from ..constants import NOTES


class TwoNoteGoalTest(MessengerTestBase):
options = {
"notes_needed": 2,
}

def testPrecollectedNotes(self) -> None:
def test_precollected_notes(self) -> None:
self.assertEqual(self.multiworld.state.count_group("Notes", self.player), 4)


Expand All @@ -16,15 +16,15 @@ class FourNoteGoalTest(MessengerTestBase):
"notes_needed": 4,
}

def testPrecollectedNotes(self) -> None:
def test_precollected_notes(self) -> None:
self.assertEqual(self.multiworld.state.count_group("Notes", self.player), 2)


class DefaultGoalTest(MessengerTestBase):
def testPrecollectedNotes(self) -> None:
def test_precollected_notes(self) -> None:
self.assertEqual(self.multiworld.state.count_group("Notes", self.player), 0)

def testGoal(self) -> None:
def test_goal(self) -> None:
self.assertBeatable(False)
self.collect_by_name(NOTES)
rope_dart = self.get_item_by_name("Rope Dart")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Dict

from . import MessengerTestBase
from ..Shop import SHOP_ITEMS, FIGURINES
from ..shop import SHOP_ITEMS, FIGURINES


class ShopCostTest(MessengerTestBase):
Expand All @@ -10,21 +10,21 @@ class ShopCostTest(MessengerTestBase):
"shuffle_shards": "true",
}

def testShopRules(self) -> None:
def test_shop_rules(self) -> None:
for loc in SHOP_ITEMS:
loc = f"The Shop - {loc}"
with self.subTest("has cost", loc=loc):
self.assertFalse(self.can_reach_location(loc))

def testShopPrices(self) -> None:
def test_shop_prices(self) -> None:
prices: Dict[str, int] = self.multiworld.worlds[self.player].shop_prices
for loc, price in prices.items():
with self.subTest("prices", loc=loc):
self.assertLessEqual(price, self.multiworld.get_location(f"The Shop - {loc}", self.player).cost)
self.assertTrue(loc in SHOP_ITEMS)
self.assertEqual(len(prices), len(SHOP_ITEMS))

def testDBoost(self) -> None:
def test_dboost(self) -> None:
locations = [
"Riviere Turquoise Seal - Bounces and Balls",
"Forlorn Temple - Demon King", "Forlorn Temple Seal - Rocket Maze", "Forlorn Temple Seal - Rocket Sunset",
Expand All @@ -33,10 +33,10 @@ def testDBoost(self) -> None:
items = [["Path of Resilience", "Meditation", "Second Wind"]]
self.assertAccessDependency(locations, items)

def testCurrents(self) -> None:
def test_currents(self) -> None:
self.assertAccessDependency(["Elemental Skylands Seal - Water"], [["Currents Master"]])

def testStrike(self) -> None:
def test_strike(self) -> None:
locations = [
"Glacial Peak Seal - Projectile Spike Pit", "Elemental Skylands Seal - Fire",
]
Expand All @@ -50,22 +50,22 @@ class ShopCostMinTest(ShopCostTest):
"shuffle_seals": "false",
}

def testShopRules(self) -> None:
def test_shop_rules(self) -> None:
if self.multiworld.worlds[self.player].total_shards:
super().testShopRules()
super().test_shop_rules()
else:
for loc in SHOP_ITEMS:
loc = f"The Shop - {loc}"
with self.subTest("has cost", loc=loc):
self.assertTrue(self.can_reach_location(loc))

def testDBoost(self) -> None:
def test_dboost(self) -> None:
pass

def testCurrents(self) -> None:
def test_currents(self) -> None:
pass

def testStrike(self) -> None:
def test_strike(self) -> None:
pass


Expand All @@ -79,7 +79,7 @@ class PlandoTest(MessengerTestBase):
},
}

def testCosts(self) -> None:
def test_costs(self) -> None:
for loc in SHOP_ITEMS:
loc = f"The Shop - {loc}"
with self.subTest("has cost", loc=loc):
Expand Down
Loading

0 comments on commit 6f9484f

Please sign in to comment.