Skip to content

Commit

Permalink
Merge pull request mtgred#7369 from NoahTheDuke/nb/explicit-pay-actions
Browse files Browse the repository at this point in the history
Move actions in pay to eid
  • Loading branch information
NoahTheDuke authored Apr 4, 2024
2 parents b96cd95 + 4b33d53 commit e7b195a
Show file tree
Hide file tree
Showing 13 changed files with 104 additions and 95 deletions.
4 changes: 3 additions & 1 deletion .clj-kondo/config.edn
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{:linters
{:unresolved-symbol
{:unused-binding {:exclude-defmulti-args true
:exclude-destructured-as true}
:unresolved-symbol
{:exclude [(game.macros/req [state side eid card targets target context
runner corp run run-server run-ices run-position
current-ice corp-reg corp-reg-last runner-reg
Expand Down
24 changes: 12 additions & 12 deletions src/clj/game/cards/assets.clj
Original file line number Diff line number Diff line change
Expand Up @@ -1434,19 +1434,20 @@
{:abilities [ability]
:leave-play cleanup
:events [{:event :corp-spent-click
:effect (req (let [cid (first target)
ability-idx (:ability-idx (:source-info eid))
:effect (req (let [[cid value ability-idx] targets
bac-cid (get-in @state [:corp :basic-action-card :cid])
cause (if (keyword? (first target))
(case (first target)
cause (if (keyword? cid)
(case cid
:play-instant [bac-cid 3]
:corp-click-install [bac-cid 2]
(first target)) ; in clojure there's: (= [1 2 3] '(1 2 3))
; else
[cid ability-idx])
[cid ability-idx])
clicks-spent (+ (get-in card [:seen-this-turn cause] 0) (second targets))]
(update! state side (assoc-in card [:seen-this-turn cause] clicks-spent))
(when (>= clicks-spent 3) ; can be >= 3 because :once :per-turn on ability
(resolve-ability state side ability (get-card state card) nil))))}
clicks-spent (+ (get-in card [:seen-this-turn cause] 0) value)]
(let [card (update! state side (assoc-in card [:seen-this-turn cause] clicks-spent))]
; can be >= 3 because :once :per-turn on ability
(when (>= clicks-spent 3)
(resolve-ability state side ability card nil)))))}
{:event :corp-turn-ends
:effect cleanup}]}))

Expand Down Expand Up @@ -2989,13 +2990,12 @@
card nil))})
all-events (fn [state side] (turn-events state side :corp-spent-click))
three-of (fn [cid idx state side]
(= 3 (count (filter #(and (= (first (first %)) cid)
(= 3 (count (filter #(and (= (first %) cid)
(= (last %) idx))
(all-events state side)))))]
{:events [{:event :corp-spent-click
:async true
:effect (req (let [cid (first target)
ability-idx (:ability-idx (:source-info eid))]
:effect (req (let [[cid _value ability-idx] targets]
(if (three-of cid ability-idx state side)
(continue-ability state side payoff card nil)
(effect-completed state side eid))))}]}))
Expand Down
9 changes: 6 additions & 3 deletions src/clj/game/cards/basic.clj
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
can-pay (can-pay? state side (make-eid state (assoc eid :additional-costs additional-costs)) target (:title target) additional-costs)]
(or (empty? additional-costs) can-pay))))}
:effect (req
(let [additional-costs (merge-costs (into [] (get-effects state side :basic-ability-additional-trash-cost target)))
(let [additional-costs (merge-costs (get-effects state side :basic-ability-additional-trash-cost target))
cost-strs (build-cost-string additional-costs)
can-pay (can-pay? state side (make-eid state (assoc eid :additional-costs additional-costs)) target (:title target) additional-costs)]
(if (empty? additional-costs)
Expand All @@ -129,8 +129,11 @@
(do (system-msg state side (str "declines to pay the additional cost to trash " (:title target-card)))
(effect-completed state side eid))
(wait-for (pay state side (make-eid state
(assoc eid :additional-costs additional-costs :source card :source-type :trash-card))
nil additional-costs 0)
(assoc eid
:additional-costs additional-costs
:source card
:source-type :trash-card))
nil additional-costs)
(system-msg state side (str (:msg async-result) " as an additional cost to trash " (:title target-card)))
(complete-with-result state side eid target-card))))}
card nil)
Expand Down
4 changes: 2 additions & 2 deletions src/clj/game/cards/ice.clj
Original file line number Diff line number Diff line change
Expand Up @@ -1649,7 +1649,7 @@
"Trash an installed card")])
:async true
:effect (req (if (= target "Pay 2 [Credits]")
(wait-for (pay state side (make-eid state eid) card :credit 2)
(wait-for (pay state side (make-eid state eid) card (->c :credit 2))
(system-msg state side (:msg async-result))
(effect-completed state side eid))
(continue-ability state :runner runner-trash-installed-sub card nil)))}]
Expand All @@ -1671,7 +1671,7 @@
"Trash an installed card")])
:async true
:effect (req (if (= target "Pay 3 [Credits]")
(wait-for (pay state side (make-eid state eid) card :credit 3)
(wait-for (pay state side (make-eid state eid) card (->c :credit 3))
(system-msg state side (:msg async-result))
(effect-completed state side eid))
(continue-ability state :runner runner-trash-installed-sub card nil)))}]
Expand Down
9 changes: 4 additions & 5 deletions src/clj/game/cards/identities.clj
Original file line number Diff line number Diff line change
Expand Up @@ -1299,14 +1299,13 @@
:abilities [mm-ability mm-clear]
:events [{:event :corp-spent-click
:async true
:effect (req (let [cid (first target)
ability-idx (:ability-idx (:source-info eid))
:effect (req (let [[cid _value ability-idx] targets
bac-cid (get-in @state [:corp :basic-action-card :cid])
cause (if (keyword? (first target))
(case (first target)
cause (if (keyword? cid)
(case cid
:play-instant [bac-cid 3]
:corp-click-install [bac-cid 2]
(first target)) ; in clojure there's: (= [1 2 3] '(1 2 3))
[cid ability-idx])
[cid ability-idx])
prev-actions (get-in card [:special :mm-actions] [])
actions (conj prev-actions cause)]
Expand Down
4 changes: 2 additions & 2 deletions src/clj/game/cards/resources.clj
Original file line number Diff line number Diff line change
Expand Up @@ -1842,10 +1842,10 @@
;; and having it trashed (all-cards wont find it)
;; also asset that the first-event? fn actually works right...
;; -nbk, mar '24
(and (resource? (find-cid (first target) all-cards))
(and (resource? (find-cid target all-cards))
(first-event? state side :runner-spent-click
#(resource?
(find-cid (first (first %)) all-cards))))))
(find-cid (first %) all-cards))))))
:msg "gain [Click]"
:effect (effect (add-counter card :power -1)
(gain-clicks 1))}]})
Expand Down
12 changes: 7 additions & 5 deletions src/clj/game/core/access.clj
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,13 @@

