Skip to content

Commit 566e93d

Browse files
committed
suppress checkpoints when calling from a cost
1 parent e4310d7 commit 566e93d

File tree

6 files changed

+94
-64
lines changed

6 files changed

+94
-64
lines changed

src/clj/game/core/bad_publicity.clj

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
(ns game.core.bad-publicity
22
(:require
33
[game.core.eid :refer [effect-completed make-eid make-result]]
4-
[game.core.engine :refer [trigger-event trigger-event-sync]]
4+
[game.core.engine :refer [checkpoint queue-event trigger-event trigger-event-sync]]
55
[game.core.flags :refer [cards-can-prevent? get-prevent-list]]
66
[game.core.gaining :refer [gain lose]]
77
[game.core.prompts :refer [clear-wait-prompt show-prompt show-wait-prompt]]
@@ -16,11 +16,14 @@
1616
:amount n}))
1717

1818
(defn- resolve-bad-publicity
19-
[state side eid n]
19+
[state side eid n {:keys [suppress-checkpoint] :as args}]
2020
(if (pos? n)
2121
(do (gain state :corp :bad-publicity n)
2222
(toast state :corp (str "Took " n " bad publicity!") "info")
23-
(trigger-event-sync state side (make-result eid n) :corp-gain-bad-publicity {:amount n}))
23+
(queue-event state :corp-gain-bad-publicity {:amount n})
24+
(if suppress-checkpoint
25+
(effect-completed state side eid)
26+
(checkpoint state eid)))
2427
(effect-completed state side eid)))
2528

2629
(defn- bad-publicity-count
@@ -58,8 +61,8 @@
5861
" bad publicity")
5962
"will not avoid bad publicity"))
6063
(clear-wait-prompt state :runner)
61-
(resolve-bad-publicity state side eid (max 0 (- n (or prevent 0))))))))
62-
(resolve-bad-publicity state side eid n))))))
64+
(resolve-bad-publicity state side eid (max 0 (- n (or prevent 0))) args)))))
65+
(resolve-bad-publicity state side eid n args))))))
6366

6467
(defn lose-bad-publicity
6568
([state side n] (lose-bad-publicity state side (make-eid state) n))

src/clj/game/core/costs.clj

Lines changed: 48 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
[game.core.card-defs :refer [card-def]]
77
[game.core.damage :refer [damage]]
88
[game.core.eid :refer [complete-with-result make-eid]]
9-
[game.core.engine :refer [checkpoint queue-event resolve-ability trigger-event-sync]]
9+
[game.core.engine :refer [checkpoint queue-event resolve-ability]]
1010
[game.core.effects :refer [any-effects is-disabled-reg?]]
1111
[game.core.flags :refer [is-scored?]]
1212
[game.core.gaining :refer [deduct lose]]
1313
[game.core.moving :refer [discard-from-hand flip-facedown forfeit mill move trash trash-cards]]
1414
[game.core.payment :refer [handler label payable? value stealth-value]]
1515
[game.core.pick-counters :refer [pick-credit-providing-cards pick-credit-reducers pick-virus-counters-to-spend]]
1616
[game.core.props :refer [add-counter add-prop]]
17-
[game.core.revealing :refer [reveal]]
17+
[game.core.revealing :refer [reveal reveal-and-queue-event]]
1818
[game.core.rezzing :refer [derez]]
1919
[game.core.shuffling :refer [shuffle!]]
2020
[game.core.tags :refer [lose-tags gain-tags]]
@@ -227,14 +227,16 @@
227227
(in-hand? (get-card state card)))
228228
(defmethod handler :expend
229229
[cost state side eid card]
230-
(wait-for (reveal state :corp (make-eid state eid) [card])
231-
(wait-for (trash state :corp (make-eid state eid)
232-
(assoc (get-card state card) :seen true))
233-
(complete-with-result state side eid
234-
{:paid/msg (str "trashes " (:title card) " from HQ")
235-
:paid/type :expend
236-
:paid/value 1
237-
:paid/targets [card]}))))
230+
(reveal-and-queue-event state side [card])
231+
(wait-for (trash state :corp (make-eid state eid)
232+
(assoc (get-card state card) :seen true) {:cause :ability-cost
233+
:unpreventable true
234+
:suppress-checkpoint true})
235+
(complete-with-result state side eid
236+
{:paid/msg (str "trashes " (:title card) " from HQ")
237+
:paid/type :expend
238+
:paid/value 1
239+
:paid/targets [card]})))
238240

