The Messenger, LADX: use collect and remove as intended (#2093)
Co-authored-by: el-u <109771707+el-u@users.noreply.github.com>
This commit is contained in:
parent
fe6a70a1de
commit
cfe357eb71
|
@ -1,32 +1,29 @@
|
||||||
import binascii
|
import binascii
|
||||||
import bsdiff4
|
|
||||||
import os
|
import os
|
||||||
import pkgutil
|
import pkgutil
|
||||||
import settings
|
|
||||||
import typing
|
|
||||||
import tempfile
|
import tempfile
|
||||||
|
import typing
|
||||||
|
|
||||||
|
import bsdiff4
|
||||||
|
|
||||||
|
import settings
|
||||||
from BaseClasses import Entrance, Item, ItemClassification, Location, Tutorial
|
from BaseClasses import Entrance, Item, ItemClassification, Location, Tutorial
|
||||||
from Fill import fill_restrictive
|
from Fill import fill_restrictive
|
||||||
from worlds.AutoWorld import WebWorld, World
|
from worlds.AutoWorld import WebWorld, World
|
||||||
|
|
||||||
from .Common import *
|
from .Common import *
|
||||||
from .Items import (DungeonItemData, DungeonItemType, LinksAwakeningItem, TradeItemData,
|
from .Items import (DungeonItemData, DungeonItemType, ItemName, LinksAwakeningItem, TradeItemData,
|
||||||
ladxr_item_to_la_item_name, links_awakening_items,
|
ladxr_item_to_la_item_name, links_awakening_items, links_awakening_items_by_name)
|
||||||
links_awakening_items_by_name, ItemName)
|
|
||||||
from .LADXR import generator
|
from .LADXR import generator
|
||||||
from .LADXR.itempool import ItemPool as LADXRItemPool
|
from .LADXR.itempool import ItemPool as LADXRItemPool
|
||||||
|
from .LADXR.locations.constants import CHEST_ITEMS
|
||||||
|
from .LADXR.locations.instrument import Instrument
|
||||||
from .LADXR.logic import Logic as LAXDRLogic
|
from .LADXR.logic import Logic as LAXDRLogic
|
||||||
from .LADXR.main import get_parser
|
from .LADXR.main import get_parser
|
||||||
from .LADXR.settings import Settings as LADXRSettings
|
from .LADXR.settings import Settings as LADXRSettings
|
||||||
from .LADXR.worldSetup import WorldSetup as LADXRWorldSetup
|
from .LADXR.worldSetup import WorldSetup as LADXRWorldSetup
|
||||||
from .LADXR.locations.instrument import Instrument
|
|
||||||
from .LADXR.locations.constants import CHEST_ITEMS
|
|
||||||
from .Locations import (LinksAwakeningLocation, LinksAwakeningRegion,
|
from .Locations import (LinksAwakeningLocation, LinksAwakeningRegion,
|
||||||
create_regions_from_ladxr, get_locations_to_id)
|
create_regions_from_ladxr, get_locations_to_id)
|
||||||
from .Options import links_awakening_options, DungeonItemShuffle
|
from .Options import DungeonItemShuffle, links_awakening_options
|
||||||
|
|
||||||
from .Rom import LADXDeltaPatch
|
from .Rom import LADXDeltaPatch
|
||||||
|
|
||||||
DEVELOPER_MODE = False
|
DEVELOPER_MODE = False
|
||||||
|
@ -511,16 +508,12 @@ class LinksAwakeningWorld(World):
|
||||||
|
|
||||||
def collect(self, state, item: Item) -> bool:
|
def collect(self, state, item: Item) -> bool:
|
||||||
change = super().collect(state, item)
|
change = super().collect(state, item)
|
||||||
if change:
|
if change and item.name in self.rupees:
|
||||||
rupees = self.rupees.get(item.name, 0)
|
state.prog_items[self.player]["RUPEES"] += self.rupees[item.name]
|
||||||
state.prog_items[item.player]["RUPEES"] += rupees
|
|
||||||
|
|
||||||
return change
|
return change
|
||||||
|
|
||||||
def remove(self, state, item: Item) -> bool:
|
def remove(self, state, item: Item) -> bool:
|
||||||
change = super().remove(state, item)
|
change = super().remove(state, item)
|
||||||
if change:
|
if change and item.name in self.rupees:
|
||||||
rupees = self.rupees.get(item.name, 0)
|
state.prog_items[self.player]["RUPEES"] -= self.rupees[item.name]
|
||||||
state.prog_items[item.player]["RUPEES"] -= rupees
|
|
||||||
|
|
||||||
return change
|
return change
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
from Fill import distribute_planned
|
||||||
|
from test.general import setup_solo_multiworld
|
||||||
|
from worlds.AutoWorld import call_all
|
||||||
|
from . import LADXTestBase
|
||||||
|
from .. import LinksAwakeningWorld
|
||||||
|
|
||||||
|
|
||||||
|
class PlandoTest(LADXTestBase):
|
||||||
|
options = {
|
||||||
|
"plando_items": [{
|
||||||
|
"items": {
|
||||||
|
"Progressive Sword": 2,
|
||||||
|
},
|
||||||
|
"locations": [
|
||||||
|
"Shop 200 Item (Mabe Village)",
|
||||||
|
"Shop 980 Item (Mabe Village)",
|
||||||
|
],
|
||||||
|
}],
|
||||||
|
}
|
||||||
|
|
||||||
|
def world_setup(self, seed: Optional[int] = None) -> None:
|
||||||
|
self.multiworld = setup_solo_multiworld(
|
||||||
|
LinksAwakeningWorld,
|
||||||
|
("generate_early", "create_regions", "create_items", "set_rules", "generate_basic")
|
||||||
|
)
|
||||||
|
self.multiworld.plando_items[1] = self.options["plando_items"]
|
||||||
|
distribute_planned(self.multiworld)
|
||||||
|
call_all(self.multiworld, "pre_fill")
|
||||||
|
|
||||||
|
def test_planned(self):
|
||||||
|
"""Tests plandoing swords in the shop."""
|
||||||
|
location_names = ["Shop 200 Item (Mabe Village)", "Shop 980 Item (Mabe Village)"]
|
||||||
|
locations = [self.multiworld.get_location(loc, 1) for loc in location_names]
|
||||||
|
for loc in locations:
|
||||||
|
self.assertEqual("Progressive Sword", loc.item.name)
|
||||||
|
self.assertFalse(loc.can_reach(self.multiworld.state))
|
|
@ -176,11 +176,14 @@ class MessengerWorld(World):
|
||||||
self.total_shards += count
|
self.total_shards += count
|
||||||
return MessengerItem(name, self.player, item_id, override_prog, count)
|
return MessengerItem(name, self.player, item_id, override_prog, count)
|
||||||
|
|
||||||
def collect_item(self, state: "CollectionState", item: "Item", remove: bool = False) -> Optional[str]:
|
def collect(self, state: "CollectionState", item: "Item") -> bool:
|
||||||
if item.advancement and "Time Shard" in item.name:
|
change = super().collect(state, item)
|
||||||
shard_count = int(item.name.strip("Time Shard ()"))
|
if change and "Time Shard" in item.name:
|
||||||
if remove:
|
state.prog_items[self.player]["Shards"] += int(item.name.strip("Time Shard ()"))
|
||||||
shard_count = -shard_count
|
return change
|
||||||
state.prog_items[self.player]["Shards"] += shard_count
|
|
||||||
|
|
||||||
return super().collect_item(state, item, remove)
|
def remove(self, state: "CollectionState", item: "Item") -> bool:
|
||||||
|
change = super().remove(state, item)
|
||||||
|
if change and "Time Shard" in item.name:
|
||||||
|
state.prog_items[self.player]["Shards"] -= int(item.name.strip("Time Shard ()"))
|
||||||
|
return change
|
||||||
|
|
Loading…
Reference in New Issue