92 lines
2.1 KiB
Python
92 lines
2.1 KiB
Python
from enum import Enum
|
|
|
|
|
|
class Wire(Enum):
|
|
BLUE = 1
|
|
GREEN = 2
|
|
RED = 3
|
|
|
|
|
|
class TypeHash(Enum):
|
|
TIME = 90
|
|
CHAINED = 12
|
|
STANDARD = 0
|
|
|
|
|
|
class DangerClassHash(Enum):
|
|
BIG_BANG = 64
|
|
WEAPON_OF_MASS_DESTRUCTION = 32
|
|
RADIOACTIVE = 16
|
|
CASUAL_DEVASTATOR = 8
|
|
CHERRY_BOMB = 0
|
|
|
|
|
|
class SeriesHash(Enum):
|
|
TCH_2990TONER = 65
|
|
TCH_2990INKJET = 64
|
|
TVY_2400H = 55
|
|
SWX_5000 = 53
|
|
SWX_4000 = 50
|
|
WORKFORCE_3200 = 43
|
|
FX_500 = 40
|
|
TVY_2400 = 23
|
|
|
|
|
|
class IndicatorHash(Enum):
|
|
RED = 10
|
|
YELLOW = 8
|
|
BLUE = 5
|
|
GREEN = 2
|
|
WHITE = 0
|
|
|
|
|
|
class SpecificityHash(Enum):
|
|
ANTI_AIRCRAFT = 55
|
|
ANTI_PERSONNEL = 43
|
|
DEPTH_MINE = 37
|
|
ANTI_TANK = 26
|
|
PROXIMITY_MINE = 18
|
|
PRESSURE_MINE = 9
|
|
FRAGMENTATION_MINE = 0
|
|
|
|
|
|
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 hash_sum <= 0.6 * MAX_VALUE:
|
|
return Wire.GREEN
|
|
else:
|
|
return Wire.RED
|
|
|
|
|
|
# STRING ARGUMENTS
|
|
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
|
|
series_hash = SeriesHash[series.upper()].value
|
|
indicator_hash = IndicatorHash[indicator.upper()].value
|
|
specificity_hash = SpecificityHash[specificity.upper()].value
|
|
|
|
hash_sum = type_hash + danger_cls_hash + series_hash + indicator_hash + specificity_hash
|
|
return _get_wire_color(hash_sum)
|
|
|
|
|
|
# ENUM ARGUMENTS
|
|
def get_wire_from_enums(
|
|
mine_type: TypeHash,
|
|
danger_cls: DangerClassHash,
|
|
series: SeriesHash,
|
|
indicator: IndicatorHash,
|
|
specificity: SpecificityHash):
|
|
|
|
hash_sum = mine_type.value + danger_cls.value + series.value + indicator.value + specificity.value
|
|
return _get_wire_color(hash_sum)
|