(s: str)
| 17 | |
| 18 | @staticmethod |
| 19 | def parse(s: str) -> 'Unit': |
| 20 | units, hp, resistances, dmg, dmgtype, initiative = re.findall(PARSE_REGEX, s)[0] |
| 21 | weaknesses, immunities = set(), set() |
| 22 | if resistances: |
| 23 | for s in resistances[2:-1].split(';'): |
| 24 | t, _, *types = [w.rstrip(',') for w in s.strip().split(' ')] |
| 25 | if t == "weak": |
| 26 | weaknesses = set(types) |
| 27 | if t == "immune": |
| 28 | immunities = set(types) |
| 29 | return Unit(int(units), int(hp), int(dmg), dmgtype, int(initiative), weaknesses, immunities) |
| 30 | |
| 31 | def effective_power(self) -> int: |
| 32 | return self.units * self.dmg |
no test coverage detected