Skip to content

Commit a162058

Browse files
authored
Merge pull request #8011 from NBKelly/malia-vs-cupellation
hosting cards out of play calls leave-play fns
2 parents 4fcf826 + e937f75 commit a162058

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/clj/game/core/hosting.clj

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(ns game.core.hosting
22
(:require
3-
[game.core.card :refer [assoc-host-zones corp? get-card program? rezzed? runner?]]
3+
[game.core.card :refer [active? assoc-host-zones corp? get-card program? installed? rezzed? runner?]]
44
[game.core.card-defs :refer [card-def]]
55
[game.core.effects :refer [register-static-abilities unregister-static-abilities]]
66
[game.core.eid :refer [make-eid]]
@@ -23,11 +23,21 @@
2323
[card target]
2424
(when (and card target) (or (same-card? card target) (has-ancestor? (:host card) target))))
2525

26+
(defn handle-card-is-uninstalled
27+
"If a card is hosted (uninstalled) from being installed and active, then call it's `leave-play` fn"
28+
[state side card {:keys [installed] :as target}]
29+
(when-let [leave-play (:leave-play (card-def target))]
30+
(when (and (not installed)
31+
(installed? (get-card state target))
32+
(active? (get-card state target)))
33+
(leave-play state (keyword (clojure.string/lower-case (:side target))) (make-eid state) target nil))))
34+
2635
(defn host
2736
"Host the target onto the card."
2837
([state side card target] (host state side card target nil))
2938
([state side card {:keys [zone cid host installed] :as target} {:keys [facedown no-mu]}]
3039
(when (not= cid (:cid card))
40+
(handle-card-is-uninstalled state side card target)
3141
(unregister-events state side target)
3242
(unregister-static-abilities state side target)
3343
(doseq [s [:runner :corp]]

test/clj/game/cards/assets_test.clj

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3277,6 +3277,21 @@
32773277
(click-prompt state :corp "8")
32783278
(is (= (+ credits 8) (:credit (get-corp))) "Corp should gain 8 credits from Long-Term Investment ability")))))
32793279

3280+
(deftest malia-icon-goes-away-with-cupellation
3281+
(do-game
3282+
(new-game {:corp {:hand ["Malia Z0L0K4"]}
3283+
:runner {:hand ["Daily Casts" "Cupellation"]}})
3284+
(play-from-hand state :corp "Malia Z0L0K4" "New remote")
3285+
(take-credits state :corp)
3286+
(play-from-hand state :runner "Daily Casts")
3287+
(rez state :corp (get-content state :remote1 0))
3288+
(click-card state :corp "Daily Casts")
3289+
(is (:icon (refresh (get-resource state 0))) "Daily Cast has an icon")
3290+
(play-from-hand state :runner "Cupellation")
3291+
(run-empty-server state :remote1)
3292+
(click-prompt state :runner "[Cupellation] 1 [Credits]: Host card")
3293+
(is (not (:icon (refresh (get-resource state 0)))) "Daily Cast does not have an icon anymore")))
3294+
32803295
(deftest malia-z0l0k4
32813296
;; Malia Z0L0K4 - blank an installed non-virtual runner resource
32823297
(do-game

0 commit comments

Comments
 (0)