Add debug_unit_function
@@ -23,6 +23,7 @@ from .data import Race, ActionResult, ChatChannel
from .action import combine_actions
from .position import Point2, Point3
from .unit import Unit
+from .units import Units
from typing import List, Dict, Set, Tuple, Any, Optional, Union # mypy type checking
class Client(Protocol):
@@ -258,6 +259,17 @@ class Client(Protocol):
)) for unit_type, amount_of_units, position, owner_id in unit_spawn_commands]
))
+ async def debug_kill_unit(self, unit_tags: Union[Units, List[int], Set[int]]):
+ if isinstance(unit_tags, Units):
+ unit_tags = unit_tags.tags
+ assert len(unit_tags) > 0
+
+ await self._execute(debug=sc_pb.RequestDebug(
+ debug=[debug_pb.DebugCommand(kill_unit=debug_pb.DebugKillUnit(
+ tag=unit_tags
+ ))]
+ ))
+
async def move_camera(self, position: Union[Unit, Point2, Point3]):
""" Moves camera to the target position """
assert isinstance(position, (Unit, Point2, Point3))
@@ -363,18 +375,10 @@ class Client(Protocol):
""" Helper function for color conversion """
if color is None:
return debug_pb.Color(r=255, g=255, b=255)
- else:
- if isinstance(color, (tuple, list)):
- assert(len(color) == 3)
-
- r = color[0]
- g = color[1]
- b = color[2]
else:
r = getattr(color, "r", getattr(color, "x", 255))
g = getattr(color, "g", getattr(color, "y", 255))
b = getattr(color, "b", getattr(color, "z", 255))
-
if max(r, g, b) <= 1:
r *= 255
g *= 255
