Skip to content

Commit

Permalink
Bug fixes and test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahTheDuke committed Jul 24, 2019
1 parent 1db6100 commit 76e7558
Show file tree
Hide file tree
Showing 11 changed files with 106 additions and 77 deletions.
8 changes: 4 additions & 4 deletions src/clj/game/cards/ice.clj
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@
:prompt "You are encountering Archangel. Allow its subroutine to fire?"
:priority 1
:yes-ability {:async true
:effect (effect (play-subroutine eid {:card card :subroutine 0}))}
:effect (effect (resolve-unbroken-subs! eid card))}
:no-ability {:effect (effect (effect-completed eid))}}}
card nil))}
:no-ability {:effect (effect (system-msg :corp "declines to force the Runner to encounter Archangel")
Expand Down Expand Up @@ -2131,10 +2131,10 @@
(let [sub {:player :runner
:async true
:label (str "Do 1 net damage unless the Runner pays 1 [Credits]")
:prompt (str "Do 1 net damage or pay 1 [Credits]?")
:choices ["Do 1 net damage"
:prompt (str "Suffer 1 net damage or pay 1 [Credits]?")
:choices ["Suffer 1 net damage"
"Pay 1 [Credits]"]
:effect (req (if (= "Do 1 net damage" target)
:effect (req (if (= "Suffer 1 net damage" target)
(continue-ability state side (do-net-damage 1) card nil)
(do (pay state :runner :credit 1)
(effect-completed state side))))}]
Expand Down
10 changes: 6 additions & 4 deletions src/clj/game/cards/programs.clj
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
{:async true
:effect (req (wait-for (resolve-ability state side (break-subroutines-impl ice n) card nil)
(let [broken-subs async-result]
(wait-for (resolve-ability state side (break-subroutines-pay ice cost broken-subs) card nil)
(wait-for (resolve-ability state side (make-eid state {:source-type :ability})
(break-subroutines-pay ice cost broken-subs) card nil)
(doseq [sub broken-subs]
(break-subroutine! state (get-card state ice) sub))
(let [ice (get-card state ice)]
Expand All @@ -58,7 +59,7 @@
(pos? (count (unbroken-subroutines-choice ice)))
(can-pay? state side eid card nil cost))
(continue-ability state side (break-subroutines ice cost n ability) card nil)
(continue-ability state side ability card nil)))))))}))
(continue-ability state side {:effect ability} card nil)))))))}))

