Skip to content

Commit

Permalink
few refactored key condition
Browse files Browse the repository at this point in the history
  • Loading branch information
bomzheg committed Jan 2, 2025
1 parent 5b16f88 commit 2660c9f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions shvatka/core/models/dto/action/keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,7 @@ def check(self, action: Action, state_holder: StateHolder) -> Decision:
if not state.is_duplicate(action):
if self._is_all_typed(action, state):
return LevelUpKeyDecision(
type=DecisionType.LEVEL_UP,
key_type=enums.KeyType.simple
if self._is_correct(action)
else enums.KeyType.wrong,
key_type=self._get_key_type(action), # TODO always simple
duplicate=state.is_duplicate(action),
key=action.key,
next_level=self.next_level,
Expand All @@ -106,11 +103,14 @@ def check(self, action: Action, state_holder: StateHolder) -> Decision:
type_ = DecisionType.NO_ACTION
return KeyDecision(
type=type_,
key_type=enums.KeyType.simple if self._is_correct(action) else enums.KeyType.wrong,
key_type=self._get_key_type(action), # TODO always simple
duplicate=state.is_duplicate(action),
key=action.key,
)

def _get_key_type(self, action: TypedKeyAction):
return enums.KeyType.simple if self._is_correct(action) else enums.KeyType.wrong

def _is_correct(self, action: TypedKeyAction) -> bool:
return action.key in self.keys

Expand Down

0 comments on commit 2660c9f

Please sign in to comment.