;; Pay additiional costs to steal
(= target "Pay to steal")
(wait-for (pay state side (make-eid state
(assoc eid :additional-costs cost
:source card
:source-type :runner-steal))
nil cost {:action :steal-cost})
(wait-for (pay state side
(make-eid state
(assoc eid :additional-costs cost
:source card
:source-type :runner-steal
:action :steal-cost))
nil cost)
(system-msg state side (str (:msg async-result) " to steal "
(:title card) " from "
(name-zone :corp (get-zone card))))
Expand Down
12 changes: 8 additions & 4 deletions src/clj/game/core/actions.clj
Original file line number Diff line number Diff line change
Expand Up @@ -564,10 +564,11 @@
(let [card (get-card state card)
eid (eid-set-defaults eid :source nil :source-type :advance)]
(if (can-advance? state side card)
(wait-for (pay state side (make-eid state eid) card
(wait-for (pay state side
(make-eid state (assoc eid :action :corp-advance))
card
(->c :click (if-not no-cost 1 0))
(->c :credit (if-not no-cost 1 0))
{:action :corp-advance})
(->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)))
(update-advancement-requirement state card)
Expand Down Expand Up @@ -612,7 +613,10 @@
(string/blank? cost-strs) (resolve-score state side eid card)
(not can-pay) (effect-completed state side eid)
:else (wait-for (pay state side (make-eid state
(assoc eid :additional-costs cost :source card :source-type :corp-score))
(assoc eid
:additional-costs cost
:source card
:source-type :corp-score))
nil cost)
(let [payment-result async-result]
(if (string/blank? (:msg payment-result))
Expand Down
Loading

0 comments on commit e7b195a

Please sign in to comment.