Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use stringer/strcat instead of str for all of our string composition #7730

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
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
1 change: 1 addition & 0 deletions project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
[org.clojure/data.csv "1.0.0"]
[dev.weavejester/medley "1.8.0"]
[org.slf4j/slf4j-nop "1.7.32"]
[stringer "0.4.1"]
[integrant "0.8.0"]
[cljc.java-time "0.1.18"]
[time-literals "0.1.5"]
Expand Down
114 changes: 57 additions & 57 deletions src/clj/game/cards/agendas.clj

Large diffs are not rendered by default.

97 changes: 49 additions & 48 deletions src/clj/game/cards/assets.clj

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions src/clj/game/cards/basic.clj
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
[game.core.to-string :refer [card-str]]
[game.macros :refer [effect msg req wait-for]]
[game.utils :refer :all]
[jinteki.utils :refer :all]))
[jinteki.utils :refer :all]
[stringer.core :as s]))
;; Card definitions

(defcard "Corp Basic Action Card"
Expand Down Expand Up @@ -130,18 +131,18 @@
(wait-for (resolve-ability
state side
(make-eid state eid)
{:prompt (str "Pay the additional cost to trash " (:title target) "?")
{:prompt (s/strcat "Pay the additional cost to trash " (:title target) "?")
:choices [(when can-pay cost-strs) "No"]
:async true
:effect (req (if (= target "No")
(do (system-msg state side (str "declines to pay the additional cost to trash " (:title target)))
(do (system-msg state side (s/strcat "declines to pay the additional cost to trash " (:title target)))
(effect-completed state side eid))
(wait-for (pay state side (make-eid state
(assoc eid
:additional-costs additional-costs
:source-type :trash-card))
nil additional-costs)
(system-msg state side (str (:msg async-result) " as an additional cost to trash " (:title target)))
(system-msg state side (s/strcat (:msg async-result) " as an additional cost to trash " (:title target)))
(complete-with-result state side eid target))))}
card nil)
(if async-result
Expand Down
183 changes: 92 additions & 91 deletions src/clj/game/cards/events.clj

Large diffs are not rendered by default.

77 changes: 39 additions & 38 deletions src/clj/game/cards/hardware.clj

Large diffs are not rendered by default.

237 changes: 119 additions & 118 deletions src/clj/game/cards/ice.clj

Large diffs are not rendered by default.

107 changes: 54 additions & 53 deletions src/clj/game/cards/identities.clj

Large diffs are not rendered by default.

141 changes: 71 additions & 70 deletions src/clj/game/cards/operations.clj

Large diffs are not rendered by default.

107 changes: 54 additions & 53 deletions src/clj/game/cards/programs.clj

Large diffs are not rendered by default.

147 changes: 74 additions & 73 deletions src/clj/game/cards/resources.clj

Large diffs are not rendered by default.

72 changes: 36 additions & 36 deletions src/clj/game/cards/upgrades.clj

Large diffs are not rendered by default.

41 changes: 21 additions & 20 deletions src/clj/game/core/access.clj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
[jinteki.utils :refer [add-cost-to-label]]
[clojure.set :as clj-set]
[medley.core :refer [find-first]]
[clojure.string :as string]))
[clojure.string :as string]
[stringer.core :as s]))

(defn no-trash-or-steal
[state]
Expand Down Expand Up @@ -61,7 +62,7 @@
access-ability (access-ab card)
ability (add-cost-label-to-ability access-ability (card-ability-cost state :runner access-ability card))
label (add-cost-to-label ability)]
(str "[" title "] " label)))
(s/strcat "[" title "] " label)))

