Skip to content

Commit

Permalink
Merge pull request mtgred#7348 from NoahTheDuke/nb/remove-ugly-hack
Browse files Browse the repository at this point in the history
Further cost clean up
  • Loading branch information
NoahTheDuke authored Apr 4, 2024
2 parents e7b195a + d713104 commit 60426ff
Show file tree
Hide file tree
Showing 10 changed files with 320 additions and 361 deletions.
9 changes: 3 additions & 6 deletions src/clj/game/cards/ice.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2666,15 +2666,11 @@
(defcard "Lycian Multi-Munition"
(letfn [(ice-subtype-choice [choices]
{:prompt "Choose an ice subtype"
:waiting-prompt true
:choices choices
:async true
:effect (req (if (= target "Done")
(effect-completed state side eid)
(let [new-choices (->> choices
(remove #{target})
(cons "Done")
distinct)]
(let [new-choices (remove #{target} choices)]
;; note this is a lingering ability and persists so
;; long as the card is rezzed
;; if the card is hushed, it will not derez, so the subtypes will stay!
Expand All @@ -2691,7 +2687,8 @@
(ice-subtype-choice new-choices)
card nil))))})]
{:on-rez {:async true
:effect (effect (continue-ability (ice-subtype-choice ["Barrier" "Code Gate" "Sentry"]) card nil))}
:waiting-prompt true
:effect (effect (continue-ability (ice-subtype-choice ["Barrier" "Code Gate" "Sentry" "Done"]) card nil))}
:derez-effect {:effect (req (unregister-effects-for-card state side card #(= :gain-subtype (:type %))))}
:static-abilities [{:type :gain-subtype
:req (req (and (same-card? card target) (:subtype-target card)))
Expand Down
27 changes: 14 additions & 13 deletions src/clj/game/core/access.clj
Original file line number Diff line number Diff line change
Expand Up @@ -137,19 +137,20 @@

; Pay credits (from pool or cards) to trash
(= target (first trash-cost-str))
(wait-for (pay state side (make-eid state trash-eid) card [(->c :credit trash-cost)])
(when (:breach @state)
(swap! state assoc-in [:breach :did-trash] true))
(when (:run @state)
(swap! state assoc-in [:run :did-trash] true)
(when must-trash?
(swap! state assoc-in [:run :did-access] true)))
(swap! state assoc-in [:runner :register :trashed-card] true)
(system-msg state side (str (:msg async-result) " to trash "
(:title card) " from "
(name-zone :corp (get-zone card))))
(wait-for (trash state side card {:accessed true})
(access-end state side eid (first async-result) {:trashed true})))
(let [card (update! state side (assoc c :seen true))]
(wait-for (pay state side (make-eid state trash-eid) card [(->c :credit trash-cost)])
(when (:breach @state)
(swap! state assoc-in [:breach :did-trash] true))
(when (:run @state)
(swap! state assoc-in [:run :did-trash] true)
(when must-trash?
(swap! state assoc-in [:run :did-access] true)))
(swap! state assoc-in [:runner :register :trashed-card] true)
(system-msg state side (str (:msg async-result) " to trash "
(:title card) " from "
(name-zone :corp (get-zone card))))
(wait-for (trash state side card {:accessed true})
(access-end state side eid (first async-result) {:trashed true}))))

; Use access ability
(find-first #(same-card? % target) access-ab-cards)
Expand Down
9 changes: 3 additions & 6 deletions src/clj/game/core/actions.clj
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@
(sort-by #(-> % first :auto-pump-sort))
(apply min-key #(let [costs (second %)]
(reduce (fnil + 0 0) 0 (keep :cost/amount costs)))))
cost-req (or (:cost-req pump-ability) identity)
pump-strength (get-pump-strength state side pump-ability card)
strength-diff (when (and current-ice
(get-strength current-ice)
Expand All @@ -257,7 +256,7 @@
0)
total-pump-cost (when (and pump-ability
times-pump)
(repeat times-pump (cost-req pump-cost)))]
(repeat times-pump pump-cost))]
(when (can-pay? state side eid card (:title card) total-pump-cost)
(wait-for (pay state side (make-eid state eid) card total-pump-cost)
(dotimes [_ times-pump]
Expand Down Expand Up @@ -386,7 +385,6 @@
(sort-by #(-> % first :auto-pump-sort))
(apply min-key #(let [costs (second %)]
(reduce (fnil + 0 0) 0 (mapv :cost/amount costs)))))
pump-cost-req (or (:cost-req pump-ability) identity)
pump-strength (get-pump-strength state side pump-ability card)
strength-diff (when (and current-ice
(get-strength current-ice)
Expand All @@ -399,7 +397,7 @@
0)
total-pump-cost (when (and pump-ability
times-pump)
(repeat times-pump (pump-cost-req [pump-cost])))
(repeat times-pump pump-cost))
;; break all subs
can-break (fn [ability]
(when (and (:break-req ability)
Expand All @@ -413,7 +411,6 @@
(sort-by #(-> % first :auto-break-sort))
(apply min-key #(let [costs (second %)]
(reduce (fnil + 0 0) 0 (mapv :cost/amount costs)))))
break-cost-req (or (:cost-req break-ability) identity)
subs-broken-at-once (when break-ability
(:break break-ability 1))
unbroken-subs (when (:subroutines current-ice)
Expand All @@ -426,7 +423,7 @@
1))
total-break-cost (when (and break-cost
times-break)
(repeat times-break (break-cost-req [break-cost])))
(repeat times-break break-cost))
total-cost (merge-costs (conj total-pump-cost total-break-cost))]
(when (and break-ability
(can-pay? state side eid card (:title card) total-cost))
Expand Down
Loading

0 comments on commit 60426ff

Please sign in to comment.