Skip to content

Commit

Permalink
Merge pull request #7038 from francescopellegrini/attini-test
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahTheDuke authored Aug 12, 2023
2 parents a75586a + 0c92d81 commit 6794a14
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/clj/game/cards/ice.clj
Original file line number Diff line number Diff line change
Expand Up @@ -769,23 +769,25 @@
;; TODO - this should provide an aura that prevents the runner from paying credits
;; for paid abilities during subroutine resolution
;; we can figure out how to do that type of thing some time in the future
(let [sub {:label "Do 1 net damage unless runner pays 2 [Credits] (Do 1 net damage)"
:msg (msg "do 1 net damage" (when-not (threat-level 4 state) " unless the runner pays 2 [Credits]"))
(let [sub {:label "Do 1 net damage unless the Runner pays 2 [Credits]"
:async true
:effect (req (if (threat-level 3 state)
(damage state :corp eid :net 1)
(damage state side eid :net 1 {:card card})
(continue-ability
state side
{:prompt "Choose one"
:waiting-prompt true
:player :runner
:choices (req [(when (can-pay? state :runner (assoc eid :source card :source-type :ability) card nil [:credit 2]) "Pay 2 [Credit]")
"Corp does 1 net damage"])
:effect (req (if (= "Corp does 1 net damage" target)
(damage state :corp eid :net 1)
(continue-ability state side (runner-pays [:credit 2]) card nil)))
:msg (msg (if (= "Corp does 1 net damage" target)
:choices (req ["Take 1 net damage"
(when (can-pay? state :runner (assoc eid :source card :source-type :ability) card nil [:credit 2]) "Pay 2 [Credits]")])
:effect
(req (if (= "Take 1 net damage" target)
(damage state side eid :net 1 {:card card})
(wait-for (pay state :runner (make-eid state eid) card [:credit 2])
(effect-completed state side eid))))
:msg (msg (if (= "Take 1 net damage" target)
"do 1 net damage"
"force the runner to pay 2 [Credits]"))}
(str "force the runner to " (decapitalize target))))}
card nil)))}]
{:implementation "preventing paid abilities with credit costs not implemented (yet)"
:subroutines [sub
Expand Down
64 changes: 64 additions & 0 deletions test/clj/game/cards/ice_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,70 @@
(rez state :corp (refresh ab))
(is (= 5 (:credit (get-corp))) "Paid 3 credits to rez; 2 advancments on Asteroid Belt"))))

(deftest attini
(do-game
(new-game {:corp {:hand ["Attini"]
:credits 10}
:runner {:hand ["Sure Gamble" "Caldera"]
:credits 10}})
(play-from-hand state :corp "Attini" "Archives")
(take-credits state :corp)
(let [att (get-ice state :archives 0)]
(play-from-hand state :runner "Caldera")
(run-on state "Archives")
(rez state :corp (refresh att))
(run-continue state)
(fire-subs state att)
(changes-val-macro
-2 (:credit (get-runner))
"Runner lost 2 credits"
(click-prompt state :runner "Pay 2 [Credits]"))
(changes-val-macro
0 (count (:hand (get-runner)))
"Runner prevented 1 net damage"
(click-prompt state :runner "Take 1 net damage")
(card-ability state :runner (get-resource state 0) 0))
(changes-val-macro
-1 (count (:hand (get-runner)))
"Runner got 1 damage"
(click-prompt state :runner "Take 1 net damage")
(click-prompt state :runner "Done")))))

(deftest attini-threat-ability
(do-game
(new-game {:corp {:hand ["Attini" "Obokata Protocol"]
:credits 10}
:runner {:hand [(qty "Sure Gamble" 3)]}})
(play-and-score state "Obokata Protocol")
(play-from-hand state :corp "Attini" "HQ")
(take-credits state :corp)
(let [att (get-ice state :hq 0)]
(run-on state "HQ")
(rez state :corp (refresh att))
(run-continue state)
(changes-val-macro
-3 (count (:hand (get-runner)))
"Runner took 3 damage and couldn't choose to spend credits"
(fire-subs state att)))))

(deftest ^:kaocha/pending attini-threat-ability-cannot-spend-credits
(do-game
(new-game {:corp {:hand ["Attini" "Obokata Protocol"]
:credits 10}
:runner {:hand [(qty "Sure Gamble" 3) "Caldera"]}})
(play-and-score state "Obokata Protocol")
(play-from-hand state :corp "Attini" "HQ")
(take-credits state :corp)
(let [att (get-ice state :hq 0)]
(play-from-hand state :runner "Caldera")
(run-on state "HQ")
(rez state :corp (refresh att))
(run-continue state)
(changes-val-macro
-3 (count (:hand (get-runner)))
"Runner took 3 damage and couldn't prevent any of them by spending credits"
(fire-subs state att)))))

(deftest authenticator-encounter-decline-to-take-tag
(do-game
(new-game{:corp {:hand ["Authenticator"]}})
Expand Down

0 comments on commit 6794a14

Please sign in to comment.