Files
Grinch-AP/worlds/civ_6/test/TestRegionRequirements.py

235 lines
8.5 KiB
Python
Raw Normal View History

New Game Implementation: Civilization VI (#3736) * Init * remove submodule * Init * Update docs * Fix tests * Update to use apcivvi * Update Readme and codeowners * Minor changes * Remove .value from options (except starting hint) * Minor updates * remove unnecessary property * Cleanup Rules and Region * Fix output file generation * Implement feedback * Remove 'AP' tag and fix issue with format strings and using same quotes * Update worlds/civ_6/__init__.py Co-authored-by: Scipio Wright <scipiowright@gmail.com> * Minor docs changes * minor updates * Small rework of create items * Minor updates * Remove unused variable * Move client to Launcher Components with rest of similar clients * Revert "Move client to Launcher Components with rest of similar clients" This reverts commit f9fd5df9fdf19eaf4f1de54e21e3c33a74f02364. * modify component * Fix generation issues * Fix tests * Minor change * Add improvement and test case * Minor options changes * . * Preliminary Review * Fix failing test due to slot data serialization * Format json * Remove exclude missable boosts * Update options (update goody hut text, make research multiplier a range) * Update docs punctuation and slot data init * Move priority/excluded locations into options * Implement docs PR feedback * PR Feedback for options * PR feedback misc * Update location classification and fix client type * Fix typings * Update research cost multiplier * Remove unnecessary location priority code * Remove extrenous use of items() * WIP PR Feedback * WIP PR Feedback * Add victory event * Add option set for death link effect * PR improvements * Update post fill hint to support items with multiple classifications * remove unnecessary len * Move location exclusion logic * Update test to use set instead of accidental dict * Update docs around progressive eras and boost locations * Update docs for options to be more readable * Fix issue with filler items and prehints * Update filler_data to be static * Update links in docs * Minor updates and PR feedback * Update boosts data * Update era required items * Update existing techs * Update existing techs * move boost data class * Update reward data * Update prereq data * Update new items and progressive districts * Remove unused code * Make filler item name func more efficient * Update death link text * Move Civ6 to the end of readme * Fix bug with hidden locations and location.name * Partial PR Feedback Implementation * Format changes * Minor review feedback * Modify access rules to use list created in generate_early * Modify boost rules to precalculate requirements * Remove option checks from access rules * Fix issue with pre initialized dicts * Add inno setup for civ6 client * Update inno_setup.iss --------- Co-authored-by: Scipio Wright <scipiowright@gmail.com> Co-authored-by: Exempt-Medic <60412657+Exempt-Medic@users.noreply.github.com> Co-authored-by: Exempt-Medic <ExemptMedic@Gmail.com> Co-authored-by: NewSoupVi <57900059+NewSoupVi@users.noreply.github.com>
2025-03-10 07:53:26 -06:00
from typing import Callable, List
from BaseClasses import CollectionState
from ..Data import get_era_required_items_data
from ..Enum import EraType
from ..ProgressiveDistricts import convert_items_to_progressive_items
from ..Items import get_item_by_civ_name
from . import CivVITestBase
def collect_items_for_era(test: CivVITestBase, era: EraType) -> None:
era_required_items = get_era_required_items_data()
items = [
get_item_by_civ_name(item, test.world.item_table).name
for item in era_required_items[era.value]
]
test.collect_by_name(items)
def collect_items_for_era_progressive(test: CivVITestBase, era: EraType) -> None:
era_progression_items = get_era_required_items_data()
progressive_items = convert_items_to_progressive_items(
era_progression_items[era.value]
)
items = [
get_item_by_civ_name(item, test.world.item_table).name
for item in progressive_items
]
for item in items:
test.collect(test.get_item_by_name(item))
def verify_eras_accessible(
test: CivVITestBase,
state: CollectionState,
collect_func: Callable[[CivVITestBase, EraType], None],
) -> None:
"""Collect for an era, then check if the next era is accessible and the one after that is not"""
for era in EraType:
if era == EraType.ERA_ANCIENT:
test.assertTrue(state.can_reach(era.value, "Region", test.player))
else:
test.assertFalse(state.can_reach(era.value, "Region", test.player))
eras = [
EraType.ERA_ANCIENT,
EraType.ERA_CLASSICAL,
EraType.ERA_MEDIEVAL,
EraType.ERA_RENAISSANCE,
EraType.ERA_INDUSTRIAL,
EraType.ERA_MODERN,
EraType.ERA_ATOMIC,
EraType.ERA_INFORMATION,
EraType.ERA_FUTURE,
]
for i in range(len(eras) - 1):
collect_func(test, eras[i])
test.assertTrue(state.can_reach(eras[i + 1].value, "Region", test.player))
if i + 2 < len(eras):
test.assertFalse(state.can_reach(eras[i + 2].value, "Region", test.player))
class TestNonProgressiveRegionRequirements(CivVITestBase):
options = {
"progression_style": "none",
"boostsanity": "false",
}
def test_eras_are_accessible_without_progressive_districts(self) -> None:
state = self.multiworld.state
verify_eras_accessible(self, state, collect_items_for_era)
class TestNonProgressiveRegionRequirementsWithBoostsanity(CivVITestBase):
options = {
"progression_style": "none",
"boostsanity": "true",
}
def test_eras_are_accessible_without_progressive_districts(self) -> None:
state = self.multiworld.state
verify_eras_accessible(self, state, collect_items_for_era)
class TestProgressiveDistrictRequirementsWithBoostsanity(CivVITestBase):
options = {
"progression_style": "districts_only",
"boostsanity": "true",
}
def test_eras_are_accessible_with_progressive_districts(self) -> None:
state = self.multiworld.state
verify_eras_accessible(self, state, collect_items_for_era_progressive)
class TestProgressiveDistrictRequirements(CivVITestBase):
options = {
"progression_style": "districts_only",
"boostsanity": "false",
}
def test_eras_are_accessible_with_progressive_districts(self) -> None:
state = self.multiworld.state
verify_eras_accessible(self, state, collect_items_for_era_progressive)
def test_progressive_districts_are_required(self) -> None:
state = self.multiworld.state
self.collect_all_but(["Progressive Encampment"])
self.assertFalse(state.can_reach("ERA_CLASSICAL", "Region", self.player))
self.assertFalse(state.can_reach("ERA_RENAISSANCE", "Region", self.player))
self.assertFalse(state.can_reach("ERA_MODERN", "Region", self.player))
self.collect(self.get_item_by_name("Progressive Encampment"))
self.assertTrue(state.can_reach("ERA_CLASSICAL", "Region", self.player))
self.assertFalse(state.can_reach("ERA_RENAISSANCE", "Region", self.player))
self.assertFalse(state.can_reach("ERA_MODERN", "Region", self.player))
self.collect(self.get_item_by_name("Progressive Encampment"))
self.assertTrue(state.can_reach("ERA_RENAISSANCE", "Region", self.player))
self.assertFalse(state.can_reach("ERA_MODERN", "Region", self.player))
self.collect(self.get_item_by_name("Progressive Encampment"))
self.assertTrue(state.can_reach("ERA_MODERN", "Region", self.player))
class TestProgressiveEraRequirements(CivVITestBase):
options = {
"progression_style": "eras_and_districts",
}
def test_eras_are_accessible_with_progressive_eras(self) -> None:
state = self.multiworld.state
self.collect_all_but(["Progressive Era"])
def check_eras_accessible(eras: List[EraType]):
for era in EraType:
if era in eras:
self.assertTrue(state.can_reach(era.value, "Region", self.player))
else:
self.assertFalse(state.can_reach(era.value, "Region", self.player))
progresive_era_item = self.get_item_by_name("Progressive Era")
accessible_eras = [EraType.ERA_ANCIENT]
check_eras_accessible(accessible_eras)
# Classical era requires 2 progressive era items
self.collect(progresive_era_item)
accessible_eras += [EraType.ERA_CLASSICAL]
check_eras_accessible(accessible_eras)
self.collect(progresive_era_item)
accessible_eras += [EraType.ERA_MEDIEVAL]
check_eras_accessible(accessible_eras)
self.collect(progresive_era_item)
accessible_eras += [EraType.ERA_RENAISSANCE]
check_eras_accessible(accessible_eras)
self.collect(progresive_era_item)
accessible_eras += [EraType.ERA_INDUSTRIAL]
check_eras_accessible(accessible_eras)
self.collect(progresive_era_item)
accessible_eras += [EraType.ERA_MODERN]
check_eras_accessible(accessible_eras)
self.collect(progresive_era_item)
accessible_eras += [EraType.ERA_ATOMIC]
check_eras_accessible(accessible_eras)
# Since we collect 2 in the ancient era, information and future era have same logic requirement
self.collect(progresive_era_item)
accessible_eras += [EraType.ERA_INFORMATION]
accessible_eras += [EraType.ERA_FUTURE]
check_eras_accessible(accessible_eras)
class TestProgressiveEraRequirementsWithBoostsanity(CivVITestBase):
options = {
"progression_style": "eras_and_districts",
"boostsanity": "true",
}
def test_eras_are_accessible_with_progressive_eras(self) -> None:
state = self.multiworld.state
self.collect_all_but(["Progressive Era"])
def check_eras_accessible(eras: List[EraType]):
for era in EraType:
if era in eras:
self.assertTrue(
state.can_reach(era.value, "Region", self.player),
"Failed for era: " + era.value,
)
else:
self.assertFalse(
state.can_reach(era.value, "Region", self.player),
"Failed for era: " + era.value,
)
progresive_era_item = self.get_item_by_name("Progressive Era")
accessible_eras = [EraType.ERA_ANCIENT]
check_eras_accessible(accessible_eras)
self.collect(progresive_era_item)
accessible_eras += [EraType.ERA_CLASSICAL]
check_eras_accessible(accessible_eras)
self.collect(progresive_era_item)
accessible_eras += [EraType.ERA_MEDIEVAL]
check_eras_accessible(accessible_eras)
self.collect(progresive_era_item)
accessible_eras += [EraType.ERA_RENAISSANCE]
check_eras_accessible(accessible_eras)
self.collect(progresive_era_item)
accessible_eras += [EraType.ERA_INDUSTRIAL]
check_eras_accessible(accessible_eras)
self.collect(progresive_era_item)
accessible_eras += [EraType.ERA_MODERN]
check_eras_accessible(accessible_eras)
self.collect(progresive_era_item)
accessible_eras += [EraType.ERA_ATOMIC]
check_eras_accessible(accessible_eras)
# Since we collect 2 in the ancient era, information and future era have same logic requirement
self.collect(progresive_era_item)
accessible_eras += [EraType.ERA_INFORMATION]
accessible_eras += [EraType.ERA_FUTURE]
check_eras_accessible(accessible_eras)