Skip to content
Draft
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
8 changes: 6 additions & 2 deletions src/clj/game/core/runs.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
5 changes: 3 additions & 2 deletions src/clj/game/core/set_up.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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)))))

Expand Down
4 changes: 3 additions & 1 deletion src/clj/web/lobby.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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}]
Expand Down Expand Up @@ -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}))

Expand Down Expand Up @@ -200,6 +201,7 @@
:date
:format
:gameid
:legacy-bad-pub
:precon
:messages
:mute-spectators
Expand Down
17 changes: 14 additions & 3 deletions src/cljs/nr/new_game.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
:api-access
:description
:format
:legacy-bad-pub
:password
:room
:save-replay
Expand Down Expand Up @@ -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]
Expand All @@ -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 ""
Expand All @@ -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))
Expand Down Expand Up @@ -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]]])))
6 changes: 4 additions & 2 deletions src/cljs/nr/pending_game.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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"]]
Expand All @@ -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]
Expand Down
18 changes: 18 additions & 0 deletions test/clj/game/core/rules_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions test/clj/game/test_framework.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)
Expand Down