Skip to content

Commit

Permalink
Merge pull request #6472 from NoahTheDuke/nb/bug-fixes-22-07-25
Browse files Browse the repository at this point in the history
Bug Fixes 2022-07-25
  • Loading branch information
NoahTheDuke authored Jul 27, 2022
2 parents 3717432 + d49ee82 commit 73fab4a
Show file tree
Hide file tree
Showing 14 changed files with 231 additions and 182 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,4 @@ tags.temp.tmp

.lsp/
.shadow-cljs/
tests-user.edn
2 changes: 1 addition & 1 deletion src/clj/game/cards/assets.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2272,7 +2272,7 @@
:choices {:not-self true
:req (req (and (corp? target)
(installed? target)))}
:msg (msg "trash " (:title target) " and gain 3 [Credits]")
:msg (msg "trash " (card-str state target) " and gain 3 [Credits]")
:cancel-effect (req (system-msg state :corp "declines to use Svyatogor Excavator")
(effect-completed state side eid))
:effect (req (wait-for (trash state side target {:unpreventable true :cause-card card})
Expand Down
3 changes: 2 additions & 1 deletion src/clj/game/cards/ice.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3618,7 +3618,8 @@
:prompt "Place an advancement token on a card that can be advanced"
:msg (msg "place 1 advancement token on " (card-str state target))
:effect (effect (add-prop target :advance-counter 1 {:placed true}))
:cancel-effect (effect (system-msg state side "declines to use Vasilisa"))}
:cancel-effect (effect (system-msg "declines to use Vasilisa")
(effect-completed eid))}
:no-ability {:msg "declines to use Vasilisa"}}}
:subroutines [(give-tags 1)]})

