forked from Dentosal/python-sc2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
unit_command.py
24 lines (20 loc) · 916 Bytes
/
unit_command.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from . import unit as unit_module
from .ids.ability_id import AbilityId
from .position import Point2
class UnitCommand:
def __init__(self, ability, unit, target=None, queue=False):
assert ability in AbilityId, f"ability {ability} is not in AbilityId"
assert isinstance(unit, unit_module.Unit), f"unit {unit} is of type {type(unit)}"
assert target is None or isinstance(
target, (Point2, unit_module.Unit)
), f"target {target} is of type {type(target)}"
assert isinstance(queue, bool), f"queue flag {queue} is of type {type(queue)}"
self.ability = ability
self.unit = unit
self.target = target
self.queue = queue
@property
def combining_tuple(self):
return (self.ability, self.target, self.queue)
def __repr__(self):
return f"UnitCommand({self.ability}, {self.unit}, {self.target}, {self.queue})"