239241
;; Trash
240242
(defmethod value :trash-can [cost] (:cost/amount cost))
@@ -246,7 +248,8 @@
246248
(defmethod handler :trash-can
247249
[cost state side eid card]
248250
(wait-for (trash state side card {:cause :ability-cost
249-
:unpreventable true})
251+
:unpreventable true
252+
:suppress-checkpoint true})
250253
(complete-with-result state side eid {:paid/msg (str "trashes " (:title card))
251254
:paid/type :trash-can
252255
:paid/value 1
@@ -274,14 +277,13 @@
274277
;; everything is queued, then we perform the actual checkpoint.
275278
(forfeit state side (make-eid state eid) agenda {:msg false
276279
:suppress-checkpoint true}))
277-
(wait-for (checkpoint state nil (make-eid state eid) {:durations [:game-trash]})
278-
(complete-with-result
279-
state side eid
280-
{:paid/msg (str "forfeits " (quantify (value cost) "agenda")
281-
" (" (enumerate-str (map :title targets)) ")")
282-
:paid/type :forfeit
283-
:paid/value (value cost)
284-
:paid/targets targets})))}
280+
(complete-with-result
281+
state side eid
282+
{:paid/msg (str "forfeits " (quantify (value cost) "agenda")
283+
" (" (enumerate-str (map :title targets)) ")")
284+
:paid/type :forfeit
285+
:paid/value (value cost)
286+
:paid/targets targets}))}
285287
card nil))
286288

