From 832b8b1c9b4c55b62fba3234560b5da7d9e6206b Mon Sep 17 00:00:00 2001 From: Filipe Silva Date: Sun, 28 Jun 2026 16:35:56 +0100 Subject: [PATCH] fix: hosting triggers uninstalled too Fix #8752 --- src/clj/game/core/hosting.clj | 17 +++++++++++------ test/clj/game/cards/assets_test.clj | 20 ++++++++++++++++++++ 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/src/clj/game/core/hosting.clj b/src/clj/game/core/hosting.clj index cdbc047568..27328ac85f 100644 --- a/src/clj/game/core/hosting.clj +++ b/src/clj/game/core/hosting.clj @@ -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]] @@ -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." diff --git a/test/clj/game/cards/assets_test.clj b/test/clj/game/cards/assets_test.clj index 3f56f0eb5d..b2eba536a9 100644 --- a/test/clj/game/cards/assets_test.clj +++ b/test/clj/game/cards/assets_test.clj @@ -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"]}