Projekt_Sztuczna_Inteligencja/objects/mines/disarming/mine_parameters.py

52 lines
1.7 KiB
Python
Raw Normal View History

import random
from objects.mines.disarming import hash_function as hf
class MineParameters:
def __init__(self, jdict=None, mine_type=None):
if jdict is None:
self.mine_type = random.choice(list(hf.TypeHash))
self.danger_cls = random.choice(list(hf.DangerClassHash))
self.series = random.choice(list(hf.SeriesHash))
self.indicator = random.choice(list(hf.IndicatorHash))
self.specificity = random.choice(list(hf.SpecificityHash))
self.weight = random.choice(list(hf.WeightHash))
else:
self.mine_type = jdict["mine_type"]
self.danger_cls = jdict["danger_cls"]
self.series = jdict["series"]
self.specificity = jdict["specificity"]
self.indicator = jdict["indicator"]
self.weight = jdict["weight"]
if mine_type is not None:
self.mine_type = mine_type
def jsonifyable_dict(self, with_wire=True):
wire = hf.get_wire_from_enums(
self.mine_type, self.danger_cls, self.series,
self.indicator, self.specificity, self.weight
)
jdict = {
"mine_type": self.mine_type.value[1],
"danger_cls": self.danger_cls.value[1],
"series": self.series.value[1],
"specificity": self.specificity.value[1],
"indicator": self.indicator.value[1],
"weight": self.weight.value[1]
}
if with_wire:
jdict["wire"] = wire.value[1]
return jdict
def get_parameters(self):
return self.mine_type, self.danger_cls, self.series,\
self.specificity, self.indicator, self.weight