(defn access-non-agenda
"Access a non-agenda. Show a prompt to trash for trashable cards."
Expand Down Expand Up @@ -89,7 +90,7 @@
can-pay (when trash-cost
(can-pay? state :runner trash-eid card nil [(->c :credit trash-cost)]))
trash-cost-str (when can-pay
[(str "Pay " trash-cost " [Credits] to trash")])
[(s/strcat "Pay " trash-cost " [Credits] to trash")])
; Is the runner is forced to trash this card with only credits? (NAT)
must-trash-with-credits? (and can-pay
(get-in @state [:runner :register :must-trash-with-credits]))
Expand Down Expand Up @@ -127,7 +128,7 @@
(continue-ability
state :runner
{:async true
:prompt (str "You accessed " (:title card) ".")
:prompt (s/strcat "You accessed " (:title card) ".")
:choices choices
:effect (req (cond
; Can't or won't trash or use an ability
Expand All @@ -146,7 +147,7 @@
(swap! state assoc-in [:run :did-access] true)))
(swap! state assoc-in [:runner :register :trashed-card] true)
(swap! state assoc-in [:runner :register :trashed-accessed-card] true)
(system-msg state side (str (:msg async-result) " to trash "
(system-msg state side (s/strcat (:msg async-result) " to trash "
(:title card) " from "
(name-zone :corp (get-zone card))))
(wait-for (trash state side card {:accessed true})
Expand Down Expand Up @@ -189,7 +190,7 @@
_ (update-all-agenda-points state)
c (get-card state c)
points (get-agenda-points c)]
(system-msg state :runner (str "steals " (:title c) " and gains " (quantify points "agenda point")))
(system-msg state :runner (s/strcat "steals " (:title c) " and gains " (quantify points "agenda point")))
(swap! state update-in [:runner :register :stole-agenda] #(+ (or % 0) (:agendapoints c 0)))
(play-sfx state side "agenda-steal")
(when (:breach @state)
Expand Down Expand Up @@ -238,9 +239,9 @@
no-action-str (when-not (= steal-str ["Steal"])
["No action"])
prompt-str (if (not (string/blank? cost-strs))
(str " " cost-strs " to steal?")
(s/strcat " " cost-strs " to steal?")
"")
prompt-str (str "You accessed " (:title card) "." prompt-str)
prompt-str (s/strcat "You accessed " (:title card) "." prompt-str)
choices (vec (concat ability-strs steal-str no-action-str))]
;; Steal costs are additional costs and can be denied by the runner.
(continue-ability
Expand All @@ -252,7 +253,7 @@
;; Can't steal or pay, or won't pay additional costs to steal
(= target "No action")
(do (when-not (find-cid (:cid card) (:deck corp))
(system-msg state side (str "decides to not pay to steal " (:title card))))
(system-msg state side (s/strcat "decides to not pay to steal " (:title card))))
(access-end state side eid card))

;; Steal normally
Expand All @@ -268,7 +269,7 @@
:source-type :runner-steal
:action :steal-cost))
nil cost)
(system-msg state side (str (:msg async-result) " to steal "
(system-msg state side (s/strcat (:msg async-result) " to steal "
(:title card) " from "
(name-zone :corp (get-zone card))))
(steal-agenda state side eid card))
Expand Down Expand Up @@ -319,14 +320,14 @@
(let [cost-str (join-cost-strs cost-msg)]
(when-not no-msg
(system-msg state side
(str (if (seq cost-msg)
(str cost-str " to access ")
(s/strcat (if (seq cost-msg)
(s/strcat cost-str " to access ")
"accesses ")
title
(when card
(str " from " (name-zone :corp zone)))))))
(s/strcat " from " (name-zone :corp zone)))))))
(if (reveal-access? state side card)
(do (system-msg state side (str "must reveal they accessed " (:title card)))
(do (system-msg state side (s/strcat "must reveal they accessed " (:title card)))
(reveal state :runner eid card))
(effect-completed state side eid)))

