diff --git a/src/clj/game/core/runs.clj b/src/clj/game/core/runs.clj index 159121615e..877b7f1fa2 100644 --- a/src/clj/game/core/runs.clj +++ b/src/clj/game/core/runs.clj @@ -159,8 +159,12 @@ (wait-for (gain-run-credits state side (make-eid state eid) - (get-in @state [:runner :next-run-credit] 0)) - (swap! state assoc-in [:run :bad-publicity-available] (count-bad-pub state)) + (+ (get-in @state [:runner :next-run-credit] 0) + (if (get-in @state [:options :legacy-bad-pub]) + (count-bad-pub state) + 0))) + (when-not (get-in @state [:options :legacy-bad-pub]) + (swap! state assoc-in [:run :bad-publicity-available] (count-bad-pub state))) (swap! state assoc-in [:runner :next-run-credit] 0) (swap! state update-in [:runner :register :made-run] conj (first s)) (swap! state update-in [:stats side :runs :started] (fnil inc 0)) diff --git a/src/clj/game/core/set_up.clj b/src/clj/game/core/set_up.clj index 40c302707d..0ad8177b2b 100644 --- a/src/clj/game/core/set_up.clj +++ b/src/clj/game/core/set_up.clj @@ -79,7 +79,7 @@ (defn- init-game-state "Initialises the game state" - [{:keys [players gameid timer spectatorhands api-access save-replay room] :as game}] + [{:keys [players gameid timer spectatorhands api-access save-replay legacy-bad-pub room] :as game}] (let [corp (some #(when (corp? %) %) players) runner (some #(when (runner? %) %) players) corp-deck (create-deck (:deck corp)) @@ -108,7 +108,8 @@ {:timer timer :spectatorhands spectatorhands :api-access api-access - :save-replay save-replay} + :save-replay save-replay + :legacy-bad-pub legacy-bad-pub} (new-corp (:user corp) corp-identity corp-options (map #(assoc % :zone [:deck]) corp-deck) corp-deck-id corp-quote) (new-runner (:user runner) runner-identity runner-options (map #(assoc % :zone [:deck]) runner-deck) runner-deck-id runner-quote))))) diff --git a/src/clj/web/lobby.clj b/src/clj/web/lobby.clj index b85f8349ec..d0cf99d8bb 100644 --- a/src/clj/web/lobby.clj +++ b/src/clj/web/lobby.clj @@ -105,7 +105,7 @@ [{uid :uid user :user {:keys [gameid now - allow-spectator api-access format mute-spectators password room save-replay + allow-spectator api-access format legacy-bad-pub mute-spectators password room save-replay precon gateway-type side singleton spectatorhands timer title open-decklists description] :or {gameid (random-uuid) now (inst/now)}} :options}] @@ -134,6 +134,7 @@ :save-replay save-replay :spectatorhands spectatorhands :singleton (when (some #{format} `("standard" "startup" "casual" "eternal")) singleton) + :legacy-bad-pub (when (some #{format} '("casual" "eternal" "preconstructed" "chimera")) legacy-bad-pub) :timer timer :title title})) @@ -200,6 +201,7 @@ :date :format :gameid + :legacy-bad-pub :precon :messages :mute-spectators diff --git a/src/cljs/nr/new_game.cljs b/src/cljs/nr/new_game.cljs index 5ec05a277e..92d2acf9c4 100644 --- a/src/cljs/nr/new_game.cljs +++ b/src/cljs/nr/new_game.cljs @@ -14,6 +14,7 @@ :api-access :description :format + :legacy-bad-pub :password :room :save-replay @@ -250,7 +251,15 @@ {:style {:display (if (:api-access @options) "block" "none")}} [tr-element :p [:lobby_api-access-details "This allows access to information about your game to 3rd party extensions. Requires an API Key to be created in Settings."]]]]) -(defn options-section [options user] +(defn legacy-bad-pub [options fmt-state] + (when (#{"casual" "eternal" "preconstructed" "chimera"} @fmt-state) + [:p + [:label + [:input {:type "checkbox" :checked (:legacy-bad-pub @options) + :on-change #(swap! options assoc :legacy-bad-pub (.. % -target -checked))}] + "Legacy bad publicity"]])) + +(defn options-section [options user fmt-state] [:section [tr-element :h3 [:lobby_options "Options"]] [allow-spectators options] @@ -259,7 +268,8 @@ [password-input options] [add-timer options] [save-replay options] - [api-access options user]]) + [api-access options user] + [legacy-bad-pub options fmt-state]]) (defn create-new-game [lobby-state user] (r/with-let [state (r/atom {:flash-message "" @@ -271,6 +281,7 @@ :title (str (:username @user) "'s game")}) options (r/atom {:allow-spectator true :api-access false + :legacy-bad-pub false :password "" :protected false :save-replay (not= "casual" (:room @lobby-state)) @@ -301,4 +312,4 @@ [side-section side] [format-section fmt options gateway-type precon] [description-section description] - [options-section options user]]]))) + [options-section options user fmt]]]))) diff --git a/src/cljs/nr/pending_game.cljs b/src/cljs/nr/pending_game.cljs index ff84c9e420..16d689b942 100644 --- a/src/cljs/nr/pending_game.cljs +++ b/src/cljs/nr/pending_game.cljs @@ -175,7 +175,7 @@ @players))]) (defn options-list [current-game] - (let [{:keys [allow-spectator api-access password + (let [{:keys [allow-spectator api-access legacy-bad-pub password save-replay spectatorhands timer]} @current-game] [:<> [tr-element :h3 [:lobby_options "Options"]] @@ -196,7 +196,9 @@ [tr-element :p [:lobby_save-replay-unshared "Only your latest 15 unshared games will be kept, so make sure to either download or share the match afterwards."]] [tr-element :p [:lobby_save-replay-beta "BETA Functionality: Be aware that we might need to reset the saved replays, so make sure to download games you want to keep. Also, please keep in mind that we might need to do future changes to the site that might make replays incompatible."]]]]) (when api-access - [tr-element :li [:lobby_api-access "Allow API access to game information"]])]])) + [tr-element :li [:lobby_api-access "Allow API access to game information"]]) + (when legacy-bad-pub + [tr-element :li [:lobby_legacy-bad-publicity "Legacy bad publicity"]])]])) (defn spectator-list [current-game] (let [{:keys [allow-spectator spectators]} @current-game] diff --git a/test/clj/game/core/rules_test.clj b/test/clj/game/core/rules_test.clj index b97aab617a..f89dee1904 100644 --- a/test/clj/game/core/rules_test.clj +++ b/test/clj/game/core/rules_test.clj @@ -391,6 +391,24 @@ (select-bad-pub state 1) (is (= 5 (:credit (get-runner))) "1 BP credit spent to trash CVS"))) +(deftest legacy-bad-publicity-credits + ;; With legacy-bad-pub option, bad pub credits are added as run-credits + ;; and bad-publicity-available is not tracked on the run + (do-game + (new-game {:corp {:deck [(qty "Cyberdex Virus Suite" 3)] + :bad-pub 1} + :options {:legacy-bad-pub true}}) + (is (= 1 (count-bad-pub state)) "Corp starts with 1 BP") + (play-from-hand state :corp "Cyberdex Virus Suite" "New remote") + (take-credits state :corp) + (run-on state :remote1) + (is (= 1 (:run-credit (get-runner))) "Runner gained 1 run credit from bad pub") + (is (nil? (get-in @state [:run :bad-publicity-available])) "No bad-publicity-available tracking in legacy mode") + (run-continue state) + (click-prompt state :corp "No") + (click-prompt state :runner "Pay 1 [Credits] to trash") + (is (zero? (:run-credit (get-runner))) "Run credits cleared after run ends"))) + (deftest run-psi-bad-publicity-credits ;; Should pay from Bad Pub for Psi games during run #2374 (do-game diff --git a/test/clj/game/test_framework.clj b/test/clj/game/test_framework.clj index 5b1128c57d..a712c7efa6 100644 --- a/test/clj/game/test_framework.clj +++ b/test/clj/game/test_framework.clj @@ -350,7 +350,8 @@ :start-as (:start-as options) :dont-start-turn (:dont-start-turn options) :dont-start-game (:dont-start-game options) - :format (or (:format options) :casual)}) + :format (or (:format options) :casual) + :legacy-bad-pub (:legacy-bad-pub options)}) (defn stack-deck "Stacks the top of the deck with the named cards in order, if possible" @@ -374,10 +375,11 @@ "Init a new game using given corp and runner. Keep starting hands (no mulligan) and start Corp's turn." ([] (new-game nil)) ([players] - (let [{:keys [corp runner mulligan start-as dont-start-turn dont-start-game format]} (make-decks players) + (let [{:keys [corp runner mulligan start-as dont-start-turn dont-start-game format legacy-bad-pub]} (make-decks players) state (core/init-game {:gameid 1 :format format + :legacy-bad-pub legacy-bad-pub :players [{:side "Corp" :user {:username "Corp"} :deck {:identity (:identity corp)