(defn break-sub
"Creates a break subroutine ability.
Expand All @@ -70,7 +71,8 @@
(seq (remove :broken (:subroutines current-ice)))
(<= (get-strength current-ice) (get-strength card))
(if subtype
(has-subtype? current-ice subtype)
(or (= "ICE" subtype)
(has-subtype? current-ice subtype))
true)))
:label (str (build-cost-str (if (number? cost) [:credit cost] cost))
": break "
Expand Down Expand Up @@ -1873,7 +1875,7 @@
stypes (:subtype ice)
remove-subtype
{:effect (effect (update! (assoc (get-card state ice) :subtype stypes))
(system-say (str (card-str state ice) " loses " chosen-type))
(system-say (str (card-str state ice) " loses " chosen-type "."))
(unregister-events card)
(register-events (:events (card-def card)) card))}]
(update! state side (assoc ice :subtype (combine-subtypes false stypes chosen-type)))
Expand Down
4 changes: 2 additions & 2 deletions src/clj/game/core/actions.clj
Original file line number Diff line number Diff line change
Expand Up @@ -606,8 +606,8 @@
(swap! state assoc-in [:run :no-action] false)
(system-msg state side "continues the run")
(when cur-ice
(reset-all-subs! state cur-ice)
(update-ice-strength state side cur-ice))
(reset-all-subs! state (get-card state cur-ice))
(update-ice-strength state side (get-card state cur-ice)))
(wait-for (trigger-event-simult state side (if next-ice :approach-ice :approach-server) nil (when next-ice next-ice))
(doseq [p (filter #(has-subtype? % "Icebreaker") (all-active-installed state :runner))]
(update! state side (update-in (get-card state p) [:pump] dissoc :encounter))
Expand Down
20 changes: 9 additions & 11 deletions test/clj/game_test/cards/assets.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3178,11 +3178,9 @@
(play-from-hand state :corp "Scorched Earth")
(is (= 4 (count (:discard (get-runner)))))
(is (= 1 (get-counters (refresh rc) :advancement)) "Reconstruction Contract has 1 advancement token")
(starting-hand state :runner ["Imp" "Imp"])
(play-from-hand state :corp "Pup" "HQ")
(core/rez state :corp (get-ice state :hq 0))
(card-subroutine state :corp (get-ice state :hq 0) 0)
(is (= 5 (count (:discard (get-runner)))))
(is (= 4 (count (:discard (get-runner)))))
(is (= 1 (get-counters (refresh rc) :advancement)) "Reconstruction Contract doesn't get advancement token for net damage"))))

(deftest reversed-accounts
Expand Down Expand Up @@ -4333,20 +4331,20 @@
(core/rez state :corp kak)
(is (= 1 (count (:subroutines (refresh kak)))) "Kakugo starts with 1 sub")
(core/rez state :corp eli)
(is (= 2 (count (:subroutines (refresh eli)))) "Eli 2.0 starts with 2 subs")
(is (= 2 (count (:subroutines (refresh ichi)))) "Unrezzed Ichi 2.0 starts with 2 subs")
(is (= 3 (count (:subroutines (refresh eli)))) "Eli 3.0 starts with 2 subs")
(is (= 3 (count (:subroutines (refresh ichi)))) "Unrezzed Ichi 2.0 starts with 3 subs")
(core/rez state :corp wf)
(is (= 1 (count (:subroutines (refresh kak)))) "Kakugo stays at 1 sub")
(is (= 3 (count (:subroutines (refresh eli)))) "Eli 2.0 gains 1 sub")
(is (= 2 (count (:subroutines (refresh ichi)))) "Unrezzed Ichi 2.0 stays at 2 subs")
(is (= 4 (count (:subroutines (refresh eli)))) "Eli 2.0 gains 1 sub")
(is (= 3 (count (:subroutines (refresh ichi)))) "Unrezzed Ichi 2.0 stays at 2 subs")
(core/rez state :corp ichi)
(is (= 1 (count (:subroutines (refresh kak)))) "Kakugo stays at 1 sub")
(is (= 3 (count (:subroutines (refresh eli)))) "Eli 2.0 stays at 1 sub")
(is (= 3 (count (:subroutines (refresh ichi)))) "Ichi 2.0 rezzes with 3 subs")
(is (= 4 (count (:subroutines (refresh eli)))) "Eli 2.0 stays at 4 subs")
(is (= 4 (count (:subroutines (refresh ichi)))) "Ichi 2.0 rezzes with 4 subs")
(core/derez state :corp (refresh wf))
(is (= 1 (count (:subroutines (refresh kak)))) "Kakugo stays at 1 sub")
(is (= 2 (count (:subroutines (refresh eli)))) "Eli 2.0 reverts")
(is (= 2 (count (:subroutines (refresh ichi)))) "Ichi 2.0 reverts"))))
(is (= 3 (count (:subroutines (refresh eli)))) "Eli 2.0 reverts")
(is (= 3 (count (:subroutines (refresh ichi)))) "Ichi 2.0 reverts"))))

