From 51ae122d1979c4d8e45e3f34322cd2e21a32a4f3 Mon Sep 17 00:00:00 2001 From: Noah Date: Wed, 12 Jun 2019 16:15:05 -0400 Subject: [PATCH] messy commit DONT MERGE --- src/clj/game/cards/agendas.clj | 20 ++++++-------- src/clj/game/core/rules.clj | 2 +- src/clj/game/core/runs.clj | 41 ++++++++++++++++------------ test/clj/game_test/cards/agendas.clj | 36 ++++++++++++------------ 4 files changed, 51 insertions(+), 48 deletions(-) diff --git a/src/clj/game/cards/agendas.clj b/src/clj/game/cards/agendas.clj index 9e48ef4064..7b4ef0eb1f 100644 --- a/src/clj/game/cards/agendas.clj +++ b/src/clj/game/cards/agendas.clj @@ -776,11 +776,8 @@ :effect (effect (add-counter card :power 2)) :abilities [{:req (req (:run @state)) :counter-cost [:power 1] - :effect (req (let [ls (filter #(= "Labyrinthine Servers" (:title %)) (:scored corp))] - (jack-out-prevent state side) - (when (zero? (reduce + (for [c ls] (get-counters c :power)))) - (swap! state update-in [:prevent] dissoc :jack-out)))) - :msg "prevent the Runner from jacking out"}]} + :msg "prevent the Runner from jacking out" + :effect (effect (jack-out-prevent))}]} "License Acquisition" {:interactive (req true) @@ -1032,16 +1029,17 @@ (when-let [ice (get-card state i)] (remove-sub! state side ice #(= cid (:from-cid %)))))) (update! state side (dissoc-in card [:special :kusanagi])))}} - :abilities [{:req (req (and (ice? current-ice) - (rezzed? current-ice) - (has-subtype? current-ice "Bioroid"))) + :abilities [{:label "Give a piece of ICE \"[Subroutine] Do 1 net damage\"" + :prompt "Choose a piece of ICE" + :choices {:req #(and (ice? %) + (rezzed? %))} :counter-cost [:agenda 1] :msg (str "make a piece of ICE gain \"[Subroutine] Do 1 net damage\" " "after all its other subroutines for the remainder of the run") - :effect (effect (add-extra-sub! (get-card state current-ice) + :effect (effect (add-extra-sub! (get-card state target) (do-net-damage 1) (:cid card) {:back true}) - (update! (update-in card [:special :kusanagi] #(conj % current-ice))))}]} + (update! (update-in card [:special :kusanagi] #(conj % target))))}]} "Project Vitruvius" {:silent (req true) @@ -1500,7 +1498,7 @@ "Veterans Program" {:interactive (req true) :msg "lose 2 bad publicity" - :effect (effect (lose :bad-publicity 2))} + :effect (effect (lose-bad-publicity 2))} "Viral Weaponization" (let [dmg {:msg "do 1 net damage for each card in the grip" diff --git a/src/clj/game/core/rules.clj b/src/clj/game/core/rules.clj index 2627a74c6f..b6389d1319 100644 --- a/src/clj/game/core/rules.clj +++ b/src/clj/game/core/rules.clj @@ -387,7 +387,7 @@ (resolve-bad-publicity state side eid n args)))))) (defn lose-bad-publicity - ([state side n] (lose-tags state side (make-eid state) n)) + ([state side n] (lose-bad-publicity state side (make-eid state) n)) ([state side eid n] (if (= n :all) (lose-bad-publicity state side eid (get-in @state [:corp :bad-publicity])) diff --git a/src/clj/game/core/runs.clj b/src/clj/game/core/runs.clj index 19d31bae92..60f2ace5ab 100644 --- a/src/clj/game/core/runs.clj +++ b/src/clj/game/core/runs.clj @@ -909,32 +909,37 @@ (prevent-jack-out state side)) (defn- resolve-jack-out - [state side eid] - (end-run state side) - (system-msg state side "jacks out") - (trigger-event-sync state side (make-result eid true) :jack-out)) + [state side eid prevented?] + (if prevented? + (effect-completed state side eid) + (do (end-run state side) + (system-msg state side "jacks out") + (trigger-event-sync state side eid :jack-out)))) (defn jack-out "The runner decides to jack out." - ([state side] (jack-out state side (make-eid state))) - ([state side eid] + ([state side] (jack-out state side (make-eid state) nil)) + ([state side eid] (jack-out state side eid nil)) + ([state side eid {:keys [unpreventable]}] (swap! state update-in [:jack-out] dissoc :jack-out-prevent) (wait-for (trigger-event-sync state side :pre-jack-out nil) (let [prevent (get-prevent-list state :corp :jack-out)] - (if (cards-can-prevent? state :corp prevent :jack-out) + (if (and (not unpreventable) + (cards-can-prevent? state :corp prevent :jack-out)) (do (system-msg state :corp "has the option to prevent the Runner from jacking out") (show-wait-prompt state :runner "Corp to prevent the jack out" {:priority 10}) - (show-prompt state :corp nil - (str "Prevent the Runner from jacking out?") ["Done"] - (fn [_] - (clear-wait-prompt state :runner) - (if-let [_ (get-in @state [:jack-out :jack-out-prevent])] - (effect-completed state side (make-result eid false)) - (do (system-msg state :corp "will not prevent the Runner from jacking out") - (resolve-jack-out state side eid)))) - {:priority 10})) - (do (resolve-jack-out state side eid) - (effect-completed state side (make-result eid false)))))))) + (show-prompt + state :corp nil + (str "Prevent the Runner from jacking out?") ["Done"] + (fn [_] + (let [prevented? (pos? (get-in @state [:jack-out :jack-out-prevent]))] + (clear-wait-prompt state :runner) + (system-msg state :corp + (str (if prevented? "will" "will not") + " prevent the Runner from jacking out")) + (resolve-jack-out state side eid prevented?))) + {:priority 10})) + (resolve-jack-out state side eid false)))))) (defn- trigger-run-end-events [state side eid run] diff --git a/test/clj/game_test/cards/agendas.clj b/test/clj/game_test/cards/agendas.clj index a056cebf1f..c74545930d 100644 --- a/test/clj/game_test/cards/agendas.clj +++ b/test/clj/game_test/cards/agendas.clj @@ -1371,7 +1371,7 @@ (card-ability state :corp ls1 0) (click-prompt state :corp "Done") (is (:run @state) "Jack out prevented, run is still ongoing") - (is (true? (get-in @state [:run :cannot-jack-out])) "Cannot jack out flag is in effect") + (is (get-in @state [:run :cannot-jack-out]) "Cannot jack out flag is in effect") (run-successful state) (is (not (:run @state)))) (testing "one Labyrinthine is empty but the other still has one token, ensure prompt still occurs" @@ -1382,7 +1382,7 @@ (is (:run @state)) (card-ability state :corp ls2 0) (click-prompt state :corp "Done") - (is (true? (get-in @state [:run :cannot-jack-out]))) + (is (get-in @state [:run :cannot-jack-out])) (run-successful state) (is (not (:run @state)))) (testing "No more tokens" @@ -1973,23 +1973,23 @@ (do-game (new-game {:corp {:deck [(qty "Project Kusanagi" 2) "Ice Wall"]}}) (play-from-hand state :corp "Ice Wall" "HQ") + (core/rez state :corp (get-ice state :hq 0)) (core/gain state :corp :click 10 :credit 10) - (testing "Should gain 0 counters" - (play-and-score state "Project Kusanagi") - (let [pk-scored (get-scored state :corp 0)] - (is (zero? (get-counters (refresh pk-scored) :agenda)) "Kusanagi should start with 0 agenda counters"))) - (testing "Should gain 1 counter" - (play-from-hand state :corp "Project Kusanagi" "New remote") - (let [pk (get-content state :remote2 0)] - (advance state pk 3) - (is (= 3 (get-counters (refresh pk) :advancement)) "Kusanagi should have 3 advancement tokens") - (core/score state :corp {:card (refresh pk)})) - (let [pk-scored (get-scored state :corp 1)] - (is (= 1 (get-counters (refresh pk-scored) :agenda)) "Kusanagi should have 1 agenda counter") - (run-empty-server state :hq) - (card-ability state :corp pk-scored 0) - (is (last-log-contains? state "Do 1 net damage")) - (is (zero? (get-counters (refresh pk-scored) :agenda)) "Kusanagi should have 0 agenda counters"))))) + (play-and-score state "Project Kusanagi") + (let [pk-scored (get-scored state :corp 0)] + (is (zero? (get-counters (refresh pk-scored) :agenda)) "Kusanagi should start with 0 agenda counters")) + (play-from-hand state :corp "Project Kusanagi" "New remote") + (let [pk (get-content state :remote2 0)] + (advance state pk 3) + (is (= 3 (get-counters (refresh pk) :advancement)) "Kusanagi should have 3 advancement tokens") + (core/score state :corp {:card (refresh pk)})) + (let [pk-scored (get-scored state :corp 1)] + (is (= 1 (get-counters (refresh pk-scored) :agenda)) "Kusanagi should have 1 agenda counter") + (run-empty-server state :hq) + (card-ability state :corp pk-scored 0) + (click-card state :corp (get-ice state :hq 0)) + (is (last-log-contains? state "Do 1 net damage")) + (is (zero? (get-counters (refresh pk-scored) :agenda)) "Kusanagi should have 0 agenda counters")))) (deftest project-vitruvius ;; Project Vitruvius