|
9 | 9 | [game.core.card :refer [active? get-card get-counters get-title installed? |
10 | 10 | rezzed?]] |
11 | 11 | [game.core.eid :as eid] |
| 12 | + [game.core.events :refer [turn-events]] |
12 | 13 | [game.core.ice :refer [active-ice?]] |
13 | 14 | [game.core.initializing :refer [make-card]] |
14 | 15 | [game.core.threat :refer [threat-level]] |
|
616 | 617 | ([state side title server] |
617 | 618 | `(error-wrapper (play-from-hand-impl ~state ~side ~title ~server)))) |
618 | 619 |
|
| 620 | +(defn- split-on-keywords [coll] |
| 621 | + (reduce (fn [acc x] |
| 622 | + (if (keyword? x) |
| 623 | + (conj acc x) |
| 624 | + (let [last-el (peek acc)] |
| 625 | + (if (vector? last-el) |
| 626 | + (conj (pop acc) (conj last-el x)) |
| 627 | + (conj acc [x]))))) |
| 628 | + [] |
| 629 | + coll)) |
| 630 | + |
619 | 631 | (defn play-from-hand-with-prompts-impl |
620 | 632 | [state side title choices] |
621 | 633 | (let [card (find-card title (get-in @state [side :hand]))] |
|
627 | 639 | (println title " was instead found in the opposing hand - was the wrong side used?"))) |
628 | 640 | true) |
629 | 641 | (when-let [played (core/process-action "play" state side {:card card})] |
630 | | - (click-prompts-impl state side choices))))) |
| 642 | + (let [choice-sets (split-on-keywords choices)] |
| 643 | + (doseq [cs choice-sets] |
| 644 | + (cond |
| 645 | + (vector? cs) (click-prompts-impl state side cs) |
| 646 | + (#{:rez :rezzed} cs) |
| 647 | + (if-let [tgt (->> (turn-events state side :corp-install) |
| 648 | + (apply concat) |
| 649 | + (map :card) |
| 650 | + (filter #(= (:title %) title)) |
| 651 | + (filter (complement rezzed?)) |
| 652 | + last)] |
| 653 | + (core/process-action "rez" state :corp {:card tgt}) |
| 654 | + (throw (Exception. (str title " not found in an unrezzed state to be rezzed"))))))))))) |
| 655 | + |
631 | 656 |
|
632 | 657 | (defmacro play-from-hand-with-prompts |
633 | 658 | "Play a card from hand based on it's title, and then click any number of prompts |
|
0 commit comments