(deftest watchdog
;; Watchdog - Reduce rez cost of first ICE per turn by number of Runner tags
Expand Down
1 change: 1 addition & 0 deletions test/clj/game_test/cards/events.clj
Original file line number Diff line number Diff line change
Expand Up @@ -1724,6 +1724,7 @@
(play-from-hand state :corp "Pup" "HQ")
(core/rez state :corp (get-ice state :hq 0))
(card-subroutine state :corp (get-ice state :hq 0) 0)
(click-prompt state :runner "Suffer 1 net damage")
(is (= 1 (count (:discard (get-runner)))))
(is (= 3 (count (:hand (get-runner)))) "I've Had Worse triggered and drew 3 cards")
(starting-hand state :runner ["I've Had Worse" "Imp" "Imp"])
Expand Down
12 changes: 10 additions & 2 deletions test/clj/game_test/cards/hardware.clj
Original file line number Diff line number Diff line change
Expand Up @@ -537,17 +537,23 @@
(is (empty? (:hosted (refresh fo))) "Mimic trashed"))))
(testing "Pay-credits prompt"
(do-game
(new-game {:runner {:deck ["Flame-out" "Mimic"]}})
(new-game {:corp {:deck [(qty "Hedge Fund" 5)]
:hand ["Owl"]}
:runner {:deck ["Flame-out" "Mimic"]}})
(play-from-hand state :corp "Owl" "HQ")
(core/rez state :corp (get-ice state :hq 0))
(take-credits state :corp)
(play-from-hand state :runner "Flame-out")
(let [fo (get-hardware state 0)]
(card-ability state :runner fo 2)
(click-card state :runner (find-card "Mimic" (:hand (get-runner))))
(click-card state :runner "Mimic")
(take-credits state :runner)
(take-credits state :corp)
(is (= 1 (count (:hosted (refresh fo)))) "Mimic still hosted")
(is (= 2 (:credit (get-runner))) "Runner starts with 2 credits")
(run-on state :hq)
(card-ability state :runner (first (:hosted (refresh fo))) 0)
(click-prompt state :runner "Add installed program to the top of the Runner's Stack")
(click-card state :runner fo)
(is (= 2 (:credit (get-runner))) "Runner has not paid any credits from their credit pool")
(take-credits state :runner)
Expand Down Expand Up @@ -678,6 +684,7 @@
(core/rez state :corp pup)
(core/rez state :corp nk)
(card-subroutine state :corp (refresh pup) 0)
(click-prompt state :runner "Suffer 1 net damage")
(is (= (-> (get-runner) :prompt first :msg)
"Prevent any of the 1 net damage?")
"Damage prevention message correct.")
Expand Down Expand Up @@ -2058,6 +2065,7 @@
(let [pup (get-ice state :hq 0)]
(core/rez state :corp pup)
(card-subroutine state :corp pup 0)
(click-prompt state :runner "Suffer 1 net damage")
(click-card state :runner (find-card "Sure Gamble" (:hand (get-runner)))) ; Ribs takes precedence over CP on Runner turn
(is (= 3 (count (:discard (get-runner)))) "Chose card lost from 1 net damage")
(run-jack-out state)
Expand Down
56 changes: 28 additions & 28 deletions test/clj/game_test/cards/ice.clj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
[game-test.macros :refer :all]
[clojure.test :refer :all]))

; peeping-tom
; salvage
; sensei
; swarm
Expand Down Expand Up @@ -1733,31 +1732,32 @@
(is (= "You accessed Otoroshi." (-> (get-runner) :prompt first :msg)) "Runner should access Otoroshi even tho it's an ice.")
(click-prompt state :runner "No action"))))

;(deftest peeping-tom
; ;;Peeping Tom - Counts # of chosen card type in Runner grip
; (do-game
; (new-game {:corp {:deck ["Peeping Tom"]}
; :runner {:deck [(qty "Sure Gamble" 5)]}})
; (play-from-hand state :corp "Peeping Tom" "HQ")
; (take-credits state :corp)
; (run-on state "HQ")
; (let [tom (get-ice state :hq 0)]
; (core/rez state :corp (refresh tom))
; (card-ability state :corp tom 0)
; (click-prompt state :corp "Hardware")
; (is (last-log-contains? state "Sure Gamble, Sure Gamble, Sure Gamble, Sure Gamble, Sure Gamble")
; "Revealed Runner grip")
; (is (last-log-contains? state "0") "Correctly counted Hardware in Runner grip")
; (card-ability state :corp tom 0)
; (click-prompt state :corp "Event")
; (is (last-log-contains? state "5") "Correctly counted Events in Runner grip")
; (card-side-ability state :runner tom 1)
; (card-side-ability state :runner tom 1)
; (card-side-ability state :runner tom 1)
; (card-side-ability state :runner tom 1)
; (is (= 4 (count-tags state)) "Tag ability sucessful")
; (card-side-ability state :runner tom 0)
; (is (not (:run @state)) "Run ended"))))
(deftest peeping-tom
;;Peeping Tom - Counts # of chosen card type in Runner grip
(do-game
(new-game {:corp {:deck ["Peeping Tom"]}
:runner {:deck [(qty "Sure Gamble" 5)]}})
(play-from-hand state :corp "Peeping Tom" "HQ")
(take-credits state :corp)
(run-on state "HQ")
(let [tom (get-ice state :hq 0)]
(core/rez state :corp (refresh tom))
(card-ability state :corp tom 0)
(click-prompt state :corp "Hardware")
(is (last-log-contains? state "Sure Gamble, Sure Gamble, Sure Gamble, Sure Gamble, Sure Gamble")
"Revealed Runner grip")
(is (last-log-contains? state "0") "Correctly counted Hardware in Runner grip")
(card-ability state :corp tom 0)
(click-prompt state :corp "Event")
(is (last-log-contains? state "5") "Correctly counted Events in Runner grip")
(core/resolve-unbroken-subs! state :corp (refresh tom))
(click-prompt state :runner "Take 1 tag")
(click-prompt state :runner "Take 1 tag")
(click-prompt state :runner "Take 1 tag")
(click-prompt state :runner "Take 1 tag")
(is (= 4 (count-tags state)) "Tag ability sucessful")
(click-prompt state :runner "End the run")
(is (not (:run @state)) "Run ended"))))

