Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
12 changes: 11 additions & 1 deletion src/clj/game/core/hosting.clj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(ns game.core.hosting
(:require
[game.core.card :refer [assoc-host-zones corp? get-card program? rezzed? runner?]]
[game.core.card :refer [active? assoc-host-zones corp? get-card program? installed? rezzed? runner?]]
[game.core.card-defs :refer [card-def]]
[game.core.effects :refer [register-static-abilities unregister-static-abilities]]
[game.core.eid :refer [make-eid]]
Expand All @@ -23,11 +23,21 @@
[card target]
(when (and card target) (or (same-card? card target) (has-ancestor? (:host card) target))))

(defn handle-card-is-uninstalled
"If a card is hosted (uninstalled) from being installed and active, then call it's `leave-play` fn"
[state side card {:keys [installed] :as target}]
(when-let [leave-play-fn (and (active? (get-card state target))
(not installed)
(installed? (get-card state target))
(:leave-play (card-def target)))]
(leave-play-fn state (keyword (clojure.string/lower-case (:side target))) (make-eid state) target nil)))

(defn host
"Host the target onto the card."
([state side card target] (host state side card target nil))
([state side card {:keys [zone cid host installed] :as target} {:keys [facedown no-mu]}]
(when (not= cid (:cid card))
(handle-card-is-uninstalled state side card target)
(unregister-events state side target)
(unregister-static-abilities state side target)
(doseq [s [:runner :corp]]
Expand Down
15 changes: 15 additions & 0 deletions test/clj/game/cards/assets_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3273,6 +3273,21 @@
(click-prompt state :corp "8")
(is (= (+ credits 8) (:credit (get-corp))) "Corp should gain 8 credits from Long-Term Investment ability")))))

(deftest malia-icon-goes-away-with-cupellation
(do-game
(new-game {:corp {:hand ["Malia Z0L0K4"]}
:runner {:hand ["Daily Casts" "Cupellation"]}})
(play-from-hand state :corp "Malia Z0L0K4" "New remote")
(take-credits state :corp)
(play-from-hand state :runner "Daily Casts")
(rez state :corp (get-content state :remote1 0))
(click-card state :corp "Daily Casts")
(is (:icon (refresh (get-resource state 0))) "Daily Cast has an icon")
(play-from-hand state :runner "Cupellation")
(run-empty-server state :remote1)
(click-prompt state :runner "[Cupellation] 1 [Credits]: Host card")
(is (not (:icon (refresh (get-resource state 0)))) "Daily Cast does not have an icon anymore")))

(deftest malia-z0l0k4
;; Malia Z0L0K4 - blank an installed non-virtual runner resource
(do-game
Expand Down