Skip to content
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
17 changes: 11 additions & 6 deletions src/clj/game/core/hosting.clj
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(ns game.core.hosting
(:require
[clojure.string :as str]
[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]]
Expand All @@ -24,13 +25,17 @@
(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"
"If a card is hosted (uninstalled) from being installed and active, then call its `leave-play` and `uninstall` fns"
[state side card {:keys [installed] :as target}]
(when-let [leave-play (:leave-play (card-def target))]
(when (and (not installed)
(installed? (get-card state target))
(active? (get-card state target)))
(leave-play state (keyword (clojure.string/lower-case (:side target))) (make-eid state) target nil))))
(when (and (not installed)
(installed? (get-card state target))
(active? (get-card state target)))
(let [target-side (keyword (str/lower-case (:side target)))
old-card (get-card state target)]
(when-let [leave-play (:leave-play (card-def target))]
(leave-play state target-side (make-eid state) target nil))
(when-let [uninstall-effect (:uninstall (card-def target))]
(uninstall-effect state target-side (make-eid state) old-card [{:old-card old-card}])))))

(defn host
"Host the target onto the card."
Expand Down
20 changes: 20 additions & 0 deletions test/clj/game/cards/assets_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3422,6 +3422,26 @@
(play-cards state :corp ["Extract" "Luana Campos"]))
"Took BP back")))

(deftest luana-cupellation
;; Hosting Luana on Cupellation uninstalls it and should return the hosted bad publicity #8752
(do-game
(new-game {:corp {:hand ["Luana Campos"]
:deck [(qty "IPO" 10)]
:bad-pub 1}
:runner {:hand ["Cupellation"]
:credits 10}})
(play-cards state :corp ["Luana Campos" "New remote" :rezzed])
(take-credits state :corp)
(play-from-hand state :runner "Cupellation")
(take-credits state :runner)
(click-prompt state :corp "Yes")
(is (= 0 (count-bad-pub state)) "Bad publicity is hosted on Luana")
(take-credits state :corp)
(run-empty-server state :remote1)
(is (changed? [(count-bad-pub state) 1]
(click-prompt state :runner "[Cupellation] 1 [Credits]: Host card"))
"Hosting Luana on Cupellation returns the bad publicity")))

(deftest magistrate-revontuler
(do-game
(new-game {:corp {:hand ["Magistrate Revontulet" "Greenmail" "Project Beale" "Project Atlas"]}
Expand Down
Loading