Skip to content

Commit

Permalink
Merge pull request #7933 from NBKelly/rewrite-grammar-properly
Browse files Browse the repository at this point in the history
Rewrite grammar properly
  • Loading branch information
NoahTheDuke authored Jan 31, 2025
2 parents 30249af + 1dd7327 commit ee70f98
Show file tree
Hide file tree
Showing 14 changed files with 348 additions and 227 deletions.
1 change: 1 addition & 0 deletions src/clj/game/cards/assets.clj
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@

(defcard "B-1001"
{:abilities [{:req (req (not this-server))
:async true
:cost [(->c :tag 1)]
:msg "end the run"
:label "End the run on another server"
Expand Down
1 change: 1 addition & 0 deletions src/clj/game/cards/hardware.clj
Original file line number Diff line number Diff line change
Expand Up @@ -1253,6 +1253,7 @@

(defcard "Lemuria Codecracker"
{:abilities [{:action true
:async true
:cost [(->c :click 1) (->c :credit 1)]
:req (req (some #{:hq} (:successful-run runner-reg)))
:choices {:card installed?}
Expand Down
1 change: 1 addition & 0 deletions src/clj/game/cards/ice.clj
Original file line number Diff line number Diff line change
Expand Up @@ -1241,6 +1241,7 @@

(defcard "Clairvoyant Monitor"
{:subroutines [(do-psi {:label "Place 1 advancement token and end the run"
:async true
:player :corp
:prompt "Choose an installed card to place 1 advancement token on"
:msg (msg "place 1 advancement token on "
Expand Down
1 change: 1 addition & 0 deletions src/clj/game/cards/operations.clj
Original file line number Diff line number Diff line change
Expand Up @@ -1632,6 +1632,7 @@
(has-subtype? % "Connection")
(installed? %))}
:msg (msg "host itself on " (card-str state target) ". The Runner has an additional tag")
:async true
:effect (effect (install-as-condition-counter eid card target))}
:static-abilities [{:type :tags
:value 1}]
Expand Down
1 change: 0 additions & 1 deletion src/clj/game/cards/programs.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2081,7 +2081,6 @@
:once :per-turn
:cost [(->c :x-credits)]
:req (req (:runner-phase-12 @state))
:async true
:effect (effect (add-counter card :power (cost-value eid :x-credits)))
:msg (msg "place " (quantify (cost-value eid :x-credits) "power counter") " on itself")}
(break-sub [(->c :power 1)] 1)
Expand Down
8 changes: 5 additions & 3 deletions src/clj/game/cards/upgrades.clj
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@
{:events [{:event :pass-all-ice
:psi {:req (req this-server)
:not-equal {:msg "end the run"
:async true
:effect (effect (end-run eid card))}}}]})

(defcard "Cayambe Grid"
Expand Down Expand Up @@ -493,8 +494,7 @@
:effect (effect (add-counter card :power 1))}]})

(defcard "Corporate Troubleshooter"
{:abilities [{:async true
:label "Add strength to a rezzed piece of ice protecting this server"
{:abilities [{:label "Add strength to a rezzed piece of ice protecting this server"
:cost [(->c :trash-can) (->c :x-credits)]
:choices {:all true
:req (req (and (ice? target)
Expand Down Expand Up @@ -678,6 +678,7 @@
etr {:req (req this-server)
:cost [(->c :power 1)]
:msg "end the run"
:async true
:effect (effect (end-run eid card))}]
{:derezzed-events [(assoc corp-rez-toast :event :runner-turn-ends)]
:events [(assoc maybe-gain-counter :event :corp-turn-begins)
Expand Down Expand Up @@ -1707,6 +1708,7 @@
:choices {:req (req (same-server? card target))}
:msg (msg "place " (if (is-boosted-fn? state side) 3 2) " advancement counters on "
(card-str state target))
:async true
:effect
(req (let [n (if (is-boosted-fn? state side) 3 2)]
(add-prop state side eid target :advance-counter n {:placed true})))}]
Expand Down Expand Up @@ -1752,7 +1754,7 @@
{:async true
:msg "do 1 core damage instead of net damage"
:effect (req (swap! state update :damage dissoc :damage-replace :defer-damage)
(wait-for (pay state :corp (make-eid state eid) card (->c :credit 2))
(wait-for (pay state :corp card (->c :credit 2))
(system-msg state side (:msg async-result))
(wait-for (damage state side :brain 1 {:card card})
(swap! state assoc-in [:damage :damage-replace] true)
Expand Down
2 changes: 2 additions & 0 deletions src/clj/game/core/commands.clj
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@
(or (installed? target)
(in-hand? target))))}
:msg (msg "score " (card-str state target {:visible true}) ", ignoring all restrictions")
:async true
:effect (effect (score eid target {:no-req true :ignore-turn true}))}
(make-card {:title "the '/score' command"}) nil)))

Expand Down Expand Up @@ -408,6 +409,7 @@
state side
{:prompt "Choose a card to trash"
:choices {:card #(f %)}
:async true
:effect (effect (trash eid target {:unpreventable true}))}
nil nil)))

Expand Down
1 change: 1 addition & 0 deletions src/clj/game/core/costs.clj
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,7 @@
:choices {:card #(and (agenda? %)
(is-scored? state side %)
(pos? (get-counters % :agenda)))}
:async true
:effect (req (let [title (:title target)
target (update! state side (update-in target [:counter :agenda] - (value cost)))]
(wait-for (trigger-event-sync state side :agenda-counter-spent target)
Expand Down
110 changes: 55 additions & 55 deletions src/clj/game/core/pick_counters.clj
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@
pay-function (if (= :custom pay-credits-type)
(-> target card-def :interactions :pay-credits :custom)
(take-counters-of-type pay-credits-type))
custom-ability {:async true
:effect pay-function}
custom-ability ^:ignore-async-check {:async true
:effect pay-function}
neweid (make-eid state outereid)
providing-card target]
(wait-for (resolve-ability state side neweid custom-ability providing-card [card])
Expand Down Expand Up @@ -141,59 +141,59 @@
pay-rest (req
(if (and (<= (- target-count counter-count) (get-in @state [side :credit]))
(<= stealth-target stealth-count))
(let [remainder (max 0 (- target-count counter-count))
remainder-str (when (pos? remainder)
(str remainder " [Credits]"))
card-strs (when (pos? (count selected-cards))
(str (enumerate-str (map #(let [{:keys [card number]} %
title (:title card)]
(str number " [Credits] from " title))
(vals selected-cards)))))
message (str card-strs
(when (and card-strs remainder-str)
" and ")
remainder-str
(when (and card-strs remainder-str)
" from [their] credit pool"))]
(lose state side :credit remainder)
(let [cards (->> (vals selected-cards)
(map :card)
(remove #(-> (card-def %) :interactions :pay-credits :cost-reduction)))]
(wait-for (trigger-spend-credits-from-cards state side cards)
; Now we trigger all of the :counter-added events we'd neglected previously
(pick-counter-triggers state side eid selected-cards selected-cards target-count message))))
(continue-ability
state side
(pick-credit-providing-cards provider-func eid target-count stealth-target selected-cards)
card nil)))]
(let [remainder (max 0 (- target-count counter-count))
remainder-str (when (pos? remainder)
(str remainder " [Credits]"))
card-strs (when (pos? (count selected-cards))
(str (enumerate-str (map #(let [{:keys [card number]} %
title (:title card)]
(str number " [Credits] from " title))
(vals selected-cards)))))
message (str card-strs
(when (and card-strs remainder-str)
" and ")
remainder-str
(when (and card-strs remainder-str)
" from [their] credit pool"))]
(lose state side :credit remainder)
(let [cards (->> (vals selected-cards)
(map :card)
(remove #(-> (card-def %) :interactions :pay-credits :cost-reduction)))]
(wait-for (trigger-spend-credits-from-cards state side cards)
; Now we trigger all of the :counter-added events we'd neglected previously
(pick-counter-triggers state side eid selected-cards selected-cards target-count message))))
(continue-ability
state side
(pick-credit-providing-cards provider-func eid target-count stealth-target selected-cards)
card nil)))]
(if (or (not (pos? target-count)) ; there is a limit
(<= target-count counter-count) ; paid everything
(zero? (count provider-cards))) ; no more additional credit sources found
{:async true
:effect pay-rest}
{:async true
:prompt (str "Choose a credit providing card ("
counter-count (when (and target-count (pos? target-count))
(str " of " target-count))
" [Credits]"
(if (pos? stealth-target)
(str ", " (min stealth-count stealth-target) " of " stealth-target " stealth")
"")
")")
:choices {:card #(in-coll? (map :cid provider-cards) (:cid %))}
:effect (req (let [pay-credits-type (-> target card-def :interactions :pay-credits :type)
pay-function (if (= :custom pay-credits-type)
(-> target card-def :interactions :pay-credits :custom)
(take-counters-of-type pay-credits-type))
custom-ability {:async true
:effect pay-function}
neweid (make-eid state outereid)
providing-card target]
(wait-for (resolve-ability state side neweid custom-ability providing-card [card])
(continue-ability state side
(pick-credit-providing-cards
provider-func eid target-count stealth-target
(update selected-cards (:cid providing-card)
#(assoc % :card providing-card :number (+ (:number % 0) async-result))))
card targets))))
:cancel-effect pay-rest}))))
{:async true
:effect pay-rest}
{:async true
:prompt (str "Choose a credit providing card ("
counter-count (when (and target-count (pos? target-count))
(str " of " target-count))
" [Credits]"
(if (pos? stealth-target)
(str ", " (min stealth-count stealth-target) " of " stealth-target " stealth")
"")
")")
:choices {:card #(in-coll? (map :cid provider-cards) (:cid %))}
:effect (req (let [pay-credits-type (-> target card-def :interactions :pay-credits :type)
pay-function (if (= :custom pay-credits-type)
(-> target card-def :interactions :pay-credits :custom)
(take-counters-of-type pay-credits-type))
custom-ability ^:ignore-async-check {:async true
:effect pay-function}
neweid (make-eid state outereid)
providing-card target]
(wait-for (resolve-ability state side neweid custom-ability providing-card [card])
(continue-ability state side
(pick-credit-providing-cards
provider-func eid target-count stealth-target
(update selected-cards (:cid providing-card)
#(assoc % :card providing-card :number (+ (:number % 0) async-result))))
card targets))))
:cancel-effect pay-rest}))))
3 changes: 2 additions & 1 deletion src/clj/game/core/prompts.clj
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
{:keys [waiting-prompt prompt-type show-discard cancel-effect end-effect targets]}]
(let [prompt (if (string? message) message (message state side eid card targets))
choices (choice-parser choices)
newitem {:eid eid
newitem ^:ignore-async-check
{:eid eid
:msg prompt
:choices choices
:effect f
Expand Down
2 changes: 2 additions & 0 deletions src/clj/game/core/runs.clj
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,7 @@
state :runner
{:prompt "Choose a breach replacement ability"
:choices (if mandatory titles (conj titles (str "Breach " (zone->name (:server (:run @state))))))
:async true
:effect (req (let [chosen (some #(when (= target (get-in % [:card :title])) %) handlers)
ability (:ability chosen)
card (:card chosen)]
Expand Down Expand Up @@ -630,6 +631,7 @@
state :runner eid
{:prompt (str "You are prevented from breaching " (zone->name server) " this run.")
:choices ["OK"]
:async true
:effect (effect (system-msg :runner (str "is prevented from breaching " (zone->name server) " this run."))
(handle-end-run eid))}
nil nil)
Expand Down
1 change: 1 addition & 0 deletions src/clj/game/core/sabotage.clj
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
(defn sabotage-ability
[n]
(let [choosing-ab (fn [forced-hq]
^:ignore-async-check
{:waiting-prompt true
:player :corp
:prompt (choosing-prompt-req n)
Expand Down
1 change: 1 addition & 0 deletions src/clj/game/core/turns.clj
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
:choices {:card in-hand?
:max (- cur-hand-size (max (hand-size state side) 0))
:all true}
:async true
:effect (req (system-msg state side
(str "discards "
(if (= :runner side)
Expand Down
Loading

0 comments on commit ee70f98

Please sign in to comment.