Skip to content

Commit 6f9484f

Browse files
The Messenger: Make modules and tests PEP8 (#2276)
* The Messenger: PEP8 module and test names * fix dumb * whitespace
1 parent cc2247b commit 6f9484f

13 files changed

+65
-71
lines changed

worlds/messenger/__init__.py

+13-17
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import logging
2-
from typing import Dict, Any, List, Optional
2+
from typing import Any, Dict, List, Optional
33

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

1313

1414
class MessengerWeb(WebWorld):
@@ -68,15 +68,11 @@ class MessengerWorld(World):
6868

6969
total_seals: int = 0
7070
required_seals: int = 0
71-
total_shards: int
71+
total_shards: int = 0
7272
shop_prices: Dict[str, int]
7373
figurine_prices: Dict[str, int]
7474
_filler_items: List[str]
7575

76-
def __init__(self, multiworld: MultiWorld, player: int):
77-
super().__init__(multiworld, player)
78-
self.total_shards = 0
79-
8076
def generate_early(self) -> None:
8177
if self.multiworld.goal[self.player] == Goal.option_power_seal_hunt:
8278
self.multiworld.shuffle_seals[self.player].value = PowerSeals.option_true
@@ -144,11 +140,11 @@ def create_items(self) -> None:
144140
def set_rules(self) -> None:
145141
logic = self.multiworld.logic_level[self.player]
146142
if logic == Logic.option_normal:
147-
Rules.MessengerRules(self).set_messenger_rules()
143+
MessengerRules(self).set_messenger_rules()
148144
elif logic == Logic.option_hard:
149-
Rules.MessengerHardRules(self).set_messenger_rules()
145+
MessengerHardRules(self).set_messenger_rules()
150146
else:
151-
Rules.MessengerOOBRules(self).set_messenger_rules()
147+
MessengerOOBRules(self).set_messenger_rules()
152148

153149
def fill_slot_data(self) -> Dict[str, Any]:
154150
shop_prices = {SHOP_ITEMS[item].internal_name: price for item, price in self.shop_prices.items()}

worlds/messenger/Constants.py renamed to worlds/messenger/constants.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# items
22
# listing individual groups first for easy lookup
3-
from .Shop import SHOP_ITEMS, FIGURINES
3+
from .shop import SHOP_ITEMS, FIGURINES
44

55
NOTES = [
66
"Key of Hope",
File renamed without changes.
File renamed without changes.

worlds/messenger/Rules.py renamed to worlds/messenger/rules.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
from BaseClasses import CollectionState, MultiWorld
44
from worlds.generic.Rules import set_rule, allow_self_locking_items, add_rule
5-
from .Options import MessengerAccessibility, Goal
6-
from .Constants import NOTES, PHOBEKINS
7-
from .SubClasses import MessengerShopLocation
5+
from .options import MessengerAccessibility, Goal
6+
from .constants import NOTES, PHOBEKINS
7+
from .subclasses import MessengerShopLocation
88

99
if TYPE_CHECKING:
1010
from . import MessengerWorld
@@ -119,7 +119,7 @@ def can_destroy_projectiles(self, state: CollectionState) -> bool:
119119
def can_dboost(self, state: CollectionState) -> bool:
120120
return state.has_any({"Path of Resilience", "Meditation"}, self.player) and \
121121
state.has("Second Wind", self.player)
122-
122+
123123
def is_aerobatic(self, state: CollectionState) -> bool:
124124
return self.has_wingsuit(state) and state.has("Aerobatics Warrior", self.player)
125125

File renamed without changes.

worlds/messenger/SubClasses.py renamed to worlds/messenger/subclasses.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
from typing import Optional, TYPE_CHECKING, cast
33

44
from BaseClasses import CollectionState, Item, ItemClassification, Location, Region
5-
from .Constants import NOTES, PHOBEKINS, PROG_ITEMS, USEFUL_ITEMS
6-
from .Options import Goal
7-
from .Regions import MEGA_SHARDS, REGIONS, SEALS
8-
from .Shop import FIGURINES, PROG_SHOP_ITEMS, SHOP_ITEMS, USEFUL_SHOP_ITEMS
5+
from .constants import NOTES, PHOBEKINS, PROG_ITEMS, USEFUL_ITEMS
6+
from .options import Goal
7+
from .regions import MEGA_SHARDS, REGIONS, SEALS
8+
from .shop import FIGURINES, PROG_SHOP_ITEMS, SHOP_ITEMS, USEFUL_SHOP_ITEMS
99

1010
if TYPE_CHECKING:
1111
from . import MessengerWorld

worlds/messenger/test/TestAccess.py renamed to worlds/messenger/test/test_access.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
from . import MessengerTestBase
2-
from ..Constants import NOTES, PHOBEKINS
2+
from ..constants import NOTES, PHOBEKINS
33

44

55
class AccessTest(MessengerTestBase):
66
options = {
77
"shuffle_shards": "true",
88
}
99

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

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

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

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

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

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

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

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

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

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

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

44

55
class LocationsTest(MessengerTestBase):
@@ -10,7 +10,7 @@ class LocationsTest(MessengerTestBase):
1010
@property
1111
def run_default_tests(self) -> bool:
1212
return False
13-
14-
def testLocationsExist(self):
13+
14+
def test_locations_exist(self) -> None:
1515
for location in self.multiworld.worlds[1].location_name_to_id:
1616
self.assertIsInstance(self.multiworld.get_location(location, self.player), MessengerLocation)

worlds/messenger/test/TestLogic.py renamed to worlds/messenger/test/test_logic.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from typing import Iterable, List
2-
31
from BaseClasses import ItemClassification
42
from . import MessengerTestBase
53

@@ -10,7 +8,7 @@ class HardLogicTest(MessengerTestBase):
108
"shuffle_shards": "true",
119
}
1210

13-
def testVertical(self) -> None:
11+
def test_vertical(self) -> None:
1412
"""Test the locations that still require wingsuit or rope dart."""
1513
locations = [
1614
# tower of time
@@ -54,7 +52,7 @@ def testVertical(self) -> None:
5452
items = [["Wingsuit", "Rope Dart"]]
5553
self.assertAccessDependency(locations, items)
5654

57-
def testWindmill(self) -> None:
55+
def test_windmill(self) -> None:
5856
"""Windmill Shuriken isn't progression on normal difficulty, so test it's marked correctly and required."""
5957
self.assertEqual(ItemClassification.progression, self.get_item_by_name("Windmill Shuriken").classification)
6058
windmill_locs = [
@@ -81,8 +79,8 @@ def testWindmill(self) -> None:
8179
item = self.get_item_by_name("Rope Dart")
8280
self.collect(item)
8381
self.assertTrue(self.can_reach_location(special_loc))
84-
85-
def testGlacial(self) -> None:
82+
83+
def test_glacial(self) -> None:
8684
"""Test Glacial Peak locations."""
8785
self.assertAccessDependency(["Glacial Peak Seal - Ice Climbers"],
8886
[["Second Wind", "Meditation"], ["Rope Dart"], ["Wingsuit"]],
@@ -100,7 +98,7 @@ class NoLogicTest(MessengerTestBase):
10098
"logic_level": "oob",
10199
}
102100

103-
def testAccess(self) -> None:
101+
def test_access(self) -> None:
104102
"""Test the locations with rules still require things."""
105103
all_locations = [
106104
"Bamboo Creek - Claustro", "Searing Crags - Key of Strength", "Elemental Skylands - Key of Symbiosis",

worlds/messenger/test/TestNotes.py renamed to worlds/messenger/test/test_notes.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
from . import MessengerTestBase
2-
from ..Constants import NOTES
2+
from ..constants import NOTES
33

44

55
class TwoNoteGoalTest(MessengerTestBase):
66
options = {
77
"notes_needed": 2,
88
}
99

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

1313

@@ -16,15 +16,15 @@ class FourNoteGoalTest(MessengerTestBase):
1616
"notes_needed": 4,
1717
}
1818

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

2222

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

27-
def testGoal(self) -> None:
27+
def test_goal(self) -> None:
2828
self.assertBeatable(False)
2929
self.collect_by_name(NOTES)
3030
rope_dart = self.get_item_by_name("Rope Dart")

worlds/messenger/test/TestShop.py renamed to worlds/messenger/test/test_shop.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from typing import Dict
22

33
from . import MessengerTestBase
4-
from ..Shop import SHOP_ITEMS, FIGURINES
4+
from ..shop import SHOP_ITEMS, FIGURINES
55

66

77
class ShopCostTest(MessengerTestBase):
@@ -10,21 +10,21 @@ class ShopCostTest(MessengerTestBase):
1010
"shuffle_shards": "true",
1111
}
1212

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

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

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

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

39-
def testStrike(self) -> None:
39+
def test_strike(self) -> None:
4040
locations = [
4141
"Glacial Peak Seal - Projectile Spike Pit", "Elemental Skylands Seal - Fire",
4242
]
@@ -50,22 +50,22 @@ class ShopCostMinTest(ShopCostTest):
5050
"shuffle_seals": "false",
5151
}
5252

53-
def testShopRules(self) -> None:
53+
def test_shop_rules(self) -> None:
5454
if self.multiworld.worlds[self.player].total_shards:
55-
super().testShopRules()
55+
super().test_shop_rules()
5656
else:
5757
for loc in SHOP_ITEMS:
5858
loc = f"The Shop - {loc}"
5959
with self.subTest("has cost", loc=loc):
6060
self.assertTrue(self.can_reach_location(loc))
6161

62-
def testDBoost(self) -> None:
62+
def test_dboost(self) -> None:
6363
pass
6464

65-
def testCurrents(self) -> None:
65+
def test_currents(self) -> None:
6666
pass
6767

68-
def testStrike(self) -> None:
68+
def test_strike(self) -> None:
6969
pass
7070

7171

@@ -79,7 +79,7 @@ class PlandoTest(MessengerTestBase):
7979
},
8080
}
8181

82-
def testCosts(self) -> None:
82+
def test_costs(self) -> None:
8383
for loc in SHOP_ITEMS:
8484
loc = f"The Shop - {loc}"
8585
with self.subTest("has cost", loc=loc):

0 commit comments

Comments
 (0)