minor refactors

This commit is contained in:
s452645 2021-05-23 00:09:02 +02:00
parent ad5864c7f8
commit 853eddcadd
3 changed files with 14 additions and 13 deletions

View File

@ -3,11 +3,11 @@ from random import randint
import project_constants as const
from display_assets import blit_graphics
from searching_algorithms import a_star
from algorithms.searching_algorithms import a_star
from minefield import Minefield
from mine_models.time_mine import TimeMine
from mines.mine_models.time_mine import TimeMine
from ui.ui_components_manager import UiComponentsManager
from ui.text_box import TextBox

View File

@ -50,25 +50,24 @@ class SpecificityHash(Enum):
FRAGMENTATION_MINE = 0
# ASSUMING ALL ENUMS' MEMBERS ARE IN DESCENDING ORDER
MAX_VALUE = list(TypeHash)[0].value \
+ list(DangerClassHash)[0].value \
+ list(SeriesHash)[0].value \
+ list(IndicatorHash)[0].value \
+ list(SpecificityHash)[0].value
MAX_VALUE = max([elem.value for elem in TypeHash]) \
+ max([elem.value for elem in DangerClassHash]) \
+ max([elem.value for elem in SeriesHash]) \
+ max([elem.value for elem in IndicatorHash]) \
+ max([elem.value for elem in SpecificityHash])
def _get_wire_color(hash_sum):
if hash_sum < 0.4 * MAX_VALUE:
return Wire.BLUE
elif 0.4 * MAX_VALUE < hash_sum <= 0.6 * MAX_VALUE:
elif hash_sum <= 0.6 * MAX_VALUE:
return Wire.GREEN
else:
return Wire.RED
# STRING ARGUMENTS
def get_correct_wire_str(mine_type: str, danger_cls: str, series: str, indicator: str, specificity: str):
def get_wire_from_str(mine_type: str, danger_cls: str, series: str, indicator: str, specificity: str):
type_hash = TypeHash[mine_type.upper()].value
danger_cls_hash = DangerClassHash[danger_cls.upper()].value
@ -81,7 +80,7 @@ def get_correct_wire_str(mine_type: str, danger_cls: str, series: str, indicator
# ENUM ARGUMENTS
def get_correct_wire_enums(
def get_wire_from_enums(
mine_type: TypeHash,
danger_cls: DangerClassHash,
series: SeriesHash,

View File

@ -11,6 +11,8 @@ class ChainedMine(Mine):
super().__init__(position, active)
def disarm(self):
if (self.predecessor.active == False):
if self.predecessor is None or not self.predecessor.active:
super().disarm()
pass
else:
# boom?
pass