|
119 | 119 | ([provider-func outereid] (pick-credit-providing-cards provider-func outereid nil 0 (hash-map))) |
120 | 120 | ([provider-func outereid target-count] (pick-credit-providing-cards provider-func outereid target-count 0 (hash-map))) |
121 | 121 | ([provider-func outereid target-count stealth-target] (pick-credit-providing-cards provider-func outereid target-count stealth-target (hash-map))) |
122 | | - ([provider-func outereid target-count stealth-target selected-cards] |
| 122 | + ([provider-func outereid target-count stealth-target selected-cards] (pick-credit-providing-cards provider-func outereid target-count stealth-target selected-cards nil)) |
| 123 | + ([provider-func outereid target-count stealth-target selected-cards pre-chosen] |
123 | 124 | (let [counter-count (reduce + 0 (map #(:number (second %) 0) selected-cards)) |
124 | 125 | selected-stealth (filter #(has-subtype? (:card (second %)) "Stealth") selected-cards) |
125 | 126 | stealth-count (reduce + 0 (map #(:number (second %) 0) selected-stealth)) |
126 | 127 | provider-cards (if (= (- counter-count target-count) (- stealth-count stealth-target)) |
127 | 128 | (filter #(has-subtype? % "Stealth") (provider-func)) |
128 | 129 | (provider-func)) |
129 | 130 | provider-cards (filter #(not (get-in (card-def %) [:interactions :pay-credits :cost-reduction])) provider-cards) |
| 131 | + ;; note - this allows holding the shift key while clicking a card to keep picking that card while possible |
| 132 | + ;; ie: taking 5cr from miss bones with one click, instead of waiting for 5 server round-trips |
| 133 | + should-auto-repeat? (fn [state side] (get-in @state [side :shift-key-select] nil)) |
130 | 134 | pay-rest (req |
131 | 135 | (if (and (<= (- target-count counter-count) (get-in @state [side :credit])) |
132 | 136 | (<= stealth-target stealth-count)) |
|
160 | 164 | (zero? (count provider-cards))) ; no more additional credit sources found |
161 | 165 | {:async true |
162 | 166 | :effect pay-rest} |
163 | | - {:async true |
164 | | - :prompt (str "Choose a credit providing card (" |
165 | | - counter-count (when (and target-count (pos? target-count)) |
166 | | - (str " of " target-count)) |
167 | | - " [Credits]" |
168 | | - (if (pos? stealth-target) |
169 | | - (str ", " (min stealth-count stealth-target) " of " stealth-target " stealth") |
170 | | - "") |
171 | | - ")") |
172 | | - :choices {:card #(in-coll? (map :cid provider-cards) (:cid %))} |
173 | | - :effect (req (let [pay-credits-type (-> target card-def :interactions :pay-credits :type) |
174 | | - pay-function (if (= :custom pay-credits-type) |
175 | | - (-> target card-def :interactions :pay-credits :custom) |
176 | | - (take-counters-of-type pay-credits-type)) |
177 | | - custom-ability ^:ignore-async-check {:async true |
178 | | - :effect pay-function} |
179 | | - neweid (make-eid state outereid) |
180 | | - providing-card target] |
181 | | - (wait-for (resolve-ability state side neweid custom-ability providing-card [card]) |
182 | | - (continue-ability state side |
183 | | - (pick-credit-providing-cards |
184 | | - provider-func eid target-count stealth-target |
185 | | - (update selected-cards (:cid providing-card) |
186 | | - #(assoc % :card providing-card :number (+ (:number % 0) async-result)))) |
187 | | - card targets)))) |
188 | | - :cancel-effect pay-rest})))) |
| 167 | + (if (and pre-chosen (in-coll? (map :cid provider-cards) (:cid pre-chosen))) |
| 168 | + {:async true |
| 169 | + :effect (req (let [target pre-chosen |
| 170 | + pay-credits-type (-> target card-def :interactions :pay-credits :type) |
| 171 | + pay-function (if (= :custom pay-credits-type) |
| 172 | + (-> target card-def :interactions :pay-credits :custom) |
| 173 | + (take-counters-of-type pay-credits-type)) |
| 174 | + custom-ability ^:ignore-async-check {:async true |
| 175 | + :effect pay-function} |
| 176 | + neweid (make-eid state outereid) |
| 177 | + providing-card target] |
| 178 | + (wait-for (resolve-ability state side neweid custom-ability providing-card [card]) |
| 179 | + (continue-ability state side |
| 180 | + (pick-credit-providing-cards |
| 181 | + provider-func eid target-count stealth-target |
| 182 | + (update selected-cards (:cid providing-card) |
| 183 | + #(assoc % :card providing-card :number (+ (:number % 0) async-result))) |
| 184 | + target) |
| 185 | + card targets))))} |
| 186 | + {:async true |
| 187 | + :prompt (str "Choose a credit providing card (" |
| 188 | + counter-count (when (and target-count (pos? target-count)) |
| 189 | + (str " of " target-count)) |
| 190 | + " [Credits]" |
| 191 | + (if (pos? stealth-target) |
| 192 | + (str ", " (min stealth-count stealth-target) " of " stealth-target " stealth") |
| 193 | + "") |
| 194 | + ")") |
| 195 | + :choices {:card #(in-coll? (map :cid provider-cards) (:cid %))} |
| 196 | + :effect (req (let [pay-credits-type (-> target card-def :interactions :pay-credits :type) |
| 197 | + pay-function (if (= :custom pay-credits-type) |
| 198 | + (-> target card-def :interactions :pay-credits :custom) |
| 199 | + (take-counters-of-type pay-credits-type)) |
| 200 | + custom-ability ^:ignore-async-check {:async true |
| 201 | + :effect pay-function} |
| 202 | + neweid (make-eid state outereid) |
| 203 | + providing-card target] |
| 204 | + (wait-for (resolve-ability state side neweid custom-ability providing-card [card]) |
| 205 | + (continue-ability state side |
| 206 | + (pick-credit-providing-cards |
| 207 | + provider-func eid target-count stealth-target |
| 208 | + (update selected-cards (:cid providing-card) |
| 209 | + #(assoc % :card providing-card :number (+ (:number % 0) async-result))) |
| 210 | + (when (should-auto-repeat? state side) target)) |
| 211 | + card targets)))) |
| 212 | + :cancel-effect pay-rest}))))) |
0 commit comments