2021-05-23 11:43:31 +02:00
|
|
|
from enum import Enum
|
|
|
|
|
|
|
|
|
|
|
|
class Wire(Enum):
|
|
|
|
BLUE = 1, "blue"
|
|
|
|
GREEN = 2, "green"
|
|
|
|
RED = 3, "red"
|
|
|
|
|
|
|
|
|
|
|
|
class TypeHash(Enum):
|
|
|
|
TIME = 90, "time"
|
|
|
|
CHAINED = 12, "chained"
|
|
|
|
STANDARD = 0, "standard"
|
|
|
|
|
|
|
|
|
|
|
|
class DangerClassHash(Enum):
|
|
|
|
BIG_BANG = 64, "big bang"
|
|
|
|
WEAPON_OF_MASS_DESTRUCTION = 32, "weapon of mass destruction"
|
|
|
|
RADIOACTIVE = 16, "radioactive"
|
|
|
|
CASUAL_DEVASTATOR = 8, "casual devastator"
|
2021-05-23 20:20:02 +02:00
|
|
|
LITTLE_BOY = 4, "little boy"
|
2021-05-23 11:43:31 +02:00
|
|
|
CHERRY_BOMB = 0, "cherry bomb"
|
|
|
|
|
|
|
|
|
|
|
|
class SeriesHash(Enum):
|
2021-05-23 20:20:02 +02:00
|
|
|
TCH_2990TONER = 128, "TCH_2990toner"
|
2021-05-23 11:43:31 +02:00
|
|
|
TCH_2990INKJET = 64, "TCH_2990inkjet"
|
2021-05-23 20:20:02 +02:00
|
|
|
TVY_2400H = 48, "TVY_2400h"
|
|
|
|
SWX_5000 = 32, "SWX_5000"
|
|
|
|
SWX_4000 = 16, "SWX_4000"
|
|
|
|
WORKHORSE_3200 = 8, "WORKHORSE_3200"
|
|
|
|
FX_500 = 4, "FX_500"
|
|
|
|
TVY_2400 = 0, "TVY_2400"
|
2021-05-23 11:43:31 +02:00
|
|
|
|
|
|
|
|
|
|
|
class IndicatorHash(Enum):
|
|
|
|
RED = 10, "red"
|
|
|
|
YELLOW = 8, "yellow"
|
|
|
|
BLUE = 5, "blue"
|
|
|
|
GREEN = 2, "green"
|
|
|
|
WHITE = 0, "white"
|
|
|
|
|
|
|
|
|
|
|
|
class SpecificityHash(Enum):
|
|
|
|
ANTI_AIRCRAFT = 55, "anti_aircraft"
|
|
|
|
ANTI_PERSONNEL = 43, "anti_personnel"
|
|
|
|
DEPTH_MINE = 37, "depth_mine"
|
|
|
|
ANTI_TANK = 26, "anti_tank"
|
|
|
|
PROXIMITY_MINE = 18, "proximity_mine"
|
|
|
|
PRESSURE_MINE = 9, "pressure_mine"
|
|
|
|
FRAGMENTATION_MINE = 0, "fragmentation_mine"
|
|
|
|
|
|
|
|
|
2021-05-23 20:20:02 +02:00
|
|
|
class WeightHash(Enum):
|
|
|
|
FAT_MAN = 32, "fat_man"
|
|
|
|
EXTRA_LARGE = 24, "extra_large"
|
|
|
|
TOTAL_AVERAGE = 16, "total_average"
|
|
|
|
SLIM_FIT = 8, "slim_fit"
|
|
|
|
BREAD_CRUMB = 0, "bread_crumb"
|
|
|
|
|
|
|
|
|
2021-05-23 11:43:31 +02:00
|
|
|
MAX_VALUE = max([elem.value[0] for elem in TypeHash]) \
|
|
|
|
+ max([elem.value[0] for elem in DangerClassHash]) \
|
|
|
|
+ max([elem.value[0] for elem in SeriesHash]) \
|
|
|
|
+ max([elem.value[0] for elem in IndicatorHash]) \
|
2021-05-23 20:20:02 +02:00
|
|
|
+ max([elem.value[0] for elem in SpecificityHash]) \
|
|
|
|
+ max([elem.value[0] for elem in WeightHash])
|
2021-05-23 11:43:31 +02:00
|
|
|
|
|
|
|
|
|
|
|
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
|
2021-05-23 20:20:02 +02:00
|
|
|
def get_wire_from_str(mine_type: str, danger_cls: str, series: str, indicator: str, specificity: str, weight: str):
|
2021-05-23 11:43:31 +02:00
|
|
|
|
|
|
|
type_hash = TypeHash[mine_type.upper().replace(" ", "_")].value[0]
|
|
|
|
danger_cls_hash = DangerClassHash[danger_cls.upper().replace(" ", "_")].value[0]
|
|
|
|
series_hash = SeriesHash[series.upper().replace(" ", "_")].value[0]
|
|
|
|
indicator_hash = IndicatorHash[indicator.upper().replace(" ", "_")].value[0]
|
|
|
|
specificity_hash = SpecificityHash[specificity.upper().replace(" ", "_")].value[0]
|
2021-05-23 20:20:02 +02:00
|
|
|
weight_hash = WeightHash[weight.upper().replace(" ", "_")].value[0]
|
2021-05-23 11:43:31 +02:00
|
|
|
|
2021-05-23 20:20:02 +02:00
|
|
|
hash_sum = type_hash + danger_cls_hash + series_hash + indicator_hash + specificity_hash + weight_hash
|
2021-05-23 11:43:31 +02:00
|
|
|
return _get_wire_color(hash_sum)
|
|
|
|
|
|
|
|
|
|
|
|
# ENUM ARGUMENTS
|
|
|
|
def get_wire_from_enums(
|
|
|
|
mine_type: TypeHash,
|
|
|
|
danger_cls: DangerClassHash,
|
|
|
|
series: SeriesHash,
|
|
|
|
indicator: IndicatorHash,
|
2021-05-23 20:20:02 +02:00
|
|
|
specificity: SpecificityHash,
|
|
|
|
weight: WeightHash):
|
|
|
|
|
|
|
|
hash_list = [mine_type, danger_cls, series, indicator, specificity, weight]
|
|
|
|
hash_sum = sum([enum.value[0] for enum in hash_list])
|
2021-05-23 11:43:31 +02:00
|
|
|
|
|
|
|
return _get_wire_color(hash_sum)
|