|
141 | 141 | pay-rest (req |
142 | 142 | (if (and (<= (- target-count counter-count) (get-in @state [side :credit])) |
143 | 143 | (<= stealth-target stealth-count)) |
144 | | - (let [remainder (max 0 (- target-count counter-count)) |
145 | | - remainder-str (when (pos? remainder) |
146 | | - (str remainder " [Credits]")) |
147 | | - card-strs (when (pos? (count selected-cards)) |
148 | | - (str (enumerate-str (map #(let [{:keys [card number]} % |
149 | | - title (:title card)] |
150 | | - (str number " [Credits] from " title)) |
151 | | - (vals selected-cards))))) |
152 | | - message (str card-strs |
153 | | - (when (and card-strs remainder-str) |
154 | | - " and ") |
155 | | - remainder-str |
156 | | - (when (and card-strs remainder-str) |
157 | | - " from [their] credit pool"))] |
158 | | - (lose state side :credit remainder) |
159 | | - (let [cards (->> (vals selected-cards) |
160 | | - (map :card) |
161 | | - (remove #(-> (card-def %) :interactions :pay-credits :cost-reduction)))] |
162 | | - (wait-for (trigger-spend-credits-from-cards state side cards) |
163 | | - ; Now we trigger all of the :counter-added events we'd neglected previously |
164 | | - (pick-counter-triggers state side eid selected-cards selected-cards target-count message)))) |
165 | | - (continue-ability |
166 | | - state side |
167 | | - (pick-credit-providing-cards provider-func eid target-count stealth-target selected-cards) |
168 | | - card nil)))] |
| 144 | + (let [remainder (max 0 (- target-count counter-count)) |
| 145 | + remainder-str (when (pos? remainder) |
| 146 | + (str remainder " [Credits]")) |
| 147 | + card-strs (when (pos? (count selected-cards)) |
| 148 | + (str (enumerate-str (map #(let [{:keys [card number]} % |
| 149 | + title (:title card)] |
| 150 | + (str number " [Credits] from " title)) |
| 151 | + (vals selected-cards))))) |
| 152 | + message (str card-strs |
| 153 | + (when (and card-strs remainder-str) |
| 154 | + " and ") |
| 155 | + remainder-str |
| 156 | + (when (and card-strs remainder-str) |
| 157 | + " from [their] credit pool"))] |
| 158 | + (lose state side :credit remainder) |
| 159 | + (let [cards (->> (vals selected-cards) |
| 160 | + (map :card) |
| 161 | + (remove #(-> (card-def %) :interactions :pay-credits :cost-reduction)))] |
| 162 | + (wait-for (trigger-spend-credits-from-cards state side cards) |
| 163 | + ; Now we trigger all of the :counter-added events we'd neglected previously |
| 164 | + (pick-counter-triggers state side eid selected-cards selected-cards target-count message)))) |
| 165 | + (continue-ability |
| 166 | + state side |
| 167 | + (pick-credit-providing-cards provider-func eid target-count stealth-target selected-cards) |
| 168 | + card nil)))] |
169 | 169 | (if (or (not (pos? target-count)) ; there is a limit |
170 | 170 | (<= target-count counter-count) ; paid everything |
171 | 171 | (zero? (count provider-cards))) ; no more additional credit sources found |
172 | 172 | {:async true |
173 | 173 | :effect pay-rest} |
174 | | - {:async true |
175 | | - :prompt (str "Choose a credit providing card (" |
176 | | - counter-count (when (and target-count (pos? target-count)) |
177 | | - (str " of " target-count)) |
178 | | - " [Credits]" |
179 | | - (if (pos? stealth-target) |
180 | | - (str ", " (min stealth-count stealth-target) " of " stealth-target " stealth") |
181 | | - "") |
182 | | - ")") |
183 | | - :choices {:card #(in-coll? (map :cid provider-cards) (:cid %))} |
184 | | - :effect (req (let [pay-credits-type (-> target card-def :interactions :pay-credits :type) |
185 | | - pay-function (if (= :custom pay-credits-type) |
186 | | - (-> target card-def :interactions :pay-credits :custom) |
187 | | - (take-counters-of-type pay-credits-type)) |
188 | | - custom-ability ^:ignore-async-check {:async true |
189 | | - :effect pay-function} |
190 | | - neweid (make-eid state outereid) |
191 | | - providing-card target] |
192 | | - (wait-for (resolve-ability state side neweid custom-ability providing-card [card]) |
193 | | - (continue-ability state side |
194 | | - (pick-credit-providing-cards |
195 | | - provider-func eid target-count stealth-target |
196 | | - (update selected-cards (:cid providing-card) |
197 | | - #(assoc % :card providing-card :number (+ (:number % 0) async-result)))) |
198 | | - card targets)))) |
199 | | - :cancel-effect pay-rest})))) |
| 174 | + {:async true |
| 175 | + :prompt (str "Choose a credit providing card (" |
| 176 | + counter-count (when (and target-count (pos? target-count)) |
| 177 | + (str " of " target-count)) |
| 178 | + " [Credits]" |
| 179 | + (if (pos? stealth-target) |
| 180 | + (str ", " (min stealth-count stealth-target) " of " stealth-target " stealth") |
| 181 | + "") |
| 182 | + ")") |
| 183 | + :choices {:card #(in-coll? (map :cid provider-cards) (:cid %))} |
| 184 | + :effect (req (let [pay-credits-type (-> target card-def :interactions :pay-credits :type) |
| 185 | + pay-function (if (= :custom pay-credits-type) |
| 186 | + (-> target card-def :interactions :pay-credits :custom) |
| 187 | + (take-counters-of-type pay-credits-type)) |
| 188 | + custom-ability ^:ignore-async-check {:async true |
| 189 | + :effect pay-function} |
| 190 | + neweid (make-eid state outereid) |
| 191 | + providing-card target] |
| 192 | + (wait-for (resolve-ability state side neweid custom-ability providing-card [card]) |
| 193 | + (continue-ability state side |
| 194 | + (pick-credit-providing-cards |
| 195 | + provider-func eid target-count stealth-target |
| 196 | + (update selected-cards (:cid providing-card) |
| 197 | + #(assoc % :card providing-card :number (+ (:number % 0) async-result)))) |
| 198 | + card targets)))) |
| 199 | + :cancel-effect pay-rest})))) |
0 commit comments