From 9a03889248f515c27ecbf0e7b792e342ec7a3d6b Mon Sep 17 00:00:00 2001 From: peter Date: Sun, 8 Sep 2024 14:01:54 +0100 Subject: [PATCH] Add more actions --- clashroyalebuildabot/actions/cannon_action.py | 6 ++++++ .../actions/hungry_dragon_action.py | 20 +++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 clashroyalebuildabot/actions/cannon_action.py create mode 100644 clashroyalebuildabot/actions/hungry_dragon_action.py diff --git a/clashroyalebuildabot/actions/cannon_action.py b/clashroyalebuildabot/actions/cannon_action.py new file mode 100644 index 0000000..a51d28a --- /dev/null +++ b/clashroyalebuildabot/actions/cannon_action.py @@ -0,0 +1,6 @@ +from clashroyalebuildabot import Cards +from clashroyalebuildabot.actions.generic.defense_action import DefenseAction + + +class CannonAction(DefenseAction): + CARD = Cards.CANNON diff --git a/clashroyalebuildabot/actions/hungry_dragon_action.py b/clashroyalebuildabot/actions/hungry_dragon_action.py new file mode 100644 index 0000000..2043541 --- /dev/null +++ b/clashroyalebuildabot/actions/hungry_dragon_action.py @@ -0,0 +1,20 @@ +import math + +from clashroyalebuildabot import Cards +from clashroyalebuildabot.actions.generic.action import Action + + +class HungryDragonAction(Action): + CARD = Cards.HUNGRY_DRAGON + + def calculate_score(self, state): + for det in state.enemies: + distance = math.hypot( + det.position.tile_x - self.tile_x, + det.position.tile_y - self.tile_y, + ) + if 5 < distance < 6: + return [1] + if distance < 5: + return [0] + return [0]