Expand Down
56 changes: 31 additions & 25 deletions src/clj/game/cards/identities.clj
Original file line number Diff line number Diff line change
Expand Up @@ -1406,41 +1406,48 @@
;; to update these cards, just add {:cause card} into the keys pass with (trash-card)
;; At the moment, the source (or cause) of the trash must be a corp-card, a subroutine,
;; or it must be an ability cost.
(letfn [(resolve-install [target]
(req ;; if it has an additional cost, the rez needs to be optional
(letfn [(resolve-install []
(req
(shuffle! state side :deck)
(system-msg state side (str "shuffles R&D"))
(let [add-costs (rez-additional-cost-bonus state side target)
inst-target target]
(if (pos? (count add-costs))
(if (can-pay? state side (:title inst-target) add-costs)
(system-msg state side "shuffles R&D")
;; if it has an additional cost, the rez needs to be optional
(if (= "No install" target)
(effect-completed state side eid)
(let [add-costs (rez-additional-cost-bonus state side target)
inst-target target]
(cond
(and (pos? (count add-costs))
(can-pay? state side (:title inst-target) add-costs))
(continue-ability
state side
{:optional
{:prompt (str "Rez " (:title inst-target) ", paying additional costs?")
:yes-ability {:msg (msg "to rez "(:title inst-target)
:yes-ability {:msg (msg "to rez " (:title inst-target)
", paying additional costs")
:async true
:effect (req (corp-install state side eid inst-target nil
{:ignore-all-cost true
:install-state :rezzed-no-rez-cost}))}
:no-ability {:msg "install a card ignoring all credit costs"
:async true
:effect (req (corp-install state side eid inst-target nil
{:ignore-all-cost true}))}}}
card nil)
;; It might be worth having a fake prompt here - at the very least, this prevents
;; the corp from accidentally revealing the card they select
(pos? (count add-costs))
(continue-ability
state side
{:msg (msg "install a card without paying additional costs to rez")
{:msg "install a card without paying additional costs to rez"
:async true
:effect (req (corp-install state side eid inst-target nil
{:ignore-all-cost true}))}
card nil))
(wait-for (reveal state side inst-target)
(corp-install state side eid (get-card state inst-target) nil
{:ignore-all-cost true
:install-state :rezzed-no-rez-cost}))))))
card nil)
:else
(wait-for (reveal state side inst-target)
(corp-install state side eid (get-card state inst-target) nil
{:ignore-all-cost true
:install-state :rezzed-no-rez-cost})))))))
;; Identify that the card wasn't just dragged to the discard, and that it was trashed
;; by the corporation.
;; This requires that any (trash-cards ..) or (trash ..) fns use {:source card}
Expand All @@ -1449,13 +1456,12 @@
(trash-cause [eid target]
(let [cause (:cause target)
cause-card (:cause-card target)]
(cond
(corp? (:source eid)) (str "trashed by " (:title (:source eid)))
(= :ability-cost cause) "trashed as an ability-cost"
(= :subroutine cause) "trashed by an ice subroutine"
(and (corp? cause-card) (not= cause :opponent-trashes)) "trashed by a corp card"
(and (runner? cause-card) (= cause :forced-to-trash)) "forced to trash by runner"
:else nil)))
(or
(corp? (:source eid))
(= :ability-cost cause)
(= :subroutine cause)
(and (corp? cause-card) (not= cause :opponent-trashes))
(and (runner? cause-card) (= cause :forced-to-trash)))))
;; prompts to install an x-cost card (handles validation)
(ob-ability [target-cost]
{:optional
Expand All @@ -1467,14 +1473,14 @@
:async true
:effect (effect (continue-ability
{:prompt "Choose a card to install and rez"
:choices {:max 1
:req (req (filter #(and (= target-cost (:cost %))
:choices (req (conj (filter #(and (= target-cost (:cost %))
(or (asset? %)
(upgrade? %)
(ice? %)))
(vec (sort-by :title (:deck corp)))))}
(vec (sort-by :title (:deck corp))))
"No install"))
:async true
:effect (resolve-install target)}
:effect (resolve-install)}
card nil))}}})]
{:events [{:event :corp-trash
:req (req (and
Expand Down
5 changes: 3 additions & 2 deletions src/clj/game/cards/operations.clj
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@
(corp? %))}
:async true
:waiting-prompt "Corp to make a decision"
:msg "gain 3 [Credit]"
:msg (msg "trash " (card-str state target) " and gain 3 [Credits]")
:cancel-effect (effect (system-msg "declines to use Extract to trash an installed card")
(effect-completed eid))
:effect (req (wait-for (trash state side target {:cause-card card})
Expand Down Expand Up @@ -2722,7 +2722,8 @@
:async true
:cancel-effect (effect (system-msg "declines to use Trust Operation to install a card")
(effect-completed eid))
:effect (effect (corp-install eid target nil {:install-state :rezzed-no-cost}))}]
:effect (effect (corp-install eid target nil {:ignore-all-cost true
:install-state :rezzed-no-cost}))}]
{:on-play {:req (req tagged)
:msg (msg "trash " (:title target))
:prompt "Choose a resource to trash"
Expand Down
21 changes: 11 additions & 10 deletions src/clj/game/core/costs.clj
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,17 @@
(and (pos? (value cost))
(pos? (count (provider-func))))
(wait-for (resolve-ability state side (pick-credit-providing-cards provider-func eid (value cost) (stealth-value cost)) card nil)
(wait-for (trigger-event-sync
state side (make-eid state eid)
(if (= side :corp) :corp-spent-credits :runner-spent-credits)
(value cost))
(swap! state update-in [:stats side :spent :credit] (fnil + 0) (value cost))
(complete-with-result state side eid
{:msg (str "pays " (:msg async-result))
:type :credit
:value (:number async-result)
:targets (:targets async-result)})))
(let [pay-async-result async-result]
(wait-for (trigger-event-sync
state side (make-eid state eid)
(if (= side :corp) :corp-spent-credits :runner-spent-credits)
(value cost))
(swap! state update-in [:stats side :spent :credit] (fnil + 0) (value cost))
(complete-with-result state side eid
{:msg (str "pays " (:msg pay-async-result))
:type :credit
:value (:number pay-async-result)
:targets (:targets pay-async-result)}))))
(pos? (value cost))
(do (lose state side :credit (value cost))
(wait-for (trigger-event-sync
Expand Down
8 changes: 4 additions & 4 deletions src/clj/game/core/engine.clj
Original file line number Diff line number Diff line change
Expand Up @@ -995,23 +995,23 @@
(effect-completed state nil eid)))

(defn unregister-expired-durations
[state _ eid duration context-maps]
[state _ eid durations context-maps]
(wait-for (trash-when-expired state nil (make-eid state eid) context-maps)
(unregister-floating-events state nil :pending)
(when duration
(doseq [duration durations]
(unregister-floating-effects state nil duration)
(unregister-floating-events state nil duration))
(effect-completed state nil eid)))

(defn checkpoint
([state eid] (checkpoint state nil eid nil))
([state _ eid] (checkpoint state nil eid nil))
([state _ eid {:keys [duration] :as args}]
([state _ eid {:keys [duration durations] :as args}]
;; a: Any ability that has met its condition creates the appropriate instances of itself and marks them as pending
(let [{:keys [handlers context-maps]} (mark-pending-abilities state eid args)]
;; b: Any ability with a duration that has passed is removed from the game state
(wait-for
(unregister-expired-durations state nil (make-eid state eid) duration context-maps)
(unregister-expired-durations state nil (make-eid state eid) (conj durations duration) context-maps)
;; c: Check winning or tying by agenda points
(check-win-by-agenda state)
;; d: uniqueness check
Expand Down
Loading

0 comments on commit 73fab4a

Please sign in to comment.