287289
;; ForfeitSelf
@@ -292,15 +294,15 @@
292294
(is-scored? state side (get-card state card)))
293295
(defmethod handler :forfeit-self
294296
[_cost state side eid card]
295-
(wait-for (forfeit state side (make-eid state eid) card {:msg false})
297+
(wait-for (forfeit state side (make-eid state eid) card {:msg false
298+
:suppress-checkpoint true})
296299
(complete-with-result
297300
state side eid
298301
{:paid/msg (str "forfeits " (:title card))
299302
:paid/type :forfeit-self
300303
:paid/value 1
301304
:paid/targets [card]})))
302305

303-
304306
;; Gain tag
305307
(defmethod value :gain-tag [cost] (:cost/amount cost))
306308
(defmethod label :gain-tag [cost] (str "take " (quantify (value cost) "tag")))
@@ -311,7 +313,7 @@
311313
true)
312314
(defmethod handler :gain-tag
313315
[cost state side eid card]
314-
(wait-for (gain-tags state side (value cost))
316+
(wait-for (gain-tags state side (value cost) {:suppress-checkpoint true})
315317
(complete-with-result state side eid {:paid/msg (str "takes " (quantify (value cost) "tag"))
316318
:paid/type :gain-tag
317319
:paid/value (value cost)})))
@@ -324,7 +326,7 @@
324326
(<= 0 (- (get-in @state [:runner :tag :base] 0) (value cost))))
325327
(defmethod handler :tag
326328
[cost state side eid card]
327-
(wait-for (lose-tags state side (value cost))
329+
(wait-for (lose-tags state side (value cost) {:suppress-checkpoint true})
328330
(complete-with-result state side eid {:paid/msg (str "removes " (quantify (value cost) "tag"))
329331
:paid/type :tag
330332
:paid/value (value cost)})))
@@ -338,7 +340,7 @@
338340
(defmethod handler :tag-or-bad-pub
339341
[cost state side eid card]
340342
(if-not (<= 0 (- (get-in @state [:runner :tag :base] 0) (value cost)))
341-
(wait-for (gain-bad-publicity state side (make-eid state eid) (value cost) nil)
343+
(wait-for (gain-bad-publicity state side (make-eid state eid) (value cost) {:suppress-checkpoint true})
342344
(complete-with-result state side eid {:paid/msg (str "gains " (value cost) " bad publicity")
343345
:paid/type :tag-or-bad-pub
344346
:paid/value (value cost)}))
@@ -349,11 +351,11 @@
349351
(str "Gain " (value cost) " bad publicity")]
350352
:async true
351353
:effect (req (if (= target (str "Gain " (value cost) " bad publicity"))
352-
(wait-for (gain-bad-publicity state side (make-eid state eid) (value cost) nil)
354+
(wait-for (gain-bad-publicity state side (make-eid state eid) (value cost) {:suppress-checkpoint true})
353355
(complete-with-result state side eid {:paid/msg (str "gains " (value cost) " bad publicity")
354356
:paid/type :tag-or-bad-pub
355357
:paid/value (value cost)}))
356-
(wait-for (lose-tags state side (value cost))
358+
(wait-for (lose-tags state side (value cost) {:suppress-checkpoint true})
357359
(complete-with-result state side eid {:paid/msg (str "removes " (quantify (value cost) "tag"))
358360
:paid/type :tag-or-bad-pub
359361
:paid/value (value cost)}))))}
@@ -443,6 +445,7 @@
443445
(corp? %)))}
444446
:async true
445447
:effect (req (wait-for (trash-cards state side targets {:cause :ability-cost
448+
:suppress-checkpoint true
446449
:unpreventable true})
447450
(complete-with-result
448451
state side eid
@@ -473,6 +476,7 @@
473476
(corp? %)))}
474477
:async true
475478
:effect (req (wait-for (trash-cards state side targets {:cause :ability-cost
479+
:suppress-checkpoint true
476480
:unpreventable true})
477481
(complete-with-result
478482
state side eid
@@ -500,6 +504,7 @@
500504
:card (every-pred installed? hardware? (complement facedown?))}
501505
:async true
502506
:effect (req (wait-for (trash-cards state side targets {:cause :ability-cost
507+
:suppress-checkpoint true
503508
:unpreventable true})
504509
(complete-with-result
505510
state side eid
@@ -532,6 +537,7 @@
532537
(not (same-card? % card))
533538
(has-subtype? % "Harmonic"))}
534539
:async true
540+
;; TODO - once derez is async, fix this
535541
:effect (req (doseq [harmonic targets]
536542
(derez state side harmonic))
537543
(complete-with-result
@@ -560,6 +566,7 @@
560566
:card (every-pred installed? program? (complement facedown?))}
561567
:async true
562568
:effect (req (wait-for (trash-cards state side targets {:cause :ability-cost
569+
:suppress-checkpoint true
563570
:unpreventable true})
564571
(complete-with-result
565572
state side eid
@@ -587,6 +594,7 @@
587594
:card (every-pred installed? resource? (complement facedown?))}
588595
:async true
589596
:effect (req (wait-for (trash-cards state side targets {:cause :ability-cost
597+
:suppress-checkpoint true
590598
:unpreventable true})
591599
(complete-with-result
592600
state side eid
@@ -617,6 +625,7 @@
617625
(complement facedown?))}
618626
:async true
619627
:effect (req (wait-for (trash-cards state side targets {:cause :ability-cost
628+
:suppress-checkpoint true
620629
:unpreventable true})
621630
(complete-with-result
622631
state side eid
@@ -644,6 +653,7 @@
644653
:card (every-pred installed? rezzed? ice?)}
645654
:async true
646655
:effect (req (wait-for (trash-cards state side targets {:cause :ability-cost
656+
:suppress-checkpoint true
647657
:unpreventable true})
648658
(complete-with-result
649659
state side eid
@@ -663,7 +673,7 @@
663673
(<= 0 (- (count (get-in @state [side :deck])) (value cost))))
664674
(defmethod handler :trash-from-deck
665675
[cost state side eid card]
666-
(wait-for (mill state side side (value cost))
676+
(wait-for (mill state side side (value cost) {:suppress-checkpoint true})
667677
(complete-with-result
668678
state side eid
669679
{:paid/msg (str "trashes " (quantify (count async-result) "card")
@@ -692,7 +702,7 @@
692702
:max (value cost)
693703
:card select-fn}
694704
:async true
695-
:effect (req (wait-for (trash-cards state side targets {:unpreventable true :seen false})
705+
:effect (req (wait-for (trash-cards state side targets {:unpreventable true :seen false :suppress-checkpoint true})
696706
(complete-with-result
697707
state side eid
698708
{:paid/msg (str "trashes " (quantify (count async-result) "card")
@@ -714,7 +724,7 @@
714724
(<= 0 (- (count (get-in @state [side :hand])) (value cost))))
715725
(defmethod handler :randomly-trash-from-hand
716726
[cost state side eid card]
717-
(wait-for (discard-from-hand state side side (value cost))
727+
(wait-for (discard-from-hand state side side (value cost) {:suppress-checkpoint true})
718728
(complete-with-result
719729
state side eid
720730
{:paid/msg (str "trashes " (quantify (count async-result) "card")
@@ -732,7 +742,7 @@
732742
(defmethod handler :trash-entire-hand
733743
[cost state side eid card]
734744
(let [cards (get-in @state [side :hand])]
735-
(wait-for (trash-cards state side cards {:unpreventable true})
745+
(wait-for (trash-cards state side cards {:unpreventable true :suppress-checkpoint true})
736746
(complete-with-result
737747
state side eid
738748
{:paid/msg (str "trashes all (" (count async-result) ") cards in "
@@ -760,7 +770,7 @@
760770
:choices {:all true
761771
:max (value cost)
762772
:card (every-pred hardware? in-hand?)}
763-
:effect (req (wait-for (trash-cards state side targets {:unpreventable true})
773+
:effect (req (wait-for (trash-cards state side targets {:unpreventable true :suppress-checkpoint true})
764774
(complete-with-result
765775
state side eid
766776
{:paid/msg (str "trashes " (quantify (count async-result) "piece")
@@ -788,7 +798,7 @@
788798
:choices {:all true
789799
:max (value cost)
790800
:card (every-pred program? in-hand?)}
791-
:effect (req (wait-for (trash-cards state side targets {:unpreventable true})
801+
:effect (req (wait-for (trash-cards state side targets {:unpreventable true :suppress-checkpoint true})
792802
(complete-with-result
793803
state side eid
794804
{:paid/msg (str "trashes " (quantify (count async-result) "program")
@@ -815,7 +825,7 @@
815825
:choices {:all true
816826
:max (value cost)
817827
:card (every-pred resource? in-hand?)}
818-
:effect (req (wait-for (trash-cards state side targets {:unpreventable true})
828+
:effect (req (wait-for (trash-cards state side targets {:unpreventable true :suppress-checkpoint true})
819829
(complete-with-result
820830
state side eid
821831
{:paid/msg (str "trashes " (quantify (count async-result) "resource")
@@ -834,7 +844,7 @@
834844
(<= (value cost) (count (get-in @state [:runner :hand]))))
835845
(defmethod handler :net
836846
[cost state side eid card]
837-
(wait-for (damage state side :net (value cost) {:unpreventable true :card card})
847+
(wait-for (damage state side :net (value cost) {:unpreventable true :card card :suppress-checkpoint true})
838848
(complete-with-result
839849
state side eid
840850
{:paid/msg (str "suffers " (count async-result) " net damage")
@@ -850,7 +860,7 @@
850860
(<= (value cost) (count (get-in @state [:runner :hand]))))
851861
(defmethod handler :meat
852862
[cost state side eid card]
853-
(wait-for (damage state side :meat (value cost) {:unpreventable true :card card})
863+
(wait-for (damage state side :meat (value cost) {:unpreventable true :card card :suppress-checkpoint true})
854864
(complete-with-result
855865
state side eid
856866
{:paid/msg (str "suffers " (count async-result) " meat damage")
@@ -866,7 +876,7 @@
866876
(<= (value cost) (count (get-in @state [:runner :hand]))))
867877
(defmethod handler :brain
868878
[cost state side eid card]
869-
(wait-for (damage state side :brain (value cost) {:unpreventable true :card card})
879+
(wait-for (damage state side :brain (value cost) {:unpreventable true :card card :suppress-checkpoint true})
870880
(complete-with-result
871881
state side eid
872882
{:paid/msg (str "suffers " (count async-result) " core damage")
@@ -993,6 +1003,7 @@
9931003
(pos? (get-counters % :agenda)))}
9941004
:async true
9951005
:effect (req (wait-for (add-counter state side target :agenda (- (value cost)) {:suppress-checkpoint true})
1006+
(queue-event state :agenda-counter-spent {:value (value cost)})
9961007
(complete-with-result
9971008
state side eid
9981009
{:paid/msg (str "spends "
@@ -1052,6 +1063,7 @@
10521063
(defmethod handler :agenda
10531064
[cost state side eid card]
10541065
(wait-for (add-counter state side card :agenda (- (value cost)) {:suppress-checkpoint true})
1066+
(queue-event state :agenda-counter-spent {:value (value cost)})
10551067
(complete-with-result
10561068
state side eid
10571069
{:paid/msg (str "spends "

0 commit comments

Comments
 (0)