# yaml-language-server: $schema=../docs/tactic.schema.json
tactic: hex-skirmish-basic
label: "Basic: heal, hit the most monsters, keep the seer at a distance"
game: hex-skirmish
summary: >
  Simple heroes for docs/examples/hex-skirmish.yaml. Card: heal when a hero has taken a lot of
  damage, otherwise the strongest attack that reaches a monster, or the fastest card. Movement: to
  a cell where the card hits the most monsters; the seer also stays out of range of as many
  monsters as possible. Attacking: as many targets as possible, then the weakest.
default: first
rules:
  - at: action choose_card
    when_x: "any(h['hp'] <= h['max'] - 3 for h in heroes())"
    pick: Restore
  - at: action choose_card
    max_x: >-
      ((o.get('attack', 0) if min([distance('map', hero(me)['cell'], m['cell']) for m in monsters()] + [99]) <= o['move'] + o['range']
        else o['move'] / 10), -o['ini'])

  # where to: the options are cells
  - at: action hero_acts
    when_x: "opts[0] in cells('map') and card[me].get('heal')"
    max_x: >-
      (-sum(1 for m in monsters() if distance('map', o, m['cell']) <= MONSTERS[m['type']]['range'] + 1),
       max([h['max'] - h['hp'] for h in heroes() if in_range(o, h['cell'], card[me]['range'])] + [0]))
  - at: action hero_acts
    when_x: "opts[0] in cells('map')"
    max_x: >-
      (max([len(s) for s in attack_options({'cell': o, 'id': hero(me)['id']}, card[me])] + [0]),
       -sum(1 for m in monsters() if distance('map', o, m['cell']) <= MONSTERS[m['type']]['range']) if me == 1 else 0,
       -min([distance('map', o, m['cell']) for m in monsters()] + [99]))

  # whom you hit: the options are lists of monsters
  - at: action hero_acts
    when_x: "labels[0][0] == '['"
    max_x: "(len(o), -min(m['hp'] for m in o))"

  # healing: the options are heroes
  - at: action hero_acts
    max_x: "o['max'] - o['hp']"