Expand All @@ -342,8 +343,8 @@
([cost ability]
(let [ab (if (pos? cost) (assoc ability :cost [(->c :credit cost)]) ability)
prompt (if (pos? cost)
(req (str "Pay " cost " [Credits] to use " (:title card) " ability?"))
(req (str "Use " (:title card) " ability?")))]
(req (s/strcat "Pay " cost " [Credits] to use " (:title card) " ability?"))
(req (s/strcat "Use " (:title card) " ability?")))]
(installed-access-trigger cost ab prompt)))
([cost ability prompt]
(let [cost (if (number? cost) [(->c :credit cost)] cost)]
Expand Down Expand Up @@ -408,7 +409,7 @@
can-pay (when (not-empty cost)
(can-pay? state side (make-eid state eid) nil nil cost))
prompt-str (if can-pay
(str cost-str " to access this card?")
(s/strcat cost-str " to access this card?")
"You can't pay the cost to access this card.")
choices (if can-pay
["Pay to access" "No action"]
Expand Down Expand Up @@ -828,7 +829,7 @@
(continue-ability
state :corp
{:async true
:prompt (str "Choose a card in HQ for the Runner to access")
:prompt (s/strcat "Choose a card in HQ for the Runner to access")
:waiting-prompt true
:choices {:all true
:card #(and (in-hand? %)
Expand Down Expand Up @@ -1174,7 +1175,7 @@
;; Present the normal options
:else
{:async true
:prompt (str "Choose a card to access. You must access all cards")
:prompt (s/strcat "Choose a card to access. You must access all cards")
:choices choices
:effect (req (cond

Expand Down Expand Up @@ -1339,7 +1340,7 @@
"Starts the breach routines for the run's server."
([state side eid server] (breach-server state side eid server nil))
([state side eid server args]
(system-msg state side (str "breaches " (zone->name server)))
(system-msg state side (s/strcat "breaches " (zone->name server)))
(wait-for (trigger-event-simult state side :breach-server nil (first server))
(swap! state assoc :breach {:breach-server (first server) :from-server (first server)})
(let [args (clean-access-args args)
Expand Down
39 changes: 20 additions & 19 deletions src/clj/game/core/actions.clj
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
[game.core.toasts :refer [toast]]
[game.core.update :refer [update!]]
[game.macros :refer [continue-ability req wait-for]]
[game.utils :refer [dissoc-in quantify remove-once same-card? same-side? server-cards to-keyword]]))
[game.utils :refer [dissoc-in quantify remove-once same-card? same-side? server-cards to-keyword]]
[stringer.core :as s]))

(defn- update-click-state
"Update :click-states to hold latest 4 moments before performing actions."
Expand Down Expand Up @@ -88,7 +89,7 @@
(not= side (to-keyword (:side card)))
(any-effects state side :prevent-paid-ability true? card [ability ability-idx]))]
(when blocking-prompt?
(toast state side (str "You cannot play abilities while other abilities are resolving.")
(toast state side (s/strcat "You cannot play abilities while other abilities are resolving.")
"warning"))
(when-not cannot-play
(do-play-ability state side eid (assoc args :ability-idx ability-idx :ability ability))))))
Expand All @@ -101,7 +102,7 @@
eid (make-eid state {:source card :source-type :ability})
expend-ab (expend (:expend card))]
(resolve-ability state side eid expend-ab card nil))
(toast state side (str "You cannot play abilities while other abilities are resolving.")
(toast state side (s/strcat "You cannot play abilities while other abilities are resolving.")
"warning")))

(defn play
Expand Down Expand Up @@ -150,7 +151,7 @@
(let [move-card-to (partial move state s c)
card-prompts (filter #(same-card? :title % c) (get-in @state [side :prompt]))
log-move (fn [verb & text]
(system-msg state side (str verb " " from-str
(system-msg state side (s/strcat verb " " from-str
(when (seq text)
(apply str " " text)))))]
(case server
Expand Down Expand Up @@ -182,9 +183,9 @@

(defn- prompt-error
[context prompt prompt-args]
(.println *err* (with-out-str (print-stack-trace (Exception. (str "Error " context)))))
(.println *err* (str "Prompt: " prompt))
(.println *err* (str "Prompt args: " prompt-args)))
(.println *err* (with-out-str (print-stack-trace (Exception. (s/strcat "Error " context)))))
(.println *err* (s/strcat "Prompt: " prompt))
(.println *err* (s/strcat "Prompt args: " prompt-args)))

(defn- maybe-pay
[state side eid card choices choice]
Expand Down Expand Up @@ -230,8 +231,8 @@
(when effect
(effect (or choice card)))
(finish-prompt state side prompt card))
(toast state side (str "You cannot choose " choice " for this effect.") "warning"))
(toast state side (str "Could not find a card named " choice ".") "warning")))
(toast state side (s/strcat "You cannot choose " choice " for this effect.") "warning"))
(toast state side (s/strcat "Could not find a card named " choice ".") "warning")))
(prompt-error "in a card-title prompt" prompt args))

;; Otherwise, choices is a sequence of strings and/or cards
Expand Down Expand Up @@ -314,7 +315,7 @@
(wait-for (pay state side (make-eid state eid) card total-pump-cost)
(dotimes [_ times-pump]
(resolve-ability state side (dissoc pump-ability :cost :msg) (get-card state card) nil))
(system-msg state side (str (build-spend-msg (:msg async-result) "increase")
(system-msg state side (s/strcat (build-spend-msg (:msg async-result) "increase")
"the strength of " (:title card) " to "
(get-strength (get-card state card))))
(effect-completed state side eid)))))
Expand Down Expand Up @@ -392,7 +393,7 @@
[(remove :broken (:subroutines current-ice))])]
(wait-for (resolve-ability state side (play-heap-breaker-auto-pump-and-break-impl state side sub-groups-to-break current-ice) card nil)
(system-msg state side
(str (build-spend-msg payment-str "increase")
(s/strcat (build-spend-msg payment-str "increase")
"the strength of " (:title card)
" to " (get-strength (get-card state card))
" and break all subroutines on " (:title current-ice)))
Expand Down Expand Up @@ -490,12 +491,12 @@
(wait-for (resolve-ability state side (play-auto-pump-and-break-impl state side sub-groups-to-break current-ice break-ability) card nil)
(system-msg state side
(if (pos? times-pump)
(str (build-spend-msg payment-str "increase")
(s/strcat (build-spend-msg payment-str "increase")
"the strength of " (:title card)
" to " (get-strength (get-card state card))
" and break all " (when (< 1 unbroken-subs) unbroken-subs)
" subroutines on " (:title current-ice))
(str (build-spend-msg payment-str "use")
(s/strcat (build-spend-msg payment-str "use")
(:title card)
" to break "
(if some-already-broken
Expand All @@ -515,7 +516,7 @@
[state side args]
(if (no-blocking-or-prevent-prompt? state side)
((dynamic-abilities (:dynamic args)) state (keyword side) args)
(toast state side (str "You cannot play abilities while other abilities are resolving.")
(toast state side (s/strcat "You cannot play abilities while other abilities are resolving.")
"warning")))


Expand Down Expand Up @@ -551,7 +552,7 @@
sub (nth (:subroutines card) subroutine nil)]
(when card
(resolve-subroutine! state side card sub)))
(toast state side (str "You cannot fire subroutines while abilities are being resolved.")
(toast state side (s/strcat "You cannot fire subroutines while abilities are being resolved.")
"warning")))

(defn play-unbroken-subroutines
Expand All @@ -560,7 +561,7 @@
(if (no-blocking-or-prevent-prompt? state side)
(when-let [card (get-card state card)]
(resolve-unbroken-subs! state side card))
(toast state side (str "You cannot fire subroutines while abilities are being resolved.")
(toast state side (s/strcat "You cannot fire subroutines while abilities are being resolved.")
"warning")))

;;; Corp actions
Expand Down Expand Up @@ -639,7 +640,7 @@
(->c :click (if-not no-cost 1 0))
(->c :credit (if-not no-cost 1 0)))
(if-let [payment-str (:msg async-result)]
(do (system-msg state side (str (build-spend-msg payment-str "advance") (card-str state card)))
(do (system-msg state side (s/strcat (build-spend-msg payment-str "advance") (card-str state card)))
(update-advancement-requirement state card)
(add-prop state side (get-card state card) :advance-counter 1)
(play-sfx state side "click-advance")
Expand All @@ -657,7 +658,7 @@
_ (update-all-agenda-points state)
c (get-card state c)
points (get-agenda-points c)]
(system-msg state :corp (str "scores " (:title c)
(system-msg state :corp (s/strcat "scores " (:title c)
" and gains " (quantify points "agenda point")))
(implementation-msg state card)
(set-prop state :corp (get-card state c) :advance-counter 0)
Expand Down Expand Up @@ -691,5 +692,5 @@
(if (string/blank? (:msg payment-result))
(effect-completed state side eid)
(do
(system-msg state side (str (:msg payment-result) " to score " (:title card)))
(system-msg state side (s/strcat (:msg payment-result) " to score " (:title card)))
(resolve-score state side eid card))))))))))
Loading
Loading