Skip to content

Commit

Permalink
Merge pull request #4421 from NoahTheDuke/nb/enforce-savant-dai-v-bre…
Browse files Browse the repository at this point in the history
…ak-all

Add :all to break-sub, enforce Savant and Dai V break-all clause
  • Loading branch information
NoahTheDuke authored Aug 17, 2019
2 parents 6ea4894 + e747bfc commit 9c06656
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
14 changes: 7 additions & 7 deletions src/clj/game/cards/programs.clj
Original file line number Diff line number Diff line change
Expand Up @@ -118,18 +118,18 @@
(Greek/Philosopher suite: Adept, Sage, Savant)"
[first-qty first-type second-qty second-type]
{:cost [:credit 2]
:req (req (or (has-subtype? current-ice first-type)
(has-subtype? current-ice second-type)))
:req (req (or (and (has-subtype? current-ice first-type)
(<= first-qty (count (remove :broken (:subroutines current-ice)))))
(and (has-subtype? current-ice second-type)
(<= second-qty (count (remove :broken (:subroutines current-ice)))))))
:label (str "break "
(when (< 1 first-qty) " up to ")
(quantify first-qty (str first-type " subroutine")) " or "
(when (< 1 second-qty) " up to ")
(quantify second-qty (str second-type " subroutine")))
:effect (effect
(continue-ability
(if (has-subtype? current-ice first-type)
(break-sub nil first-qty first-type)
(break-sub nil second-qty second-type))
(break-sub nil first-qty first-type {:all (< 1 first-qty)})
(break-sub nil second-qty second-type {:all (< 1 second-qty)}))
card nil))})

(defn- give-ice-subtype
Expand Down Expand Up @@ -813,7 +813,7 @@
{:effect
(effect
(continue-ability
(break-sub 2 (count (:subroutines current-ice)))
(break-sub 2 (count (:subroutines current-ice)) "All" {:all true})
card nil))})
(strength-pump 1 1)]})

Expand Down
19 changes: 13 additions & 6 deletions src/clj/game/core/ice.clj
Original file line number Diff line number Diff line change
Expand Up @@ -249,14 +249,19 @@

;; Break abilities
(defn- break-subroutines-impl
([ice target-count] (break-subroutines-impl ice target-count '()))
([ice target-count broken-subs]
([ice target-count] (break-subroutines-impl ice target-count '() nil))
([ice target-count broken-subs] (break-subroutines-impl ice target-count broken-subs nil))
([ice target-count broken-subs args]
{:async true
:prompt (str "Break a subroutine"
(when (and target-count (< 1 target-count))
(str " (" (count broken-subs)
" of " target-count ")")))
:choices (req (concat (unbroken-subroutines-choice ice) '("Done")))
:choices (req (concat (unbroken-subroutines-choice ice)
(when-not (and (:all args)
(pos? (count (unbroken-subroutines-choice ice)))
(< 1 target-count))
'("Done"))))
:effect (req (if (= "Done" target)
(complete-with-result state side eid {:broken-subs broken-subs
:early-exit true})
Expand All @@ -265,7 +270,7 @@
broken-subs (cons sub broken-subs)]
(if (and (pos? (count (unbroken-subroutines-choice ice)))
(< (count broken-subs) (if (pos? target-count) target-count (count (:subroutines ice)))))
(continue-ability state side (break-subroutines-impl ice target-count broken-subs) card nil)
(continue-ability state side (break-subroutines-impl ice target-count broken-subs args) card nil)
(complete-with-result state side eid {:broken-subs broken-subs
:early-exit false})))))}))

Expand All @@ -291,9 +296,11 @@
(defn break-subroutines
([ice cost n] (break-subroutines ice cost n nil))
([ice cost n args]
(let [args (merge {:repeatable true} args)]
(let [args (merge {:repeatable true
:all false}
args)]
{:async true
:effect (req (wait-for (resolve-ability state side (break-subroutines-impl ice n) card nil)
:effect (req (wait-for (resolve-ability state side (break-subroutines-impl ice n '() args) card nil)
(let [broken-subs (:broken-subs async-result)
early-exit (:early-exit async-result)]
(wait-for (resolve-ability state side (make-eid state {:source-type :ability})
Expand Down
2 changes: 1 addition & 1 deletion test/clj/game_test/cards/programs.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2311,7 +2311,7 @@
(run-on state :rd)
(card-ability state :runner (refresh savant) 0)
(click-prompt state :runner "Make the Runner lose 2 [Credits]")
(click-prompt state :runner "Done")
(click-prompt state :runner "End the run")
(is (:broken (first (:subroutines (refresh afshar)))) "Broke a code gate subroutine"))))


Expand Down

0 comments on commit 9c06656

Please sign in to comment.