2021-05-23 11:43:31 +02:00
|
|
|
from enum import Enum
|
|
|
|
|
|
|
|
|
|
|
|
class Wire(Enum):
|
|
|
|
BLUE = 1, "blue"
|
|
|
|
GREEN = 2, "green"
|
|
|
|
RED = 3, "red"
|
2021-06-07 09:40:38 +02:00
|
|
|
YELLOW = 4, "yellow"
|
|
|
|
WHITE = 5, "white"
|
|
|
|
PURPLE = 6, "purple"
|
2021-05-23 11:43:31 +02:00
|
|
|
|
|
|
|
|
|
|
|
class TypeHash(Enum):
|
|
|
|
TIME = 90, "time"
|
2021-05-24 01:05:00 +02:00
|
|
|
CHAINED = 45, "chained"
|
2021-05-23 11:43:31 +02:00
|
|
|
STANDARD = 0, "standard"
|
|
|
|
|
|
|
|
|
|
|
|
class DangerClassHash(Enum):
|
|
|
|
BIG_BANG = 64, "big bang"
|
2021-05-24 01:05:00 +02:00
|
|
|
WEAPON_OF_MASS_DESTRUCTION = 48, "weapon of mass destruction"
|
|
|
|
RADIOACTIVE = 36, "radioactive"
|
|
|
|
CASUAL_DEVASTATOR = 20, "casual devastator"
|
|
|
|
ALMOST_PIERCES_THROUGH_PAPER = 10, "almost pierces through paper"
|
2021-05-23 11:43:31 +02:00
|
|
|
CHERRY_BOMB = 0, "cherry bomb"
|
|
|
|
|
|
|
|
|
|
|
|
class SeriesHash(Enum):
|
2021-06-07 09:40:38 +02:00
|
|
|
TCH_2990TONER = 220, "TCH 2990toner", "T"
|
|
|
|
SWX_5000 = 168, "SWX 5000", "S"
|
|
|
|
WORKHORSE_3200 = 94, "WORKHORSE 3200", "W"
|
|
|
|
FX_500 = 1, "FX 500", "F"
|
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):
|
2021-06-07 09:40:38 +02:00
|
|
|
ANTI_AIRCRAFT = 512, "anti aircraft", "planes"
|
|
|
|
DEPTH_MINE = 256, "depth mine", "ships"
|
|
|
|
ANTI_TANK = 16, "anti tank", "tanks"
|
2021-05-23 11:43:31 +02:00
|
|
|
|
|
|
|
|
2021-05-23 20:20:02 +02:00
|
|
|
class WeightHash(Enum):
|
2021-05-24 01:05:00 +02:00
|
|
|
GINORMOUS = 32, "ginormous"
|
|
|
|
EXTRA_LARGE = 24, "extra large"
|
|
|
|
TOTAL_AVERAGE = 16, "total average"
|
|
|
|
SLIM_FIT = 8, "slim fit"
|
|
|
|
BREAD_CRUMB = 0, "bread crumb"
|
2021-05-23 20:20:02 +02:00
|
|
|
|
|
|
|
|
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):
|
2021-06-07 09:40:38 +02:00
|
|
|
if hash_sum < 0.20 * MAX_VALUE:
|
2021-05-23 11:43:31 +02:00
|
|
|
return Wire.BLUE
|
2021-06-07 09:40:38 +02:00
|
|
|
elif hash_sum <= 0.38 * MAX_VALUE:
|
2021-05-23 11:43:31 +02:00
|
|
|
return Wire.GREEN
|
2021-06-07 09:40:38 +02:00
|
|
|
elif hash_sum <= 0.50 * MAX_VALUE:
|
|
|
|
return Wire.YELLOW
|
|
|
|
elif hash_sum <= 0.60 * MAX_VALUE:
|
|
|
|
return Wire.WHITE
|
|
|
|
elif hash_sum <= 0.80 * MAX_VALUE:
|
|
|
|
return Wire.PURPLE
|
2021-05-23 11:43:31 +02:00
|
|
|
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)
|