(deftest resistor
;; Resistor - Strength equal to Runner tags, lose strength when Runner removes a tag
Expand Down Expand Up @@ -2268,10 +2268,10 @@
(core/derez state :corp (refresh ti))
(is (= 2 (count (:hosted (refresh ti)))) "2 cards on Tithonium")
(run-on state "HQ")
(card-subroutine state :corp ti 2)
(card-subroutine state :corp ti 3)
(click-card state :corp (refresh wast))
(is (= 1 (count (:discard (get-runner)))) "1 card trashed")
(card-subroutine state :corp ti 1)
(card-subroutine state :corp ti 2)
(is (not (:run @state)) "Run ended")))))
(testing "Do not prompt for alt cost #2734"
(do-game
Expand Down
5 changes: 5 additions & 0 deletions test/clj/game_test/cards/identities.clj
Original file line number Diff line number Diff line change
Expand Up @@ -504,11 +504,13 @@
(let [pup (get-ice state :hq 0)]
(core/rez state :corp pup)
(card-subroutine state :corp pup 0)
(click-prompt state :runner "Suffer 1 net damage")
(click-prompt state :corp "Yes")
(let [imp (find-card "Imp" (:hand (get-runner)))]
(click-prompt state :corp imp)
(is (= 1 (count (:discard (get-runner)))))
(card-subroutine state :corp pup 0)
(click-prompt state :runner "Suffer 1 net damage")
(is (empty? (:prompt (get-corp))) "No choice on second net damage")
(is (= 2 (count (:discard (get-runner)))))
(run-jack-out state)
Expand Down Expand Up @@ -547,15 +549,18 @@
(let [pup (get-ice state :hq 0)]
(core/rez state :corp pup)
(card-subroutine state :corp pup 0)
(click-prompt state :runner "Suffer 1 net damage")
(is (empty? (:prompt (get-corp))) "No choice because of Employee Strike")
(card-subroutine state :corp pup 0)
(click-prompt state :runner "Suffer 1 net damage")
(is (= 2 (count (:discard (get-runner)))))
(run-jack-out state)
(take-credits state :runner)
(take-credits state :corp)
(play-from-hand state :runner "Scrubbed")
(run-on state :hq)
(card-subroutine state :corp pup 0)
(click-prompt state :runner "Suffer 1 net damage")
(is (seq (:prompt (get-corp))) "Employee Strike out of play - Ability turned on correctly")))))

(deftest edward-kim-humanity-s-hammer
Expand Down
4 changes: 2 additions & 2 deletions test/clj/game_test/cards/operations.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2963,13 +2963,13 @@
(click-card state :corp (refresh eli))
(is (= "Wetwork Refit" (:title (first (:hosted (refresh eli)))))
"Wetwork Refit is hosted on Eli 1.0")
(is (= 2 (count (:subroutines (refresh eli))))
(is (= 3 (count (:subroutines (refresh eli))))
"Eli 1.0 has 2 different subroutines")
(is (= "[Wetwork Refit] Do 1 brain damage" (:label (first (:subroutines (refresh eli)))))
"Eli 1.0 has a brain damage subroutine as his first subroutine")
(core/move state :corp (first (:hosted (refresh eli))) :hand)
(is (empty? (:hosted (refresh eli))) "No cards are hosted on Eli 1.0")
(is (= 1 (count (:subroutines (refresh eli))))
(is (= 2 (count (:subroutines (refresh eli))))
"Eli 1.0 has 1 different subroutine")
(is (= "End the run" (:label (first (:subroutines (refresh eli)))))
"Eli 1.0 has an end the run subroutine as his first subroutine")
Expand Down
Loading

0 comments on commit 76e7558

Please sign in to comment.