forked from mirror/Archipelago
Some checks failed
Analyze modified files / flake8 (push) Failing after 2m28s
Build / build-win (push) Has been cancelled
Build / build-ubuntu2204 (push) Has been cancelled
ctest / Test C++ ubuntu-latest (push) Has been cancelled
ctest / Test C++ windows-latest (push) Has been cancelled
Analyze modified files / mypy (push) Has been cancelled
Build and Publish Docker Images / Push Docker image to Docker Hub (push) Successful in 5m4s
Native Code Static Analysis / scan-build (push) Failing after 5m2s
type check / pyright (push) Successful in 1m7s
unittests / Test Python 3.11.2 ubuntu-latest (push) Failing after 16m23s
unittests / Test Python 3.12 ubuntu-latest (push) Failing after 28m19s
unittests / Test Python 3.13 ubuntu-latest (push) Failing after 14m49s
unittests / Test hosting with 3.13 on ubuntu-latest (push) Successful in 5m0s
unittests / Test Python 3.13 macos-latest (push) Has been cancelled
unittests / Test Python 3.11 windows-latest (push) Has been cancelled
unittests / Test Python 3.13 windows-latest (push) Has been cancelled
95 lines
4.0 KiB
Python
95 lines
4.0 KiB
Python
from BaseClasses import PlandoOptions, Region
|
|
from Options import OptionError
|
|
|
|
from ..constants import BASE_GAME_CHARACTERS, CHARACTER_REGION_TEMPLATE
|
|
from ..items import ItemName
|
|
from ..options import StartingCharacters
|
|
from . import BrotatoTestBase
|
|
|
|
|
|
class TestBrotatoIncludeCharacters(BrotatoTestBase):
|
|
auto_construct = False
|
|
|
|
def test_include_characters_invalid_values_raises_exception(self):
|
|
valid_include_characters = BASE_GAME_CHARACTERS.characters[:10]
|
|
invalid_include_characters = [
|
|
"Well-Rounded",
|
|
"Bul",
|
|
"Jigglypuff",
|
|
"asdfdadfdasdf",
|
|
"",
|
|
"ireallywishihadhypothesisrn",
|
|
]
|
|
|
|
for invalid_character in invalid_include_characters:
|
|
with self.subTest(invalid_character=invalid_character):
|
|
include_characters = {*valid_include_characters, invalid_character}
|
|
self.options = {
|
|
"starting_characters": 1,
|
|
"include_base_game_characters": include_characters,
|
|
}
|
|
# The VerifyKeys mixin on OptionSet raises a bare Exception when it encounters an invalid key.
|
|
self.world_setup()
|
|
self.assertRaises(
|
|
OptionError,
|
|
self.world.options.include_base_game_characters.verify,
|
|
self.world,
|
|
self.world.player_name,
|
|
PlandoOptions.none,
|
|
)
|
|
|
|
def test_include_characters_excluded_characters_do_not_have_regions(self):
|
|
include_characters = BASE_GAME_CHARACTERS.characters[:10]
|
|
self.options = {
|
|
"starting_characters": 1,
|
|
"include_base_game_characters": include_characters,
|
|
}
|
|
self.world_setup()
|
|
|
|
player_regions: dict[str, Region] = {r.name: r for r in self.multiworld.regions if r.player == self.player}
|
|
|
|
for character in BASE_GAME_CHARACTERS.characters:
|
|
character_region_name = CHARACTER_REGION_TEMPLATE.format(char=character)
|
|
if character in include_characters:
|
|
self.assertIn(character_region_name, player_regions)
|
|
else:
|
|
self.assertNotIn(character_region_name, player_regions)
|
|
|
|
def test_include_characters_excludes_default_characters(self):
|
|
"""Test that excluded characters are not in the starting pool if they would be
|
|
otherwise.
|
|
|
|
Essentially testing that "starting_characters" and "include_*_characters"
|
|
options interact as expected.
|
|
"""
|
|
include_characters = set(BASE_GAME_CHARACTERS.characters)
|
|
include_characters.remove("Brawler")
|
|
expected_starting_characters = set(BASE_GAME_CHARACTERS.default_characters)
|
|
expected_starting_characters.remove("Brawler")
|
|
|
|
self.options = {
|
|
"starting_characters": StartingCharacters.option_default_base_game,
|
|
"include_base_game_characters": include_characters,
|
|
}
|
|
self.world_setup()
|
|
|
|
player_precollected = self.multiworld.precollected_items[self.player]
|
|
precollected_characters = {p.name for p in player_precollected if p.name in BASE_GAME_CHARACTERS.characters}
|
|
|
|
self.assertSetEqual(precollected_characters, expected_starting_characters)
|
|
|
|
def test_include_characters_less_characters_than_wins_changes_goal(self):
|
|
include_characters = set(BASE_GAME_CHARACTERS.default_characters)
|
|
self.options = {
|
|
"starting_characters": 1,
|
|
"include_base_game_characters": include_characters,
|
|
"wins_required": 30,
|
|
}
|
|
self.world_setup()
|
|
|
|
self.assertFalse(self.multiworld.has_beaten_game(self.multiworld.state))
|
|
# Create a "Run Won" item for each character included, give them to the player, then check that we've "won"
|
|
run_won_items = [self.world.create_item(ItemName.RUN_COMPLETE) for _ in include_characters]
|
|
self.collect(run_won_items)
|
|
self.assertTrue(self.multiworld.has_beaten_game(self.multiworld.state))
|