Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix :can-trash flag interaction #7208

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/clj/game/cards/events.clj
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
turn-events]]
[game.core.expose :refer [expose]]
[game.core.finding :refer [find-cid find-latest]]
[game.core.flags :refer [any-flag-fn? can-rez?
[game.core.flags :refer [any-flag-fn? can-rez? can-trash?
clear-all-flags-for-card! clear-run-flag! clear-turn-flag!
in-corp-scored? register-run-flag! register-turn-flag! zone-locked?]]
[game.core.gaining :refer [gain gain-clicks gain-credits lose lose-clicks
Expand Down Expand Up @@ -424,7 +424,8 @@
card
[{:event :access
:duration :end-of-turn
:req (req (not (in-discard? target)))
:req (req (and (can-trash? state :runner target)
(not (in-discard? target))))
:interactive (req true)
:async true
:msg (msg "trash " (:title target) " at no cost and suffer 1 meat damage")
Expand Down Expand Up @@ -953,6 +954,7 @@
:effect (effect (make-run eid target card))}
:interactions {:access-ability
{:label "Trash card"
:req (req (can-trash? state :runner target))
:msg (msg "trash " (:title target) " at no cost")
:async true
:effect (effect (trash eid (assoc target :seen true) {:cause-card card}))}}})
Expand Down
5 changes: 3 additions & 2 deletions src/clj/game/cards/hardware.clj
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
run-events]]
[game.core.expose :refer [expose]]
[game.core.finding :refer [find-card]]
[game.core.flags :refer [card-flag? in-corp-scored? register-run-flag!
[game.core.flags :refer [can-trash? card-flag? in-corp-scored? register-run-flag!
zone-locked?]]
[game.core.gaining :refer [gain-clicks gain-credits lose-clicks
lose-credits]]
Expand Down Expand Up @@ -396,7 +396,8 @@
:interactions
{:access-ability
{:label "Trash card"
:req (req (and (not (get-in @state [:per-turn (:cid card)]))
:req (req (and (can-trash? state :runner target)
(not (get-in @state [:per-turn (:cid card)]))
(<= 2 (count (:hand runner)))))
:cost [:trash-from-hand 2]
:msg (msg "trash " (:title target) " at no cost")
Expand Down
5 changes: 3 additions & 2 deletions src/clj/game/cards/programs.clj
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
first-successful-run-on-server? turn-events]]
[game.core.expose :refer [expose]]
[game.core.finding :refer [find-cid]]
[game.core.flags :refer [can-host? card-flag? lock-zone release-zone zone-locked?]]
[game.core.flags :refer [can-host? can-trash? card-flag? lock-zone release-zone zone-locked?]]
[game.core.gaining :refer [gain-clicks gain-credits lose-credits]]
[game.core.hosting :refer [host]]
[game.core.ice :refer [all-subs-broken-by-card? all-subs-broken?
Expand Down Expand Up @@ -1671,7 +1671,8 @@
(defcard "Imp"
{:data {:counter {:virus 2}}
:interactions {:access-ability {:label "Trash card"
:req (req (not (get-in @state [:per-turn (:cid card)])))
:req (req (and (can-trash? state :runner target)
(not (get-in @state [:per-turn (:cid card)]))))
:cost [:virus 1]
:msg (msg "trash " (:title target) " at no cost")
:once :per-turn
Expand Down
7 changes: 1 addition & 6 deletions test/clj/game/cards/events_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -5085,12 +5085,7 @@
(click-prompt state :runner "Server 1")
(run-continue state)
(click-card state :runner "Project Beale")
;; note: Imp does not check to see if the card can be trashed
;; the ability should fizzle though -nbkelly
(is (= ["[Imp] Hosted virus counter: Trash card" "No action"]
(mapv :value (:choices (prompt-map :runner)))))
(click-prompt state :runner "[Imp] Hosted virus counter: Trash card")
(is (= 0 (count (:discard (get-corp)))) "Beale was not trashed")))
(is (= ["No action"] (mapv :value (:choices (prompt-map :runner)))))))

(deftest planned-assault
;; Planned Assault
Expand Down
15 changes: 15 additions & 0 deletions test/clj/game/cards/programs_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3518,6 +3518,21 @@
"Ice Wall"
"Oberth Protocol"]))))

(deftest imp-cannot-trash-flag-interaction
;; Interaction with :can-trash flag
(do-game
(new-game {:corp {:hand ["Project Atlas"]}
:runner {:hand ["Imp" "Pinhole Threading"]}})
(play-from-hand state :corp "Project Atlas" "New remote")
(take-credits state :corp)
(play-from-hand state :runner "Imp")
(play-from-hand state :runner "Pinhole Threading")
(click-prompt state :runner "Archives")
(run-continue state)
(click-card state :runner "Project Atlas")
(is (= ["No action"] (prompt-buttons :runner)))
(click-prompt state :runner "No action")))

(deftest imp-vs-an-ambush
;; vs an ambush
(do-game
Expand Down