Stardew Valley: Refactor skill progression to use new feature system (#3662)

* create a first draft of the feature

* use feature in items and locations

* add content to more places

* use feature in logic

* replace option check by feature

* remove unused code

* remove weird white space

* some import nitpicking

* flip negative if
This commit is contained in:
Jouramie
2024-11-30 21:52:07 -05:00
committed by GitHub
parent f735416bda
commit a67688749f
21 changed files with 244 additions and 181 deletions

View File

@@ -0,0 +1,46 @@
from abc import ABC, abstractmethod
from typing import ClassVar, Iterable, Tuple
from ...data.skill import Skill
class SkillProgressionFeature(ABC):
is_progressive: ClassVar[bool]
are_masteries_shuffled: ClassVar[bool]
@abstractmethod
def get_randomized_level_names_by_level(self, skill: Skill) -> Iterable[Tuple[int, str]]:
...
@abstractmethod
def is_mastery_randomized(self, skill: Skill) -> bool:
...
class SkillProgressionVanilla(SkillProgressionFeature):
is_progressive = False
are_masteries_shuffled = False
def get_randomized_level_names_by_level(self, skill: Skill) -> Iterable[Tuple[int, str]]:
return ()
def is_mastery_randomized(self, skill: Skill) -> bool:
return False
class SkillProgressionProgressive(SkillProgressionFeature):
is_progressive = True
are_masteries_shuffled = False
def get_randomized_level_names_by_level(self, skill: Skill) -> Iterable[Tuple[int, str]]:
return skill.level_names_by_level
def is_mastery_randomized(self, skill: Skill) -> bool:
return False
class SkillProgressionProgressiveWithMasteries(SkillProgressionProgressive):
are_masteries_shuffled = True
def is_mastery_randomized(self, skill: Skill) -> bool:
return skill.has_mastery