From c2e68a0759b7c937e00d6185afb6b9491cd7db1d Mon Sep 17 00:00:00 2001 From: Noah Bogart Date: Thu, 4 Apr 2024 01:26:03 -0400 Subject: [PATCH 1/2] Track actions in play-ability, add :action flag to ability maps Simplifies Deep Red impl, differentiates between :card-ability-addditional-cost and :card-ability-cost effects, makes play-ability use eid if provided --- src/clj/game/cards/agendas.clj | 2 +- src/clj/game/cards/basic.clj | 39 +++++++---- src/clj/game/cards/hardware.clj | 20 ++---- src/clj/game/cards/identities.clj | 6 +- src/clj/game/cards/programs.clj | 8 ++- src/clj/game/cards/resources.clj | 2 +- src/clj/game/core.clj | 1 - src/clj/game/core/actions.clj | 93 ++++++++++++++++----------- src/clj/game/core/commands.clj | 2 - src/clj/game/core/cost_fns.clj | 20 ++++-- src/clj/game/core/costs.clj | 3 - src/clj/game/core/payment.clj | 2 +- test/clj/game/cards/hardware_test.clj | 21 +++++- test/clj/game/core/actions_test.clj | 13 +++- 14 files changed, 142 insertions(+), 90 deletions(-) diff --git a/src/clj/game/cards/agendas.clj b/src/clj/game/cards/agendas.clj index 1bd3de9f50..8cbaa455f2 100644 --- a/src/clj/game/cards/agendas.clj +++ b/src/clj/game/cards/agendas.clj @@ -1045,7 +1045,7 @@ :stolen he})) (defcard "Ikawah Project" - {:steal-cost-bonus (req [(->c :credit 2) (->c :click 1)])}) + {:steal-cost-bonus (req [(->c :click 1) (->c :credit 2)])}) (defcard "Illicit Sales" {:on-score diff --git a/src/clj/game/cards/basic.clj b/src/clj/game/cards/basic.clj index 45b62547b0..3647429001 100644 --- a/src/clj/game/cards/basic.clj +++ b/src/clj/game/cards/basic.clj @@ -28,7 +28,8 @@ ;; Card definitions (defcard "Corp Basic Action Card" - {:abilities [{:label "Gain 1 [Credits]" + {:abilities [{:action true + :label "Gain 1 [Credits]" :cost [(->c :click)] :msg "gain 1 [Credits]" :async true @@ -37,7 +38,8 @@ (trigger-event state side :corp-click-credit) (play-sfx state side "click-credit") (effect-completed state side eid)))} - {:label "Draw 1 card" + {:action true + :label "Draw 1 card" :req (req (not-empty (:deck corp))) :cost [(->c :click)] :msg "draw 1 card" @@ -46,7 +48,8 @@ (swap! state update-in [:stats side :click :draw] (fnil inc 0)) (play-sfx state side "click-card") (draw state side eid 1))} - {:label "Install 1 agenda, asset, upgrade, or piece of ice from HQ" + {:action true + :label "Install 1 agenda, asset, upgrade, or piece of ice from HQ" :async true :req (req (and (not-empty (:hand corp)) (in-hand? target) @@ -73,7 +76,8 @@ state side (assoc eid :source server :source-type :corp-install) target server {:base-cost [(->c :click 1)] :action :corp-click-install})))} - {:label "Play 1 operation" + {:action true + :label "Play 1 operation" :async true :req (req (and (not-empty (:hand corp)) (in-hand? target) @@ -82,7 +86,8 @@ target {:base-cost [(->c :click 1)]}))) :effect (req (play-instant state :corp (assoc eid :source :action :source-type :play) target {:base-cost [(->c :click 1)]}))} - {:label "Advance 1 installed card" + {:action true + :label "Advance 1 installed card" :cost [(->c :click 1) (->c :credit 1)] :async true :msg (msg "advance " (card-str state target)) @@ -91,7 +96,8 @@ (add-prop (get-card state target) :advance-counter 1) (play-sfx "click-advance") (effect-completed eid))} - {:label "Trash 1 resource if the Runner is tagged" + {:action true + :label "Trash 1 resource if the Runner is tagged" :cost [(->c :click 1) (->c :credit 2)] :async true :req (req tagged) @@ -140,7 +146,8 @@ (if async-result (trash state side eid target nil) (effect-completed state side eid)))))))} - {:label "Purge virus counters" + {:action true + :label "Purge virus counters" :cost [(->c :click 3)] :msg "purge all virus counters" :async true @@ -148,7 +155,8 @@ (purge state side eid))}]}) (defcard "Runner Basic Action Card" - {:abilities [{:label "Gain 1 [Credits]" + {:abilities [{:action true + :label "Gain 1 [Credits]" :cost [(->c :click)] :msg "gain 1 [Credits]" :async true @@ -157,7 +165,8 @@ (trigger-event state side :runner-click-credit) (play-sfx state side "click-credit") (effect-completed state side eid)))} - {:label "Draw 1 card" + {:action true + :label "Draw 1 card" :req (req (not-empty (:deck runner))) :cost [(->c :click)] :msg "draw 1 card" @@ -165,7 +174,8 @@ (swap! state update-in [:stats side :click :draw] (fnil inc 0)) (play-sfx state side "click-card") (draw state side eid (+ 1 (use-bonus-click-draws! state))))} - {:label "Install 1 program, resource, or piece of hardware from the grip" + {:action true + :label "Install 1 program, resource, or piece of hardware from the grip" :async true :req (req (and (not-empty (:hand runner)) (in-hand? target) @@ -179,7 +189,8 @@ state :runner (assoc eid :source :action :source-type :runner-install) target {:base-cost [(->c :click 1)] :no-toast true}))} - {:label "Play 1 event" + {:action true + :label "Play 1 event" :async true :req (req (and (not-empty (:hand runner)) (in-hand? target) @@ -188,10 +199,12 @@ target {:base-cost [(->c :click 1)]}))) :effect (req (play-instant state :runner (assoc eid :source :action :source-type :play) target {:base-cost [(->c :click 1)]}))} - {:label "Run any server" + {:action true + :label "Run any server" :async true :effect (effect (make-run eid target nil {:click-run true}))} - {:label "Remove 1 tag" + {:action true + :label "Remove 1 tag" :cost [(->c :click 1) (->c :credit 2)] :msg "remove 1 tag" :req (req tagged) diff --git a/src/clj/game/cards/hardware.clj b/src/clj/game/cards/hardware.clj index eda6bf22b6..479db9adc6 100644 --- a/src/clj/game/cards/hardware.clj +++ b/src/clj/game/cards/hardware.clj @@ -1,12 +1,11 @@ (ns game.cards.hardware (:require [clojure.set :as set] - [clojure.string :as str] [game.core.access :refer [access-bonus access-card breach-server get-only-card-to-access]] [game.core.actions :refer [play-ability]] [game.core.board :refer [all-active all-active-installed all-installed]] - [game.core.card :refer [active? corp? event? facedown? get-card get-counters get-title + [game.core.card :refer [corp? event? facedown? get-card get-counters get-title get-zone hardware? has-subtype? ice? in-deck? in-discard? in-hand? in-scored? installed? is-type? program? resource? rezzed? runner? virus-program? faceup?]] @@ -20,7 +19,7 @@ [game.core.effects :refer [register-lingering-effect unregister-effects-for-card unregister-lingering-effects]] [game.core.eid :refer [effect-completed make-eid make-result]] - [game.core.engine :refer [can-trigger? not-used-once? register-events + [game.core.engine :refer [can-trigger? register-events register-once register-suppress resolve-ability trigger-event unregister-floating-events unregister-suppress-by-uuid]] [game.core.events :refer [event-count first-event? first-run-event? first-trash? no-event? @@ -667,18 +666,9 @@ :prompt "Trigger the [Click] ability of the just-installed Caïssa program?" :yes-ability {:async true - :effect (effect - (continue-ability - (let [cid (:cid (:card context))] - {:async true - :prompt "Choose the just-installed Caïssa program" - :choices {:card #(= cid (:cid %))} - :msg (msg "trigger the [Click] ability of " (:title target) - " without spending [Click]") - :effect (req (gain-clicks state :runner 1) - (play-ability state side {:card target :ability 0}) - (effect-completed state side eid))}) - card nil))}}}]}) + :effect (effect (play-ability eid {:card (:card context) + :ability 0 + :ignore-cost true}))}}}]}) (defcard "Demolisher" {:static-abilities [(mu+ 1) diff --git a/src/clj/game/cards/identities.clj b/src/clj/game/cards/identities.clj index 8e5950cafb..db08e83572 100644 --- a/src/clj/game/cards/identities.clj +++ b/src/clj/game/cards/identities.clj @@ -607,7 +607,7 @@ {:events [(assoc ability :event :runner-trash :req (req (valid-trash target))) (assoc ability :event :agenda-stolen :req (req true))] :abilities [{:label "Look at the top 3 cards of R&D" - :cost [(->c :power 1) (->c :click 1)] + :cost [(->c :click 1) (->c :power 1)] :msg "look at the top 3 cards of R&D" :effect (req (let [top (take 3 (:deck corp))] (wait-for (resolve-ability state side @@ -2020,12 +2020,12 @@ {}) (defcard "SYNC: Everything, Everywhere" - {:static-abilities [{:type :card-ability-additional-cost + {:static-abilities [{:type :card-ability-cost :req (req (and (not (:sync-flipped card)) (same-card? (:card context) (:basic-action-card runner)) (= "Remove 1 tag" (:label (:ability context))))) :value (->c :credit 1)} - {:type :card-ability-additional-cost + {:type :card-ability-cost :req (req (and (:sync-flipped card) (same-card? (:card context) (:basic-action-card corp)) (= "Trash 1 resource if the Runner is tagged" (:label (:ability context))))) diff --git a/src/clj/game/cards/programs.clj b/src/clj/game/cards/programs.clj index 183b709174..88d8393948 100644 --- a/src/clj/game/cards/programs.clj +++ b/src/clj/game/cards/programs.clj @@ -685,7 +685,7 @@ (letfn [(was-a-runner-card? [target] (runner? (:card (first target))))] - {:static-abilities [{:type :card-ability-additional-cost + {:static-abilities [{:type :card-ability-cost :req (req (and (same-card? card (:card context)) (not (no-event? state side :runner-trash was-a-runner-card?)))) :value (->c :credit -1)}] @@ -1904,7 +1904,8 @@ (let [knight-req (req (and (same-card? current-ice (get-nested-host card)) (<= (get-strength current-ice) (get-strength card))))] {:implementation "[Erratum] Program: Icebreaker - AI - Caïssa - Trojan" - :abilities [{:label "Host on a piece of ice" + :abilities [{:action true + :label "Host on a piece of ice" :async true :effect (req (let [k (get-card state card) hosted (ice? (:host k)) @@ -3297,7 +3298,8 @@ (defcard "Trope" {:events [{:event :runner-turn-begins :effect (effect (add-counter card :power 1))}] - :abilities [{:req (req (not (zone-locked? state :runner :discard))) + :abilities [{:action true + :req (req (not (zone-locked? state :runner :discard))) :label "shuffle cards from heap into stack" :async true :effect diff --git a/src/clj/game/cards/resources.clj b/src/clj/game/cards/resources.clj index 28375e1649..a68a5a3241 100644 --- a/src/clj/game/cards/resources.clj +++ b/src/clj/game/cards/resources.clj @@ -2054,7 +2054,7 @@ :duration :end-of-run :effect (effect (enable-server (first (:server target))))}] {:abilities [{:label "Run a remote server" - :cost [(->c :trash-can) (->c :click 1) (->c :brain 1)] + :cost [(->c :click 1) (->c :trash-can) (->c :brain 1)] :prompt "Choose a remote server" :choices (req (cancellable (filter #(can-run-server? state %) remotes))) :msg (msg "make a run on " target " during which cards in the root of the attacked server lose all abilities") diff --git a/src/clj/game/core.clj b/src/clj/game/core.clj index d1755a8ca5..5b5850988c 100644 --- a/src/clj/game/core.clj +++ b/src/clj/game/core.clj @@ -121,7 +121,6 @@ generate-install-list generate-runnable-zones move-card - play play-ability play-auto-pump play-auto-pump-and-break diff --git a/src/clj/game/core/actions.clj b/src/clj/game/core/actions.clj index a71bc010f2..da70c9d40c 100644 --- a/src/clj/game/core/actions.clj +++ b/src/clj/game/core/actions.clj @@ -4,7 +4,7 @@ [clojure.stacktrace :refer [print-stack-trace]] [clojure.string :as string] [game.core.agendas :refer [update-advancement-requirement update-all-advancement-requirements update-all-agenda-points]] - [game.core.board :refer [get-zones installable-servers]] + [game.core.board :refer [installable-servers]] [game.core.card :refer [get-agenda-points get-card]] [game.core.card-defs :refer [card-def]] [game.core.cost-fns :refer [break-sub-ability-cost card-ability-cost score-additional-cost-bonus]] @@ -29,29 +29,40 @@ [game.macros :refer [continue-ability req wait-for]] [game.utils :refer [dissoc-in quantify remove-once same-card? same-side? server-cards]])) +(defn- update-click-state + "Update :click-states to hold latest 4 moments before performing actions." + [state ability] + (when (or (:action ability) + (= :click (:cost/type (first (:cost ability))))) + (let [state' (dissoc @state :log :history) + click-states (vec (take-last 4 (conj (:click-states state') state')))] + (swap! state assoc :click-states click-states)))) + ;;; Neutral actions -(defn- do-play-ability [state side card ability ability-idx targets] - (let [cost (seq (card-ability-cost state side ability card targets)) - source {:source card +(defn- do-play-ability [state side eid {:keys [card ability ability-idx targets ignore-cost]}] + (let [source {:source card :source-type :ability :source-info {:ability-idx ability-idx - :ability-targets targets}}] + :ability-targets targets}} + eid (or eid (make-eid state source)) + cost (when-not ignore-cost + (seq (card-ability-cost state side ability card targets))) + ability (assoc ability :cost cost)] (when (or (nil? cost) - (can-pay? state side (make-eid state source) - card (:title card) cost)) - (let [eid (make-eid state source)] - (resolve-ability state side eid (assoc ability :cost cost) card targets))))) + (can-pay? state side eid card (:title card) cost)) + (update-click-state state ability) + (resolve-ability state side eid ability card targets)))) (defn play-ability "Triggers a card's ability using its zero-based index into the card's card-def :abilities vector." - [state side {:keys [card ability targets]}] - (let [card (get-card state card) - abilities (:abilities card) - ab (nth abilities ability) - cannot-play (or (:disabled card) - (any-effects state side :prevent-paid-ability true? card [ab ability]))] - (when-not cannot-play - (do-play-ability state side card ab ability targets)))) + ([state side args] (play-ability state side nil args)) + ([state side eid {:keys [card] ability-idx :ability :as args}] + (let [card (get-card state card) + ability (nth (:abilities card) ability-idx) + cannot-play (or (:disabled card) + (any-effects state side :prevent-paid-ability true? card [ability ability-idx]))] + (when-not cannot-play + (do-play-ability state side eid (assoc args :ability-idx ability-idx :ability ability)))))) (defn expend-ability "Called when the player clicks a card from hand." @@ -67,19 +78,25 @@ (when-let [card (get-card state card)] (case (:type card) ("Event" "Operation") - (play-ability state side {:card (get-in @state [side :basic-action-card]) :ability 3 :targets [card]}) + (play-ability state side {:card (get-in @state [side :basic-action-card]) + :ability 3 + :targets [card]}) ("Hardware" "Resource" "Program" "ICE" "Upgrade" "Asset" "Agenda") - (play-ability state side {:card (get-in @state [side :basic-action-card]) :ability 2 :targets [card server]})))) + (play-ability state side {:card (get-in @state [side :basic-action-card]) + :ability 2 + :targets [card server]})))) (defn click-draw "Click to draw." [state side _] - (play-ability state side {:card (get-in @state [side :basic-action-card]) :ability 1})) + (play-ability state side {:card (get-in @state [side :basic-action-card]) + :ability 1})) (defn click-credit "Click to gain 1 credit." [state side _] - (play-ability state side {:card (get-in @state [side :basic-action-card]) :ability 0})) + (play-ability state side {:card (get-in @state [side :basic-action-card]) + :ability 0})) (defn move-card "Called when the user drags a card from one zone to another." @@ -464,25 +481,27 @@ (defn play-corp-ability "Triggers a runner card's corp-ability using its zero-based index into the card's card-def :corp-abilities vector." - [state side {:keys [card ability targets]}] - (let [card (get-card state card) - cdef (card-def card) - ab (get-in cdef [:corp-abilities ability]) - cannot-play (or (:disabled card) - (any-effects state side :prevent-paid-ability true? card [ab ability]))] - (when-not cannot-play - (do-play-ability state side card ab ability targets)))) + ([state side args] (play-corp-ability state side nil args)) + ([state side eid {:keys [card] ability-idx :ability :as args}] + (let [card (get-card state card) + cdef (card-def card) + ability (get-in cdef [:corp-abilities ability-idx]) + cannot-play (or (:disabled card) + (any-effects state side :prevent-paid-ability true? card [ability ability-idx]))] + (when-not cannot-play + (do-play-ability state side eid (assoc args :ability-idx ability-idx :ability ability)))))) (defn play-runner-ability "Triggers a corp card's runner-ability using its zero-based index into the card's card-def :runner-abilities vector." - [state side {:keys [card ability targets]}] - (let [card (get-card state card) - cdef (card-def card) - ab (get-in cdef [:runner-abilities ability]) - cannot-play (or (:disabled card) - (any-effects state side :prevent-paid-ability true? card [ab ability]))] - (when-not cannot-play - (do-play-ability state side card ab ability targets)))) + ([state side args] (play-runner-ability state side nil args)) + ([state side eid {:keys [card] ability-idx :ability :as args}] + (let [card (get-card state card) + cdef (card-def card) + ability (get-in cdef [:runner-abilities ability-idx]) + cannot-play (or (:disabled card) + (any-effects state side :prevent-paid-ability true? card [ability ability-idx]))] + (when-not cannot-play + (do-play-ability state side eid (assoc args :ability-idx ability-idx :ability ability)))))) (defn play-subroutine "Triggers a card's subroutine using its zero-based index into the card's :subroutines vector." diff --git a/src/clj/game/core/commands.clj b/src/clj/game/core/commands.clj index ceb60a5c52..f30dba25f5 100644 --- a/src/clj/game/core/commands.clj +++ b/src/clj/game/core/commands.clj @@ -179,8 +179,6 @@ (when-let [click-state (peek (:click-states @state))] (when (= (:active-player @state) side) (reset! state (assoc click-state :log (:log @state) :click-states (pop (:click-states @state)) :run nil :history (:history @state))) - (doseq [c (filter #(not (has-subtype? % "Lockdown")) (:play-area (side @state)))] - (move state side c (:previous-zone c) {:suppress-event true})) (system-say state side (str "[!] " (if (= side :corp) "Corp" "Runner") " uses the undo-click command")) (doseq [s [:runner :corp]] (toast state s "Game reset to start of click"))))) diff --git a/src/clj/game/core/cost_fns.clj b/src/clj/game/core/cost_fns.clj index c2b1559722..be2e2d10e3 100644 --- a/src/clj/game/core/cost_fns.clj +++ b/src/clj/game/core/cost_fns.clj @@ -125,12 +125,20 @@ "Returns a list of all costs (printed and additional) required to use a given ability" ([state side ability card] (card-ability-cost state side ability card nil)) ([state side ability card targets] - (merge-costs - [(:cost ability) - (:additional-cost ability) - (get-effects state side :card-ability-additional-cost {:card card - :ability ability - :targets targets})]))) + (let [base-cost [(:cost ability) + (get-effects state side :card-ability-cost + {:card card + :ability ability + :targets targets})] + additional-cost (->> [(:additional-cost ability) + (get-effects state side :card-ability-additional-cost + {:card card + :ability ability + :targets targets})] + (flatten) + ; TODO: uncomment when implementing additional costs + #_(keep #(when % (assoc % :cost/additional true))))] + (merge-costs (into base-cost additional-cost))))) (defn break-sub-ability-cost ([state side ability card] (break-sub-ability-cost state side ability card nil)) diff --git a/src/clj/game/core/costs.clj b/src/clj/game/core/costs.clj index 17352ed0d0..755db92f08 100644 --- a/src/clj/game/core/costs.clj +++ b/src/clj/game/core/costs.clj @@ -34,9 +34,6 @@ (defmethod handler :click [cost state side eid _card] (let [a (:action eid)] - (when (not (#{:steal-cost} a)) - (swap! state update :click-states (fn [click-states] - (vec (take-last 4 (conj click-states (dissoc @state :log :history))))))) (swap! state update-in [:stats side :lose :click] (fnil + 0) (value cost)) (deduct state side [:click (value cost)]) (wait-for (trigger-event-sync state side (make-eid state eid) diff --git a/src/clj/game/core/payment.clj b/src/clj/game/core/payment.clj index 97a52b1abd..114e5d5c45 100644 --- a/src/clj/game/core/payment.clj +++ b/src/clj/game/core/payment.clj @@ -69,7 +69,7 @@ "Combines disparate costs into a single cost per type." ([costs] (merge-costs costs false)) ([costs remove-zero-credit-cost] - (let [costs (flatten [costs]) + (let [costs (filterv some? (flatten [costs])) {real false additional true} (group-by :cost/additional costs) real (group-costs real) additional (group-costs additional)] diff --git a/test/clj/game/cards/hardware_test.clj b/test/clj/game/cards/hardware_test.clj index 77c168aa84..f860b7d33c 100644 --- a/test/clj/game/cards/hardware_test.clj +++ b/test/clj/game/cards/hardware_test.clj @@ -1537,6 +1537,25 @@ (run-on state "Archives") (is (= 2 (count (:hand (get-runner)))) "No cards drawn"))) +(deftest deep-red + ;; Deep Red + (do-game + (new-game {:corp {:deck [(qty "Hedge Fund" 10)] + :hand ["Ice Wall"] + :credits 100} + :runner {:hand ["Deep Red" "Rook"] + :credit 100}}) + (play-from-hand state :corp "Ice Wall" "R&D") + (rez state :corp (get-ice state :rd 0)) + (take-credits state :corp) + (play-from-hand state :runner "Deep Red") + (is (changed? [(:click (get-runner)) -1] + (play-from-hand state :runner "Rook") + (click-prompt state :runner "Yes") + (click-card state :runner "Ice Wall")) + "Only spend 1 click") + (is (= ["Rook"] (map get-title (:hosted (get-ice state :rd 0))))))) + (deftest demolisher ;; Demolisher (do-game @@ -4542,7 +4561,7 @@ (card-ability state :runner (get-hardware state 0) 0) ;; Issue #4889 (is (= "Choose 1 installed program to trash" (:msg (prompt-map :runner))) - "Runner chooses program to trash as a cost") + "Runner chooses program to trash as a cost") (click-card state :runner "Corroder")) "Corroder is installed for free") (is (= "Choose a target for Simulchip" (:msg (prompt-map :runner))) diff --git a/test/clj/game/core/actions_test.clj b/test/clj/game/core/actions_test.clj index fbb6fdc767..d5ddf28dfd 100644 --- a/test/clj/game/core/actions_test.clj +++ b/test/clj/game/core/actions_test.clj @@ -46,23 +46,30 @@ (deftest undo-click-return-card-from-play-area (do-game - (new-game {:corp {:deck ["Predictive Planogram"]} - :runner {:deck ["Dirty Laundry"]}}) + (new-game {:corp {:deck [(qty "Hedge Fund" 5)] + :hand ["Predictive Planogram"]} + :runner {:hand ["Sure Gamble" "Dirty Laundry" "Day Job"]}}) (play-from-hand state :corp "Predictive Planogram") (core/command-undo-click state :corp) (is (= 0 (count (:play-area (get-corp)))) "Corp play area is empty") (is (= 1 (count (:hand (get-corp)))) "Corp has 1 card in HQ") (take-credits state :corp) + (is (= ["Sure Gamble" "Dirty Laundry" "Day Job"] (map :title (:hand (get-runner))))) (play-from-hand state :runner "Dirty Laundry") (core/command-undo-click state :runner) (is (= 0 (count (:play-area (get-runner)))) "Runner play area is empty") - (is (= 1 (count (:hand (get-runner)))) "Player has 1 card in grip"))) + (is (= 3 (count (:hand (get-runner)))) "Player has 1 card in grip") + (is (= ["Sure Gamble" "Dirty Laundry" "Day Job"] (map :title (:hand (get-runner))))))) (deftest undo-click-does-not-return-lockdown-from-play-area (do-game (new-game {:corp {:deck ["NAPD Cordon" "Predictive Planogram"]} :runner {:deck ["Dirty Laundry"]}}) (play-from-hand state :corp "NAPD Cordon") + (core/command-undo-click state :corp) + (is (= 0 (count (:play-area (get-corp)))) "NAPD Cordon has returned to HQ") + (is (= 2 (count (:hand (get-corp))))) + (play-from-hand state :corp "NAPD Cordon") (play-from-hand state :corp "Predictive Planogram") (core/command-undo-click state :corp) (is (= 1 (count (:play-area (get-corp)))) "Corp play area still has NAPD Cordon") From e23170709687cff4f30c9b4ec260afbd4fb3d592 Mon Sep 17 00:00:00 2001 From: Noah Bogart Date: Thu, 4 Apr 2024 09:58:15 -0400 Subject: [PATCH 2/2] Fix log string escapes --- test/clj/game/cards/hardware_test.clj | 2 +- test/clj/game/cards/ice_test.clj | 14 ++++----- test/clj/game/cards/identities_test.clj | 6 ++-- test/clj/game/cards/programs_test.clj | 14 ++++----- test/clj/game/cards/resources_test.clj | 30 +++++++++---------- test/clj/game/cards/upgrades_test.clj | 4 +-- test/clj/game/core/actions_test.clj | 4 +-- test/clj/game/core/costs_test.clj | 38 ++++++++++++------------- test/clj/game/core/say_test.clj | 2 +- test/clj/game/test_framework.clj | 3 +- 10 files changed, 58 insertions(+), 59 deletions(-) diff --git a/test/clj/game/cards/hardware_test.clj b/test/clj/game/cards/hardware_test.clj index f860b7d33c..131106629a 100644 --- a/test/clj/game/cards/hardware_test.clj +++ b/test/clj/game/cards/hardware_test.clj @@ -3973,7 +3973,7 @@ (take-credits state :corp) (play-from-hand state :runner "Prognostic Q-Loop") (card-ability state :runner (get-hardware state 0) 1) - (is (last-log-contains? state "Runner spends \\[Click] and pays 1 \\[Credits] to install Prognostic Q-Loop.") + (is (last-log-contains? state "Runner spends [Click] and pays 1 [Credits] to install Prognostic Q-Loop.") "Shouldn't print anything to log as the stack is empty"))) (deftest prognostic-q-loop-orders-correctly-with-other-on-run-triggers-when-firing-first-issue-4973 diff --git a/test/clj/game/cards/ice_test.clj b/test/clj/game/cards/ice_test.clj index 32bf658c32..d38c5ebdd5 100644 --- a/test/clj/game/cards/ice_test.clj +++ b/test/clj/game/cards/ice_test.clj @@ -823,7 +823,7 @@ (is (changed? [(:credit (get-corp)) +1] (card-ability state :runner cor 0) (click-prompt state :runner "End the run") - (is (last-log-contains? state "Corp uses Bailiff to gain 1 \\[Credits\\]") + (is (last-log-contains? state "Corp uses Bailiff to gain 1 [Credits]") "Correct message")) "Gained 1c from subroutines being broken")))) @@ -902,8 +902,8 @@ (is (changed? [(:credit (get-corp)) +2] (auto-pump-and-break state cor)) "Gained 2c from the runner breaking") - (is (last-n-log-contains? state 2 "Corp uses Bailiff to gain 1 \\[Credits\\]")) - (is (last-n-log-contains? state 3 "Corp uses Bailiff to gain 1 \\[Credits\\]")))))) + (is (last-n-log-contains? state 2 "Corp uses Bailiff to gain 1 [Credits]")) + (is (last-n-log-contains? state 3 "Corp uses Bailiff to gain 1 [Credits]")))))) (deftest ballista ;; Ballista @@ -2874,7 +2874,7 @@ (card-ability state :runner cor 0) (click-prompt state :runner "End the run unless the Runner pays 3 [Credits]") (click-prompt state :runner "Done") - (is (last-log-contains? state "Corp uses Gold Farmer to force the runner to lose 1 \\[Credits\\] for breaking printed subs") + (is (last-log-contains? state "Corp uses Gold Farmer to force the runner to lose 1 [Credits] for breaking printed subs") "Correct message")) "Paid 1c + 1c for breaking")))) @@ -2894,9 +2894,9 @@ (run-continue state) (is (changed? [(:credit (get-runner)) -4] (auto-pump-and-break state cor) - (is (last-n-log-contains? state 2 "Corp uses Gold Farmer to force the runner to lose 1 \\[Credits\\] for breaking printed subs") + (is (last-n-log-contains? state 2 "Corp uses Gold Farmer to force the runner to lose 1 [Credits] for breaking printed subs") "Correct messages") - (is (last-n-log-contains? state 3 "Corp uses Gold Farmer to force the runner to lose 1 \\[Credits\\] for breaking printed subs"))) + (is (last-n-log-contains? state 3 "Corp uses Gold Farmer to force the runner to lose 1 [Credits] for breaking printed subs"))) "Paid 2c + 2c for breaking")))) (deftest gold-farmer-interaction-with-paperclip @@ -6572,7 +6572,7 @@ (card-subroutine state :corp shiro 1) (let [credits (:credit (get-corp))] (click-prompt state :corp "Yes") - (is (last-log-contains? state "pays 1 \\[Credits\\]") "Payment is logged") + (is (last-log-contains? state "pays 1 [Credits]") "Payment is logged") (is (last-log-contains? state "keep the Runner from breaching R&D") "Prevention is logged") (is (= (dec credits) (:credit (get-corp))) "Corp pays 1 to prevent access")))))) diff --git a/test/clj/game/cards/identities_test.clj b/test/clj/game/cards/identities_test.clj index a03e9e1b52..332c310c9b 100644 --- a/test/clj/game/cards/identities_test.clj +++ b/test/clj/game/cards/identities_test.clj @@ -1011,7 +1011,7 @@ (is (changed? [(:credit (get-runner)) -1] (run-on state :hq)) "Paid 1c to run on HQ") - (is (last-log-contains? state "spends \\[Click\\] and pays 1 \\[Credits\\] to make a run on HQ") "Should have correct log with credits price for the run"))) + (is (last-log-contains? state "spends [Click] and pays 1 [Credits] to make a run on HQ") "Should have correct log with credits price for the run"))) (deftest earth-station-sea-headquarters-front-side-flipping-costs-1-click ;; Flipping costs 1 click @@ -1021,7 +1021,7 @@ (card-ability state :corp (get-in @state [:corp :identity]) 0)) "Paid 1 click to flip Earth Station") (is (:flipped (get-in @state [:corp :identity])) "Earth Station is on flip side") - (is (last-log-contains? state "Corp spends \\[Click\\] to use Earth Station: SEA Headquarters to flip their identity to Earth Station: Ascending to Orbit.") "Should have correct log with click price"))) + (is (last-log-contains? state "Corp spends [Click] to use Earth Station: SEA Headquarters to flip their identity to Earth Station: Ascending to Orbit.") "Should have correct log with click price"))) (deftest earth-station-sea-headquarters-flip-side-no-additional-cost-to-run-hq ;; No additional cost to run HQ @@ -1056,7 +1056,7 @@ (is (changed? [(:credit (get-runner)) -6] (run-on state :remote1)) "Paid 6c to run on remote server") - (is (last-log-contains? state "spends \\[Click\\] and pays 6 \\[Credits\\] to make a run on Server 1") "Should have correct log with credits price for the run"))) + (is (last-log-contains? state "spends [Click] and pays 6 [Credits] to make a run on Server 1") "Should have correct log with credits price for the run"))) (deftest earth-station-sea-headquarters-flip-side-flip-back-on-successful-hq-run ;; Flip back on successful HQ run diff --git a/test/clj/game/cards/programs_test.clj b/test/clj/game/cards/programs_test.clj index bdcab72357..23466313ca 100644 --- a/test/clj/game/cards/programs_test.clj +++ b/test/clj/game/cards/programs_test.clj @@ -1167,7 +1167,7 @@ (click-prompt state :runner "Yes") (click-prompt state :runner "3")) "Runner uses Bug") - (is (last-log-contains? state "Runner pays 6 \\[Credits] to use Bug to force the Corp to reveal they drew Hedge Fund, Hedge Fund, and Hedge Fund.")))) + (is (last-log-contains? state "Runner pays 6 [Credits] to use Bug to force the Corp to reveal they drew Hedge Fund, Hedge Fund, and Hedge Fund.")))) (deftest buzzsaw ;; Buzzsaw @@ -2882,7 +2882,7 @@ (rez state :corp (get-ice state :hq 0)) (run-continue state) (auto-pump-and-break state (get-program state 0)) - (is (second-last-log-contains? state "Runner pays 0 \\[Credits\\] to use Euler to break all 2 subroutines on Enigma.") "Correct log with correct cost") + (is (second-last-log-contains? state "Runner pays 0 [Credits] to use Euler to break all 2 subroutines on Enigma.") "Correct log with correct cost") (core/continue state :corp nil) (run-jack-out state) (take-credits state :runner) @@ -2890,7 +2890,7 @@ (run-on state :hq) (run-continue state) (auto-pump-and-break state (get-program state 0)) - (is (second-last-log-contains? state "Runner pays 2 \\[Credits\\] to use Euler to break all 2 subroutines on Enigma.") "Correct second log with correct cost") + (is (second-last-log-contains? state "Runner pays 2 [Credits] to use Euler to break all 2 subroutines on Enigma.") "Correct second log with correct cost") (core/continue state :corp nil))) (deftest expert-schedule-analyzer @@ -4760,14 +4760,14 @@ (run-on state "HQ") (run-continue state) (auto-pump-and-break state (refresh maven)) - (is (second-last-log-contains? state "Runner pays 4 \\[Credits\\] to use Maven to break all 2 subroutines on Border Control.") "Correct log with autopump ability") + (is (second-last-log-contains? state "Runner pays 4 [Credits] to use Maven to break all 2 subroutines on Border Control.") "Correct log with autopump ability") (core/continue state :corp nil) (run-jack-out state) (run-on state "HQ") (run-continue state) (card-ability state :runner (refresh maven) 0) (click-prompt state :runner "End the run") - (is (last-log-contains? state "Runner pays 2 \\[Credits\\] to use Maven to break 1 subroutine on Border Control.") "Correct log with single sub break")))) + (is (last-log-contains? state "Runner pays 2 [Credits] to use Maven to break 1 subroutine on Border Control.") "Correct log with single sub break")))) (deftest mayfly ;; Mayfly @@ -4827,7 +4827,7 @@ (run-on state "HQ") (run-continue state) (auto-pump-and-break state (refresh mimic)) - (is (second-last-log-contains? state "Runner pays 2 \\[Credits\\] to use Mimic to break all 2 subroutines on Pup") "Correct log with autopump ability") + (is (second-last-log-contains? state "Runner pays 2 [Credits] to use Mimic to break all 2 subroutines on Pup") "Correct log with autopump ability") (core/continue state :corp nil) (run-jack-out state) (is (zero? (:credit (get-runner))) "Runner spent 2 credits to break Pup") @@ -4869,7 +4869,7 @@ (run-continue state) (is (= 2 (count (:abilities (refresh mimic)))) "Auto pump and break ability on Mimic is available") (auto-pump-and-break state (refresh mimic)) - (is (second-last-log-contains? state "Runner pays 3 \\[Credits\\] to use Mimic to break all 3 subroutines on Zed 2.0") "Correct log with autopump ability") + (is (second-last-log-contains? state "Runner pays 3 [Credits] to use Mimic to break all 3 subroutines on Zed 2.0") "Correct log with autopump ability") (core/continue state :corp nil) (run-jack-out state) (is (= 1 (:credit (get-runner))) "Runner spent 3 credits to break Zed 2.0")))) diff --git a/test/clj/game/cards/resources_test.clj b/test/clj/game/cards/resources_test.clj index 5c5a5544fd..6a0cd418b6 100644 --- a/test/clj/game/cards/resources_test.clj +++ b/test/clj/game/cards/resources_test.clj @@ -1379,10 +1379,10 @@ (take-credits state :corp) (play-from-hand state :runner "Dadiana Chacon") (play-from-hand state :runner "Corroder") - (is (last-n-log-contains? state 3 "Runner spends \\[Click\\] and pays 0 \\[Credits\\] to install Dadiana Chacon.")) + (is (last-n-log-contains? state 3 "Runner spends [Click] and pays 0 [Credits] to install Dadiana Chacon.")) (is (last-n-log-contains? state 2 "Runner uses Dadiana Chacon to suffer 3 meat damage.")) (is (second-last-log-contains? state "Runner trashes Corroder, Corroder, and Corroder due to meat damage.")) - (is (last-log-contains? state "Runner spends \\[Click\\] and pays 2 \\[Credits\\] to install Corroder.")))) + (is (last-log-contains? state "Runner spends [Click] and pays 2 [Credits] to install Corroder.")))) (deftest daeg-first-net-cat ;; Daeg, First Net-Cat - charge on score/steal @@ -3874,7 +3874,7 @@ (is (zero? (:click (get-runner))) "Should now have 0 clicks") (is (= 1 (count (:discard (get-runner)))) "Logic Bomb should be discarded") (is (last-log-contains? state "use Logic Bomb")) - (is (last-log-contains? state "\\[Click\\]\\[Click\\]") "Log should mention 2 clicks"))) + (is (last-log-contains? state "[Click][Click]") "Log should mention 2 clicks"))) (deftest logic-bomb-if-the-runner-has-no-clicks-left ;; if the runner has no clicks left @@ -3894,7 +3894,7 @@ (is (zero? (:click (get-runner))) "Should still have 0 clicks") (is (= 1 (count (:discard (get-runner)))) "Logic Bomb should be discarded") (is (last-log-contains? state "use Logic Bomb")) - (is (not (last-log-contains? state "\\[Click\\]")) "Log shouldn't mention any clicks"))) + (is (not (last-log-contains? state "[Click]")) "Log shouldn't mention any clicks"))) (deftest london-library ;; Install non-virus programs on London library. Includes #325/409 @@ -4520,7 +4520,7 @@ (is (changed? [(:credit (get-runner)) -1] (play-from-hand state :runner "Order of Sol")) "Only spends 1 credit total to install Order of Sol") - (is (last-log-contains? state "Runner uses Order of Sol to gain 1 \\[Credits].")))) + (is (last-log-contains? state "Runner uses Order of Sol to gain 1 [Credits].")))) (deftest order-of-sol-get-down-to-zero-credits-from-playing-an-event ;; Get down to zero credits from playing an event @@ -4532,7 +4532,7 @@ (is (changed? [(:credit (get-runner)) 5] (play-from-hand state :runner "Sure Gamble")) "Gain 5 total credits from playing Sure Gamble") - (is (last-n-log-contains? state 2 "Runner uses Order of Sol to gain 1 \\[Credits].")))) + (is (last-n-log-contains? state 2 "Runner uses Order of Sol to gain 1 [Credits].")))) (deftest order-of-sol-losing-credits ;; Losing credits @@ -4548,7 +4548,7 @@ (is (changed? [(:credit (get-runner)) 0] (rez state :corp (get-content state :remote1 0))) "Gain and lose 1 credit") - (is (last-log-contains? state "Runner uses Order of Sol to gain 1 \\[Credits].")))) + (is (last-log-contains? state "Runner uses Order of Sol to gain 1 [Credits].")))) (deftest pad-tap ;; PAD Tap @@ -4822,21 +4822,21 @@ (is (changed? [(:credit (get-runner)) -4] (click-card state :runner mo)) "Pay 4 for MOpus install (1+5-2)") - (is (second-last-log-contains? state "Runner pays 1 \\[Credits\\] to use Paule's Café to install hosted card\\.") "Correct message for Paule usage") - (is (last-log-contains? state "Runner pays 3 \\[Credits\\] to install Magnum Opus using Paule's Café\\.") "Correct message for MOpus install") + (is (second-last-log-contains? state "Runner pays 1 [Credits] to use Paule's Café to install hosted card\\.") "Correct message for Paule usage") + (is (last-log-contains? state "Runner pays 3 [Credits] to install Magnum Opus using Paule's Café\\.") "Correct message for MOpus install") (card-ability state :runner pau 1) (is (changed? [(:credit (get-runner)) -4] (click-card state :runner des)) "Pay 4 for Desperado install (1+3)") - (is (second-last-log-contains? state "Runner pays 1 \\[Credits\\] to use Paule's Café to install hosted card\\.") "Correct message for Paule usage") - (is (last-log-contains? state "Runner pays 3 \\[Credits\\] to install Desperado using Paule's Café\\.") "Correct message for Desperado install") + (is (second-last-log-contains? state "Runner pays 1 [Credits] to use Paule's Café to install hosted card\\.") "Correct message for Paule usage") + (is (last-log-contains? state "Runner pays 3 [Credits] to install Desperado using Paule's Café\\.") "Correct message for Desperado install") (take-credits state :runner) (card-ability state :runner pau 1) (is (changed? [(:credit (get-runner)) -3] (click-card state :runner cor)) "Pay 3 for Corroder install in Corp turn (1+2)") - (is (second-last-log-contains? state "Runner pays 1 \\[Credits\\] to use Paule's Café to install hosted card\\.") "Correct message for Paule usage") - (is (last-log-contains? state "Runner pays 2 \\[Credits\\] to install Corroder using Paule's Café\\.") "Correct message for Corroder install"))))) + (is (second-last-log-contains? state "Runner pays 1 [Credits] to use Paule's Café to install hosted card\\.") "Correct message for Paule usage") + (is (last-log-contains? state "Runner pays 2 [Credits] to install Corroder using Paule's Café\\.") "Correct message for Corroder install"))))) (deftest paule-s-cafe-can-t-lower-cost-below-1-issue-4816 ;; Can't lower cost below 1. Issue #4816 @@ -4858,8 +4858,8 @@ (card-ability state :runner pau 1) (click-card state :runner cor)) "Pay 1 credit for Corroder (2 - 4 + 1 base)") - (is (second-last-log-contains? state "Runner pays 1 \\[Credits\\] to use Paule's Café to install hosted card\\.") "Correct message for Paule usage") - (is (last-log-contains? state "Runner pays 0 \\[Credits\\] to install Corroder using Paule's Café\\.") "Correct message for Corroder install"))))) + (is (second-last-log-contains? state "Runner pays 1 [Credits] to use Paule's Café to install hosted card\\.") "Correct message for Paule usage") + (is (last-log-contains? state "Runner pays 0 [Credits] to install Corroder using Paule's Café\\.") "Correct message for Corroder install"))))) (deftest penumbral-toolkit-install-cost-reduction-after-hq-run ;; install cost reduction after HQ run diff --git a/test/clj/game/cards/upgrades_test.clj b/test/clj/game/cards/upgrades_test.clj index 44e9f27adb..5190107bd7 100644 --- a/test/clj/game/cards/upgrades_test.clj +++ b/test/clj/game/cards/upgrades_test.clj @@ -1024,8 +1024,8 @@ (take-credits state :corp) (play-from-hand state :runner "Dirty Laundry") (click-prompt state :runner "HQ") - (is (second-last-log-contains? state "Runner spends \\[Click\\] and pays 2 \\[Credits\\] to play Dirty Laundry.")) - (is (last-log-contains? state "Runner spends \\[Click\\] and pays 1 \\[Credits\\] to make a run on HQ.")))) + (is (second-last-log-contains? state "Runner spends [Click] and pays 2 [Credits] to play Dirty Laundry.")) + (is (last-log-contains? state "Runner spends [Click] and pays 1 [Credits] to make a run on HQ.")))) (deftest corporate-troubleshooter ;; Corporate Troubleshooter - Pay X credits and trash to add X strength to a piece of rezzed ice diff --git a/test/clj/game/core/actions_test.clj b/test/clj/game/core/actions_test.clj index d5ddf28dfd..001f1bf6ee 100644 --- a/test/clj/game/core/actions_test.clj +++ b/test/clj/game/core/actions_test.clj @@ -87,9 +87,9 @@ (run-continue state) (card-side-ability state :runner ice 0) (click-prompt state :runner "End the run") - (is (last-log-contains? state "Runner loses \\[Click\\] to use Eli 1.0 to break 1 subroutine on Eli 1.0")) + (is (last-log-contains? state "Runner loses [Click] to use Eli 1.0 to break 1 subroutine on Eli 1.0")) (click-prompt state :runner "End the run") - (is (last-log-contains? state "Runner loses \\[Click\\] to use Eli 1.0 to break 1 subroutine on Eli 1.0"))) + (is (last-log-contains? state "Runner loses [Click] to use Eli 1.0 to break 1 subroutine on Eli 1.0"))) (run-continue state) (run-continue state) (click-prompt state :runner "No action") diff --git a/test/clj/game/core/costs_test.clj b/test/clj/game/core/costs_test.clj index 36ed85f1f2..9ab21eb258 100644 --- a/test/clj/game/core/costs_test.clj +++ b/test/clj/game/core/costs_test.clj @@ -52,37 +52,37 @@ :corp {:hand [(qty "Ice Wall" 2) "Turtlebacks" "Beanstalk Royalties" "Hedge Fund" "Project Beale" "Ben Musashi"]}}) (core/gain state :corp :click 10) (play-from-hand state :corp "Ice Wall" "HQ") - (is (last-log-contains? state "Corp spends \\[Click\\] and pays 0 \\[Credits\\] to install ice protecting HQ.") "Install ice, zero cost") + (is (last-log-contains? state "Corp spends [Click] and pays 0 [Credits] to install ice protecting HQ.") "Install ice, zero cost") (play-from-hand state :corp "Ice Wall" "HQ") - (is (last-log-contains? state "Corp spends \\[Click\\] and pays 1 \\[Credits\\] to install ice protecting HQ.") "Install ice, one cost") + (is (last-log-contains? state "Corp spends [Click] and pays 1 [Credits] to install ice protecting HQ.") "Install ice, one cost") (play-from-hand state :corp "Turtlebacks" "New remote") - (is (last-log-contains? state "Corp spends \\[Click\\] to install a card in Server 1.") "Install asset, zero cost") + (is (last-log-contains? state "Corp spends [Click] to install a card in Server 1.") "Install asset, zero cost") (play-from-hand state :corp "Ben Musashi" "Server 1") - (is (last-log-contains? state "Corp spends \\[Click\\] to install a card in Server 1.") "Install upgrade, zero cost") + (is (last-log-contains? state "Corp spends [Click] to install a card in Server 1.") "Install upgrade, zero cost") (play-from-hand state :corp "Project Beale" "New remote") - (is (last-log-contains? state "Corp spends \\[Click\\] to install a card in Server 2.") "Install agenda, zero cost") + (is (last-log-contains? state "Corp spends [Click] to install a card in Server 2.") "Install agenda, zero cost") (play-from-hand state :corp "Beanstalk Royalties") - (is (second-last-log-contains? state "Corp spends \\[Click\\] and pays 0 \\[Credits\\] to play Beanstalk Royalties.") "Play operation, zero cost") + (is (second-last-log-contains? state "Corp spends [Click] and pays 0 [Credits] to play Beanstalk Royalties.") "Play operation, zero cost") (play-from-hand state :corp "Hedge Fund") - (is (second-last-log-contains? state "Corp spends \\[Click\\] and pays 5 \\[Credits\\] to play Hedge Fund.") "Play operation, five cost") + (is (second-last-log-contains? state "Corp spends [Click] and pays 5 [Credits] to play Hedge Fund.") "Play operation, five cost") (take-credits state :corp) (core/gain state :runner :click 10) (play-from-hand state :runner "Diesel") - (is (second-last-log-contains? state "Runner spends \\[Click\\] and pays 0 \\[Credits\\] to play Diesel.") "Play event, zero cost") + (is (second-last-log-contains? state "Runner spends [Click] and pays 0 [Credits] to play Diesel.") "Play event, zero cost") (play-from-hand state :runner "Sure Gamble") - (is (second-last-log-contains? state "Runner spends \\[Click\\] and pays 5 \\[Credits\\] to play Sure Gamble.") "Play event, five cost") + (is (second-last-log-contains? state "Runner spends [Click] and pays 5 [Credits] to play Sure Gamble.") "Play event, five cost") (play-from-hand state :runner "Clot") - (is (last-log-contains? state "Runner spends \\[Click\\] and pays 2 \\[Credits\\] to install Clot.") "Install program, two cost") + (is (last-log-contains? state "Runner spends [Click] and pays 2 [Credits] to install Clot.") "Install program, two cost") (play-from-hand state :runner "Misdirection") - (is (last-log-contains? state "Runner spends \\[Click\\] and pays 0 \\[Credits\\] to install Misdirection.") "Install program, zero cost") + (is (last-log-contains? state "Runner spends [Click] and pays 0 [Credits] to install Misdirection.") "Install program, zero cost") (play-from-hand state :runner "Career Fair") - (is (last-log-contains? state "Runner spends \\[Click\\] and pays 0 \\[Credits\\] to play Career Fair.") "Play Career Fair, zero cost") + (is (last-log-contains? state "Runner spends [Click] and pays 0 [Credits] to play Career Fair.") "Play Career Fair, zero cost") (click-card state :runner (find-card "Daily Casts" (:hand (get-runner)))) - (is (last-log-contains? state "Runner pays 0 \\[Credits\\] to install Daily Casts.") "Choose Daily cast, zero cost install") + (is (last-log-contains? state "Runner pays 0 [Credits] to install Daily Casts.") "Choose Daily cast, zero cost install") (play-from-hand state :runner "Daily Casts") - (is (last-log-contains? state "Runner spends \\[Click\\] and pays 3 \\[Credits\\] to install Daily Casts.") "Install resource, three cost") + (is (last-log-contains? state "Runner spends [Click] and pays 3 [Credits] to install Daily Casts.") "Install resource, three cost") (run-on state :archives) - (is (last-log-contains? state "Runner spends \\[Click\\] to make a run on Archives.") "Initiate run, zero cost"))) + (is (last-log-contains? state "Runner spends [Click] to make a run on Archives.") "Initiate run, zero cost"))) (testing "Issue #4295: Auto-pumping Icebreaker with pay-credits prompt" (do-game (new-game {:runner {:hand ["Corroder" "Net Mercur" "Cloak"]} @@ -122,7 +122,7 @@ (auto-pump-and-break state (refresh cor)) (is (= 3 (get-strength (refresh cor))) "Corroder now at 3 strength") (is (empty? (remove :broken (:subroutines (refresh hive)))) "Hive is now fully broken") - (is (second-last-log-contains? state "Runner pays 6 \\[Credits\\] to increase the strength of Corroder to 3 and break all 5 subroutines on Hive.") "Should write correct pump & break price to log")))) + (is (second-last-log-contains? state "Runner pays 6 [Credits] to increase the strength of Corroder to 3 and break all 5 subroutines on Hive.") "Should write correct pump & break price to log")))) (testing "Auto-pump first" (do-game (new-game {:runner {:hand ["Corroder"]} @@ -138,10 +138,10 @@ (run-continue state) (auto-pump state (refresh cor)) (is (= 3 (get-strength (refresh cor))) "Corroder now at 3 strength") - (is (last-log-contains? state "Runner pays 1 \\[Credits\\] to increase the strength of Corroder to 3.") "Should write correct pump price to log") + (is (last-log-contains? state "Runner pays 1 [Credits] to increase the strength of Corroder to 3.") "Should write correct pump price to log") (auto-pump-and-break state (refresh cor)) (is (empty? (remove :broken (:subroutines (refresh hive)))) "Hive is now fully broken") - (is (second-last-log-contains? state "Runner pays 5 \\[Credits\\] to use Corroder to break all 5 subroutines on Hive.") "Should write correct break price to log")))) + (is (second-last-log-contains? state "Runner pays 5 [Credits] to use Corroder to break all 5 subroutines on Hive.") "Should write correct break price to log")))) (testing "Inability to pay for auto-pump" (do-game (new-game {:runner {:hand ["Corroder"]} @@ -202,7 +202,7 @@ (is (= 4 (count (remove :broken (:subroutines (refresh hive))))) "Only broken 1 sub") (auto-pump-and-break state (refresh cor)) (is (empty? (remove :broken (:subroutines (refresh hive)))) "Hive is now fully broken") - (is (second-last-log-contains? state "Runner pays 4 \\[Credits\\] to use Corroder to break the remaining 4 subroutines on Hive.") "Should write correct price to log"))))) + (is (second-last-log-contains? state "Runner pays 4 [Credits] to use Corroder to break the remaining 4 subroutines on Hive.") "Should write correct price to log"))))) (deftest run-additional-costs (testing "If runner cannot pay additional cost, server not shown as an option for run events or click to run button" diff --git a/test/clj/game/core/say_test.clj b/test/clj/game/core/say_test.clj index 9d2fe01eec..cce9925b1b 100644 --- a/test/clj/game/core/say_test.clj +++ b/test/clj/game/core/say_test.clj @@ -298,7 +298,7 @@ (play-from-hand state :runner "Wireless Net Pavilion") (let [wnp1 (get-resource state 0)] (core/command-parser state :runner {:user user :text "/unique"}) - (is (last-log-contains? state "\\[!\\]Runner uses a command: /unique") "Correct message") + (is (last-log-contains? state "[!]Runner uses a command: /unique") "Correct message") (click-card state :runner wnp1) (is (not (unique? (refresh wnp1))) "WNP is not unique anymore") (is (last-log-contains? state "Runner uses /unique command to make Wireless Net Pavilion not unique\\.") "Correct message") diff --git a/test/clj/game/test_framework.clj b/test/clj/game/test_framework.clj index 11e4c728ae..37559246af 100644 --- a/test/clj/game/test_framework.clj +++ b/test/clj/game/test_framework.clj @@ -903,8 +903,7 @@ `(do ~@bundles))) (defn escape-log-string [s] - ; (str/escape s {\[ "\\[" \] "\\]"}) - s) + (str/escape s {\[ "\\[" \] "\\]"})) (defn last-log-contains? [state content]