-
Notifications
You must be signed in to change notification settings - Fork 386
/
hardware.clj
2452 lines (2312 loc) · 127 KB
/
hardware.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
(ns game.cards.hardware
(:require
[clojure.set :as set]
[clojure.string :as str]
[game.core.access :refer [access-bonus access-card breach-server
get-only-card-to-access]]
[game.core.actions :refer [play-ability]]
[game.core.board :refer [all-active all-active-installed all-installed]]
[game.core.card :refer [active? corp? event? facedown? get-card get-counters get-title
get-zone hardware? has-subtype? ice? in-deck? in-discard?
in-hand? in-scored? installed? program? resource? rezzed?
runner? virus-program? faceup?]]
[game.core.card-defs :refer [card-def]]
[game.core.cost-fns :refer [all-stealth install-cost
rez-additional-cost-bonus rez-cost trash-cost]]
[game.core.damage :refer [chosen-damage damage damage-prevent
enable-runner-damage-choice runner-can-choose-damage?]]
[game.core.def-helpers :refer [breach-access-bonus defcard offer-jack-out
reorder-choice trash-on-empty get-x-fn]]
[game.core.drawing :refer [draw]]
[game.core.effects :refer [register-lingering-effect
unregister-effects-for-card unregister-lingering-effects]]
[game.core.eid :refer [effect-completed make-eid make-result]]
[game.core.engine :refer [can-trigger? not-used-once? register-events
register-once register-suppress resolve-ability trigger-event
unregister-floating-events unregister-suppress-by-uuid]]
[game.core.events :refer [event-count first-event? first-trash? no-event?
run-events]]
[game.core.expose :refer [expose]]
[game.core.finding :refer [find-card find-latest]]
[game.core.flags :refer [can-trash? card-flag? in-corp-scored? register-run-flag!
zone-locked?]]
[game.core.gaining :refer [gain-clicks gain-credits lose-clicks
lose-credits]]
[game.core.hand-size :refer [hand-size runner-hand-size+]]
[game.core.hosting :refer [host]]
[game.core.ice :refer [all-subs-broken? any-subs-broken? break-sub pump
reset-all-ice update-all-ice update-all-icebreakers
update-breaker-strength]]
[game.core.installing :refer [runner-can-install? runner-can-pay-and-install? runner-install]]
[game.core.link :refer [get-link link+]]
[game.core.memory :refer [caissa-mu+ mu+ update-mu virus-mu+]]
[game.core.moving :refer [mill move swap-agendas trash trash-cards]]
[game.core.optional :refer [get-autoresolve never? set-autoresolve]]
[game.core.payment :refer [build-cost-string can-pay? cost-value]]
[game.core.play-instants :refer [play-instant]]
[game.core.prompts :refer [cancellable clear-wait-prompt]]
[game.core.props :refer [add-counter add-icon remove-icon]]
[game.core.revealing :refer [reveal]]
[game.core.rezzing :refer [derez rez]]
[game.core.runs :refer [bypass-ice end-run end-run-prevent
get-current-encounter jack-out make-run
successful-run-replace-breach total-cards-accessed]]
[game.core.say :refer [system-msg]]
[game.core.servers :refer [target-server is-central?]]
[game.core.shuffling :refer [shuffle!]]
[game.core.tags :refer [gain-tags lose-tags tag-prevent]]
[game.core.to-string :refer [card-str]]
[game.core.toasts :refer [toast]]
[game.core.update :refer [update!]]
[game.core.virus :refer [count-virus-programs number-of-virus-counters]]
[game.macros :refer [continue-ability effect msg req wait-for]]
[game.utils :refer :all]
[jinteki.utils :refer :all]
[game.core.set-aside :refer [set-aside get-set-aside]]
[game.core.sabotage :refer [sabotage-ability]]
[game.core.mark :refer [identify-mark-ability]]))
;; Card definitions
(defcard "Acacia"
{:events [{:event :purge
:optional
{:player :runner
:waiting-prompt true
:prompt "Trash Acacia to gain 1 [Credits] for each purged virus counter?"
:yes-ability
{:async true
:effect (req (let [counters (:total-purged-counters context)]
(wait-for (trash state side card {:cause-card card})
(system-msg state side (str "trashes Acacia and gains " counters " [Credit]"))
(gain-credits state side eid counters))))}}}]})
(defcard "Adjusted Matrix"
{:implementation "Click Adjusted Matrix to use the ability"
:on-install {:req (req (not-empty (filter #(has-subtype? % "Icebreaker") (all-active-installed state :runner))))
:prompt "Choose an icebreaker"
:choices {:card #(and (runner? %)
(has-subtype? % "Icebreaker")
(installed? %))}
:msg (msg "host itself on " (card-str state target))
:effect (effect (host (get-card state target) (get-card state card)))}
:static-abilities [{:type :gain-subtype
:req (req (same-card? target (:host card)))
:value "AI"}]
:abilities [(break-sub [:lose-click 1] 1 "All" {:req (req true)})]})
(defcard "AirbladeX (JSRF Ed.)"
(let [ability {:label "Prevent a \"when encountered\" ability on a piece of ice"
:cost [:power 1]
:msg (msg "prevent the encounter ability on " (card-str state current-ice))
:effect (req (let [[suppress]
(register-suppress
state side card
(let [ice current-ice]
[{:event :encounter-ice
;; TODO: when suppression is fixed, this should be (:ice context)
:req (req (same-card? ice target))}]))]
(register-once state side {:once :per-turn} card) ;; needed for firing in the event handler
(register-events
state side card
[{:event :end-of-encounter
:duration :end-of-encounter
:unregister-once-resolved true
:effect (effect (unregister-suppress-by-uuid (:uuid suppress)))}])))}]
{:data {:counter {:power 3}}
:interactions {:prevent [{:type #{:net}
:req (req run)}]}
:events [(trash-on-empty :power)
{:event :encounter-ice
:req (req (contains? (card-def current-ice) :on-encounter))
:async true
:effect
(effect (continue-ability
{:eid (assoc eid :source-type :ability)
:optional
{:prompt (str "Prevent \"when encountered\" ability of " (card-str state current-ice) "?")
:waiting-prompt true
:yes-ability ability}}
card nil))}]
:abilities [{:cost [:power 1]
:req (req run)
:msg "prevent 1 net damage"
:effect (effect (damage-prevent :net 1))}
(assoc ability
:req (req (and (= :approach-ice (:phase run))
(rezzed? current-ice)
(or (->> (:events @state)
(filter #(and (= :encounter-ice (:event %))
(same-card? current-ice (:card %))))
seq)
(contains? (card-def current-ice) :on-encounter)))))]}))
(defcard "Akamatsu Mem Chip"
{:static-abilities [(mu+ 1)]})
(defcard "Aniccam"
(let [ability {:async true
:once-per-instance true
:req (req (and (some #(event? (:card %)) targets)
(letfn [(event-targets? [targets]
(some #(event? (:card %)) targets))]
(first-trash? state event-targets?))))
:msg "draw 1 card"
:effect (effect (draw :runner eid 1))}]
{:static-abilities [(mu+ 1)]
:events [(assoc ability :event :corp-trash)
(assoc ability :event :runner-trash)
(assoc ability :event :game-trash)]}))
(defcard "Archives Interface"
{:events
[{:event :breach-server
:async true
:interactive (req true)
:req (req (and (= target :archives)
(not= (:max-access run) 0)
(not-empty (:discard corp))))
:effect (req (swap! state update-in [:corp :discard] #(map (fn [c] (assoc c :seen true)) %))
(continue-ability
state side
{:optional
{:prompt "Remove a card from the game instead of accessing it?"
:yes-ability {:prompt "Choose a card in Archives"
:choices (req (:discard corp))
:msg (msg "remove " (:title target) " from the game")
:effect (effect (move :corp target :rfg))}}} card nil))}]})
(defcard "Astrolabe"
{:static-abilities [(mu+ 1)]
:events [{:event :server-created
:msg "draw 1 card"
:async true
:effect (effect (draw :runner eid 1))}]})
(defcard "Autoscripter"
{:events [{:event :runner-install
:silent (req true)
:req (req (and (program? (:card context))
;; only trigger on Runner's turn
(= (:active-player @state) :runner)
;; only trigger when playing a Program from grip
(some #{:hand} (:previous-zone (:card context)))
;; check that we haven't played a Program from the grip this turn
;; which translates to just one case of playing a Program in turn-events
(first-event? state :runner :runner-install
(fn [[context]]
(and (some #{:hand} (:previous-zone (:card context)))
(program? (:card context)))))))
:msg "gain [Click]"
:effect (effect (gain-clicks 1))}
{:event :unsuccessful-run
:async true
:msg "trash itself"
:effect (effect (trash eid card {:cause-card card}))}]})
(defcard "Basilar Synthgland 2KVJ"
{:on-install {:async true
:effect (effect (damage eid :brain 2 {:card card}))}
:in-play [:click-per-turn 1]})
(defcard "Blackguard"
{:static-abilities [(mu+ 2)]
:events [{:event :expose
:msg (msg "attempt to force the rez of " (:title target))
:async true
:effect (req (let [c target
cname (:title c)
cost (rez-cost state side target)
additional-costs (rez-additional-cost-bonus state side target)]
(if (seq additional-costs)
(continue-ability
state side
{:optional
{:waiting-prompt true
:prompt (msg (build-cost-string [:credit cost])
", plus " (decapitalize (build-cost-string additional-costs))
" as an additional cost to rez " cname "?")
:player :corp
:yes-ability {:async true
:effect (effect (rez :corp eid c))}
:no-ability {:msg (msg "declines to pay additional costs"
" and is not forced to rez " cname)}}}
card nil)
(rez state :corp eid target))))}]})
(defcard "BMI Buffer"
(let [grip-program-trash?
(fn [card]
(and (runner? card)
(program? card)
(in-discard? card)
(= (first (:previous-zone card)) :hand)))
triggered-ability
{:async true
:effect (req (doseq [c (filter grip-program-trash? (mapv #(find-latest state (:card %)) targets))]
(host state side (get-card state card) c))
(effect-completed state side eid))}]
{:events [(assoc triggered-ability :event :runner-trash)
(assoc triggered-ability :event :corp-trash)]
:abilities [{:cost [:click 2]
:label "Install a hosted program"
:prompt "Choose a program to install"
:choices (req (cancellable (filter #(can-pay? state side (assoc eid :source card :source-type :runner-install)
% nil [:credit (install-cost state side %)])
(:hosted card))))
:msg (msg "install " (:title target))
:async true
:effect (effect (runner-install (assoc eid :source card :source-type :runner-install) target))}]}))
(defcard "BMI Buffer 2"
(let [grip-program-trash?
(fn [card]
(and (runner? card)
(program? card)
(in-discard? card)
(= (first (:previous-zone card)) :hand)))
triggered-ability
{:async true
:effect (req (doseq [c (filter grip-program-trash? (mapv #(find-latest state (:card %)) targets))]
(host state side (get-card state card) c))
(effect-completed state side eid))}]
{:events [(assoc triggered-ability :event :runner-trash)
(assoc triggered-ability :event :corp-trash)]
:abilities [{:cost [:click 2]
:label "Install a hosted program"
:prompt "Choose a program to install"
:choices (req (:hosted card))
:msg (msg "install " (:title target))
:async true
:effect (effect (runner-install (assoc eid :source card :source-type :runner-install) target {:ignore-all-cost true}))}]}))
(defcard "Bookmark"
{:abilities [{:label "Host up to 3 cards from the grip facedown"
:cost [:click 1]
:keep-menu-open :while-clicks-left
:msg "host up to 3 cards from the grip facedown"
:choices {:max 3
:card #(and (runner? %)
(in-hand? %))}
:effect (req (doseq [c targets]
(host state side (get-card state card) c {:facedown true})))}
{:label "Add all hosted cards to the grip"
:cost [:click 1]
:msg "add all hosted cards to the grip"
:effect (req (doseq [c (:hosted card)]
(move state side c :hand)))}
{:label "Add all hosted cards to the grip"
:trash-icon true
:effect (req (doseq [c (:hosted card)]
(move state side c :hand))
(continue-ability
state side
{:cost [:trash-can]
:msg "add all hosted cards to the grip"}
(get-card state card) nil))}]})
(defcard "Boomerang"
{:on-install {:prompt "Choose an installed piece of ice"
:msg (msg "target " (card-str state target))
:choices {:card #(and (installed? %)
(ice? %))}
:effect (effect (add-icon card target "B" (faction-label card))
(update! (assoc-in (get-card state card) [:special :boomerang-target] target)))}
:leave-play (effect (remove-icon card))
:abilities [(assoc
(break-sub
[:trash-can] 2 "All"
{:req (req (if-let [boomerang-target (get-in card [:special :boomerang-target])]
(some #(same-card? boomerang-target (:ice %)) (:encounters @state))
true))}) ; When eg. flipped by Assimilator
:effect
(req (wait-for
(trash state side (make-eid state eid) card {:cause :ability-cost
:cause-card card
:unpreventable true})
(continue-ability
state :runner
(when-let [[boomerang] async-result]
(break-sub
nil 2 "All"
{:additional-ability
{:effect
(effect
(register-events
boomerang
[{:event :run-ends
:duration :end-of-run
:optional
{:req (req (and (:successful target)
(not (zone-locked? state :runner :discard))
(some #(= (:title card) (:title %)) (:discard runner))))
:once :per-run
:prompt (msg "Shuffle a copy of " (:title card) " back into the Stack?")
:yes-ability
{:msg (msg "shuffle a copy of " (:title card) " back into the Stack")
:effect (effect (move (some #(when (= (:title card) (:title %)) %)
(:discard runner))
:deck)
(shuffle! :deck))}}}]))}}))
card nil))))]})
(defcard "Box-E"
{:static-abilities [(mu+ 2)
(runner-hand-size+ 2)]})
(defcard "Brain Cage"
{:static-abilities [(runner-hand-size+ 3)]
:on-install {:async true
:effect (effect (damage eid :brain 1 {:card card}))}})
(defcard "Brain Chip"
{:x-fn (req (max (get-in @state [:runner :agenda-point] 0) 0))
:static-abilities [(mu+
(req (pos? ((get-x-fn) state side eid card targets)))
;; [:regular N] is needed to make the mu system work
(req [:regular ((get-x-fn) state side eid card targets)]))
(runner-hand-size+ (get-x-fn))]})
(defcard "Buffer Drive"
(let [grip-or-stack-trash?
(fn [targets]
(some #(and (runner? (:card %))
(or (in-hand? (:card %))
(in-deck? (:card %))))
targets))
triggered-ability
{:once-per-instance true
:req (req (and (grip-or-stack-trash? targets)
(first-trash? state grip-or-stack-trash?)))
:prompt "Choose 1 trashed card to add to the bottom of the stack"
:choices (req (conj (sort (map :title (map :card targets))) "No action"))
:async true
:effect (req (if (= "No action" target)
(effect-completed state side eid)
(do (system-msg state side
(str "uses " (:title card) " to add " target
" to the bottom of the stack"))
(move state side (find-card target (:discard (:runner @state))) :deck)
(effect-completed state side eid))))}]
{:events [(assoc triggered-ability :event :runner-trash)
(assoc triggered-ability :event :corp-trash)]
:abilities [{:req (req (not (zone-locked? state :runner :discard)))
:label "Add a card from the heap to the top of the stack"
:cost [:remove-from-game]
:show-discard true
:choices {:card #(and (runner? %)
(in-discard? %))}
:msg (msg "add " (:title target) " to the top of the stack")
:effect (effect (move target :deck {:front true}))}]}))
(defcard "Capstone"
{:abilities [{:req (req (pos? (count (:hand runner))))
:label "trash and install cards"
:cost [:click 1]
:async true
:prompt "Choose any number of cards to trash from the grip"
:choices {:max (req (count (:hand runner)))
:card #(and (runner? %)
(in-hand? %))}
:effect (req (let [trashed-card-names (keep :title targets)
installed-card-names (keep :title (all-active-installed state :runner))
overlap (set/intersection (set trashed-card-names)
(set installed-card-names))]
(wait-for (trash-cards state side targets {:unpreventable true
:cause-card card})
(let [trashed-cards async-result]
(wait-for (draw state side (count (filter overlap trashed-card-names)))
(system-msg state side
(str "uses " (:title card) " to trash "
(enumerate-str (map :title trashed-cards))
" from the grip and draw "
(quantify (count async-result) "card")))
(effect-completed state side eid))))))}]})
(defcard "Capybara"
{:events [{:event :bypassed-ice
:async true
:optional
{:req (req true)
:prompt (msg "Remove this hardware from the game to derez " (:title target) "?")
:waiting-prompt true
:yes-ability
{:async true
:cost [:remove-from-game]
:msg (msg "derez " (card-str state target))
:effect (effect (derez target)
(effect-completed eid))}}}]})
(defcard "Carnivore"
{:static-abilities [(mu+ 1)]
:interactions
{:access-ability
{:label "Trash card"
:req (req (and (can-trash? state :runner target)
(not (get-in @state [:per-turn (:cid card)]))
(<= 2 (count (:hand runner)))))
:cost [:trash-from-hand 2]
:msg (msg "trash " (:title target) " at no cost")
:once :per-turn
:async true
:effect (effect (trash eid (assoc target :seen true) {:accessed true
:cause-card card}))}}})
(defcard "Chop Bot 3000"
(let [ability {:req (req (>= (count (all-installed state :runner)) 2))
:label "Trash another installed card to draw 1 card or remove 1 tag"
:once :per-turn
:choices {:card #(and (runner? %)
(installed? %))
:not-self true}
:async true
:effect (req (wait-for (trash state :runner target {:unpreventable true :cause-card card})
(continue-ability
state side
(let [trashed-card target
tags (pos? (count-real-tags state))]
{:prompt "Choose one"
:waiting-prompt true
:choices ["Draw 1 card"
(when tags "Remove 1 tag")]
:async true
:msg (msg "trash " (:title trashed-card) " and " (decapitalize target))
:effect (req (if (= target "Draw 1 card")
(draw state :runner eid 1)
(lose-tags state :runner eid 1)))})
card nil)))}]
{:flags {:runner-phase-12 (req (>= (count (all-installed state :runner)) 2))}
:events [(assoc ability
:event :runner-turn-begins
:interactive (req true))]
:abilities [ability]}))
(defcard "Clone Chip"
{:abilities [{:prompt "Choose a program to install"
:label "Install program from the heap"
:show-discard true
:req (req (some #(and (program? %)
(runner-can-pay-and-install?
state side
(assoc eid :source card :source-type :runner-install) % nil))
(:discard runner)))
:choices {:req (req (and (program? target)
(in-discard? target)
(can-pay? state side (assoc eid :source card :source-type :runner-install) target nil
[:credit (install-cost state side target)])))}
:cost [:trash-can]
:msg (msg "install " (:title target))
:effect (effect (runner-install (assoc eid :source card :source-type :runner-install) target nil))}]})
(defcard "Comet"
{:static-abilities [(mu+ 1)]
:events [{:event :play-event
:req (req (first-event? state side :play-event))
:effect (req (system-msg state :runner
(str "can play another event without spending a [Click] by clicking on Comet"))
(update! state side (assoc card :comet-event true)))}]
:abilities [{:async true
:label "Play an event in the grip twice"
:req (req (:comet-event card))
:prompt "Choose an event to play"
:choices {:card #(and (event? %)
(in-hand? %))}
:msg (msg "play " (:title target))
:effect (req (let [eid (assoc eid :source-type :play)]
(update! state :runner (dissoc (get-card state card) :comet-event))
(play-instant state side eid target nil)))}]})
(defcard "Cortez Chip"
{:abilities [{:prompt "Choose a piece of ice"
:label "increase rez cost of ice"
:choices {:card #(and (ice? %)
(not (rezzed? %)))}
:msg (msg "increase the rez cost of " (card-str state target)
" by 2 [Credits] until the end of the turn")
:cost [:trash-can]
:effect (effect (register-lingering-effect
card
(let [ice target]
{:type :rez-additional-cost
:duration :end-of-turn
:req (req (same-card? target ice))
:value [:credit 2]})))}]})
(defcard "Cyberdelia"
{:static-abilities [(mu+ 1)]
:events [{:event :subroutines-broken
:req (req (and (all-subs-broken? target)
(first-event? state side :subroutines-broken #(all-subs-broken? (first %)))))
:msg "gain 1 [Credits] for breaking all subroutines on a piece of ice"
:async true
:effect (effect (gain-credits eid 1))}]})
(defcard "Cyberfeeder"
{:recurring 1
:interactions {:pay-credits {:req (req (or (and (= :runner-install (:source-type eid))
(has-subtype? target "Virus")
(program? target))
(and (= :ability (:source-type eid))
(has-subtype? target "Icebreaker"))))
:type :recurring}}})
(defcard "CyberSolutions Mem Chip"
{:static-abilities [(mu+ 2)]})
(defcard "Cybsoft MacroDrive"
{:recurring 1
:interactions {:pay-credits {:req (req (and (= :runner-install (:source-type eid))
(program? target)))
:type :recurring}}})
(defcard "Daredevil"
{:static-abilities [(mu+ 2)]
:events [{:event :run
:once :per-turn
:req (req (and (<= 2 (:position target))
(first-event? state side :run #(<= 2 (:position (first %))))))
:msg "draw 2 cards"
:async true
:effect (effect (draw eid 2))}]})
(defcard "Dedicated Processor"
{:implementation "Click Dedicated Processor to use ability"
:req (req (not-empty (filter #(has-subtype? % "Icebreaker") (all-active-installed state :runner))))
:hosting {:card #(and (has-subtype? % "Icebreaker")
(not (has-subtype? % "AI"))
(installed? %))}
:abilities [{:cost [:credit 2]
:label "add 4 strength for the remainder of the run"
:req (req run)
:effect (effect (pump (get-card state (:host card)) 4))
:msg (msg "pump the strength of " (get-in card [:host :title]) " by 4")}]})
(defcard "Deep Red"
{:static-abilities [(caissa-mu+ 3)]
:events [{:event :runner-install
:optional
{:req (req (has-subtype? (:card context) "Caïssa"))
:prompt "Trigger the [Click] ability of the just-installed Caïssa program?"
:yes-ability
{:async true
:effect (effect
(continue-ability
(let [cid (:cid (:card context))]
{:async true
:prompt "Choose the just-installed Caïssa program"
:choices {:card #(= cid (:cid %))}
:msg (msg "trigger the [Click] ability of " (:title target)
" without spending [Click]")
:effect (req (gain-clicks state :runner 1)
(play-ability state side {:card target :ability 0})
(effect-completed state side eid))})
card nil))}}}]})
(defcard "Demolisher"
{:static-abilities [(mu+ 1)
{:type :trash-cost
:value -1}]
:events [{:event :runner-trash
:once-per-instance true
:req (req (and (corp? (:card target))
(first-event? state side :runner-trash
(fn [targets]
(some #(corp? (:card %)) targets)))))
:msg "gain 1 [Credits]"
:async true
:effect (effect (gain-credits :runner eid 1))}]})
(defcard "Desperado"
{:static-abilities [(mu+ 1)]
:events [{:event :successful-run
:silent (req true)
:async true
:msg "gain 1 [Credits]"
:effect (effect (gain-credits eid 1))}]})
(defcard "Devil Charm"
{:events [{:event :encounter-ice
:interactive (req true)
:optional
{:prompt "Remove Devil Charm from the game to give encountered ice -6 strength?"
:yes-ability
{:msg (msg "give -6 strength to " (card-str state (:ice context)) " for the remainder of the run")
:cost [:remove-from-game]
:effect (effect (register-lingering-effect
card
(let [ice (:ice context)]
{:type :ice-strength
:duration :end-of-run
:req (req (same-card? target ice))
:value -6}))
(update-all-ice))}}}]})
(defcard "Dinosaurus"
{:abilities [{:label "Install and host a non-AI icebreaker"
:req (req (empty? (:hosted card)))
:cost [:click 1]
:prompt "Choose a non-AI icebreaker in the grip"
:choices {:card #(and (has-subtype? % "Icebreaker")
(not (has-subtype? % "AI"))
(in-hand? %))}
:async true
:effect (effect (runner-install eid target {:host-card card :no-mu true}))}
{:label "Host an installed non-AI icebreaker (manual)"
:req (req (empty? (:hosted card)))
:prompt "Choose an installed non-AI icebreaker"
:choices {:card #(and (has-subtype? % "Icebreaker")
(not (has-subtype? % "AI"))
(installed? %))}
:msg (msg "host " (:title target))
:effect (effect (host card target)
(unregister-effects-for-card target #(= :used-mu (:type %)))
(update-mu))}]
:static-abilities [{:type :breaker-strength
:req (req (same-card? target (first (:hosted card))))
:value 2}]})
(defcard "Docklands Pass"
{:events [(breach-access-bonus
:hq 1
{:req (req (and (= :hq target)
(first-event? state side :breach-server #(= :hq (first %)))))
:msg "access 1 additional cards from HQ"})]})
(defcard "Doppelgänger"
{:static-abilities [(mu+ 1)]
:events [{:event :runner-install
:req (req (same-card? card (:card context)))
:silent (req true)
:effect (effect (update! (assoc card :dopp-active true)))}
{:event :runner-turn-begins
:effect (effect (update! (assoc card :dopp-active true)))}
{:event :run-ends
:interactive (req true)
:optional
{:req (req (and (:successful target)
(:dopp-active (get-card state card))))
:player :runner
:prompt "Make another run?"
:yes-ability {:prompt "Choose a server"
:async true
:choices (req runnable-servers)
:msg (msg "make a run on " target)
:makes-run true
:effect (effect (update! (dissoc card :dopp-active))
(unregister-lingering-effects :end-of-run)
(unregister-floating-events :end-of-run)
(update-all-icebreakers)
(update-all-ice)
(reset-all-ice)
(clear-wait-prompt :corp)
(make-run eid target (get-card state card)))}}}]})
(defcard "Dorm Computer"
{:flags {:forced-to-avoid-tag true}
:data {:counter {:power 4}}
:abilities [{:cost [:click 1 :power 1]
:req (req (not run))
:prompt "Choose a server"
:choices (req runnable-servers)
:msg "make a run and avoid all tags for the remainder of the run"
:makes-run true
:async true
:effect (effect (register-events
card
[{:event :pre-tag
:duration :end-of-run
:async true
:msg "avoid all tags during the run"
:effect (effect (tag-prevent :runner eid Integer/MAX_VALUE))}])
(make-run eid target card))}]})
(defcard "Dyson Fractal Generator"
{:recurring 1
:interactions {:pay-credits {:req (req (and (= :ability (:source-type eid))
(has-subtype? target "Fracter")
(has-subtype? target "Icebreaker")))
:type :recurring}}})
(defcard "Dyson Mem Chip"
{:static-abilities [(mu+ 1)
(link+ 1)]})
(defcard "DZMZ Optimizer"
{:static-abilities [(mu+ 1)
{:type :install-cost
:req (req (and (program? target)
(no-event? state :runner :runner-install #(program? (:card (first %))))))
:value -1}]
:events [{:event :runner-install
:req (req (and (program? target)
(first-event? state :runner :runner-install #(program? (first %)))))
:silent (req true)
:msg (msg "reduce the install cost of " (:title target) " by 1 [Credits]")}]})
(defcard "e3 Feedback Implants"
{:abilities [(break-sub 1 1 "All" {:req (req true)})]})
(defcard "Ekomind"
(let [update-base-mu (fn [state n] (swap! state assoc-in [:runner :memory :base] n))]
{:effect (req (update-base-mu state (count (get-in @state [:runner :hand])))
(add-watch state :ekomind (fn [_k ref old new]
(let [hand-size (count (get-in new [:runner :hand]))]
(when (not= (count (get-in old [:runner :hand])) hand-size)
(update-base-mu ref hand-size))))))
:leave-play (req (remove-watch state :ekomind))}))
(defcard "EMP Device"
{:abilities [{:req (req run)
:msg "prevent the Corp from rezzing more than 1 piece of ice for the remainder of the run"
:cost [:trash-can]
:effect (effect
(register-events
card
[{:event :rez
:duration :end-of-run
:unregister-once-resolved true
:req (req (ice? (:card context)))
:effect (effect (register-run-flag!
card :can-rez
(fn [state _side card]
(if (ice? card)
((constantly false)
(toast state :corp "Cannot rez ice the rest of this run due to EMP Device"))
true))))}]))}]})
(defcard "Endurance"
{:data {:counter {:power 3}}
:static-abilities [(mu+ 2)]
:events [{:event :successful-run
:req (req (first-event? state :runner :successful-run))
:msg "place 1 power counter on itself"
:async true
:effect (effect (add-counter eid card :power 1 nil))}]
:abilities [(break-sub [:power 2] 2 "All")]})
(defcard "Feedback Filter"
{:interactions {:prevent [{:type #{:net :brain}
:req (req true)}]}
:abilities [{:cost [:credit 3]
:msg "prevent 1 net damage"
:effect (effect (damage-prevent :net 1))}
{:label "Prevent up to 2 core damage"
:msg "prevent up to 2 core damage"
:cost [:trash-can]
:effect (effect (damage-prevent :brain 2))}]})
(defcard "Flame-out"
(let [register-flame-effect
(fn [state card]
(update! state :runner (assoc-in (get-card state card) [:special :flame-out-trigger] true)))
maybe-turn-end {:async true
:req (req (:flame-out-trigger (:special (get-card state card))))
:effect (req (update! state side (assoc-in (get-card state card) [:special :flame-out-trigger] nil))
(if-let [hosted (first (:hosted card))]
(do (system-msg state :runner (str "trashes " (:title hosted) " from Flame-out"))
(trash state side eid hosted {:cause-card card}))
(effect-completed state side eid)))}]
{:implementation "Credit usage restriction not enforced"
:data {:counter {:credit 9}}
:abilities [{:label "Take 1 hosted [Credits]"
:req (req (and (not-empty (:hosted card))
(pos? (get-counters card :credit))))
:async true
:effect (req (add-counter state side card :credit -1)
(system-msg state :runner "takes 1 hosted [Credits] from Flame-out")
(register-flame-effect state card)
(gain-credits state :runner eid 1))}
{:label "Take all hosted [Credits]"
:req (req (and (not-empty (:hosted card))
(pos? (get-counters card :credit))))
:async true
:effect (req (let [credits (get-counters card :credit)]
(update! state :runner (dissoc-in card [:counter :credit]))
(system-msg state :runner (str "takes " credits " hosted [Credits] from Flame-out"))
(register-flame-effect state card)
(gain-credits state :runner eid credits)))}
{:label "Install and host a program"
:req (req (empty? (:hosted card)))
:cost [:click 1]
:prompt "Choose a program in the grip"
:choices {:card #(and (program? %)
(in-hand? %))}
:async true
:effect (effect (update! (assoc-in (get-card state card) [:special :flame-out] (:cid target)))
(runner-install eid target {:host-card card}))}
{:label "Host an installed program (manual)"
:req (req (empty? (:hosted card)))
:prompt "Choose an installed program"
:choices {:card #(and (program? %)
(installed? %))}
:msg (msg "host " (:title target))
:effect (req (->> target
(get-card state)
(host state side card))
(update! state side (assoc-in (get-card state card) [:special :flame-out] (:cid target))))}]
:events [{:event :card-moved
:req (req (= (:cid target) (get-in (get-card state card) [:special :flame-out])))
:effect (effect (update! (dissoc-in card [:special :flame-out])))}
(assoc maybe-turn-end :event :runner-turn-ends)
(assoc maybe-turn-end :event :corp-turn-ends)]
:interactions {:pay-credits {:req (req (and (= :ability (:source-type eid))
(same-card? card (:host target))
(pos? (get-counters card :credit))))
:custom-amount 1
:custom (req (add-counter state side card :credit -1)
(register-flame-effect state card)
(effect-completed state side (make-result eid 1)))
:type :custom}}}))
(defcard "Flip Switch"
{:events [{:event :initialize-trace
:optional
{:req (req (= :runner (:active-player @state)))
:waiting-prompt true
:prompt "Trash Flip Switch to reduce the base trace strength to 0?"
:player :runner
:yes-ability {:msg "reduce the base trace strength to 0"
:cost [:trash-can]
:effect (req (swap! state assoc-in [:trace :force-base] 0))}}}]
:abilities [{:label "Jack out"
:req (req (and (or run
(get-current-encounter state))
(= :runner (:active-player @state))))
:msg "jack out"
:cost [:trash-can]
:async true
:effect (effect (jack-out eid))}
{:label "Remove 1 tag"
:req (req (and (pos? (count-real-tags state))
(= :runner (:active-player @state))))
:msg "remove 1 tag"
:cost [:trash-can]
:async true
:effect (effect (lose-tags eid 1))}]})
(defcard "Forger"
{:interactions {:prevent [{:type #{:tag}
:req (req true)}]}
:static-abilities [(link+ 1)]
:abilities [{:msg "avoid 1 tag"
:label "Avoid 1 tag"
:async true
:cost [:trash-can]
:effect (effect (tag-prevent :runner eid 1))}
{:msg "remove 1 tag"
:label "Remove 1 tag"
:cost [:trash-can]
:async true
:effect (effect (lose-tags eid 1))}]})
(defcard "Friday Chip"
(let [ability {:msg (msg "move 1 virus counter to " (:title target))
:req (req (and (pos? (get-counters card :virus))
(pos? (count-virus-programs state))))
:choices {:card virus-program?}
:effect (req (add-counter state :runner card :virus -1)
(add-counter state :runner target :virus 1))}]
{:abilities [(set-autoresolve :auto-fire "Friday Chip placing virus counters on itself")]
:events [(assoc ability :event :runner-turn-begins)
{:event :runner-trash
:once-per-instance true
:async true
:req (req (some #(corp? (:card %)) targets))
:effect (req (let [amt-trashed (count (filter #(corp? (:card %)) targets))
sing-ab {:optional
{:prompt (msg "Place a virus counter on " (:title card) "?")
:autoresolve (get-autoresolve :auto-fire)
:yes-ability {:effect (effect (system-msg
:runner
(str "uses " (:title card) " to place 1 virus counter on itself"))
(add-counter :runner card :virus 1))}}}
mult-ab {:prompt (msg "Place virus counters on " (:title card) "?")
:choices {:number (req amt-trashed)
:default (req amt-trashed)}
:effect (effect (system-msg :runner
(str "uses " (:title card) " to place "
(quantify target "virus counter")
" on itself"))
(add-counter :runner card :virus target))}
ab (if (> amt-trashed 1) mult-ab sing-ab)]
(continue-ability state side ab card targets)))}]}))
(defcard "Gachapon"
(letfn [(shuffle-end [remove-from-game shuffle-back]
{:msg (msg "shuffle " (enumerate-str (map :title shuffle-back)) " into the stack"
" and remove " (enumerate-str (map :title remove-from-game)) " from the game")
:effect (req
(doseq [c remove-from-game]
(move state side c :rfg))
(doseq [c shuffle-back]
(move state side c :deck))
(shuffle! state side :deck))})
(shuffle-next [set-aside-cards target to-shuffle]
(let [set-aside-cards (remove-once #(= % target) set-aside-cards)
to-shuffle (if target
(concat to-shuffle [target])
[])
finished? (or (= 3 (count to-shuffle))
(empty? set-aside-cards))]
{:prompt (msg (if finished?
(str "Removing: " (if (not-empty set-aside-cards)
(enumerate-str (map :title set-aside-cards))
"nothing")
"[br]Shuffling: " (if (not-empty to-shuffle)
(enumerate-str (map :title to-shuffle))
"nothing"))
(str "Choose " (- 3 (count to-shuffle)) " more cards to shuffle back."
(when (not-empty to-shuffle)
(str "[br]Currently shuffling back: " (enumerate-str (map :title to-shuffle)))))))
:async true
:not-distinct true ; show cards separately
:choices (req (if finished?
["Done" "Start over"]
(seq set-aside-cards)))
:effect (req (if finished?
(if (= "Done" target)
(continue-ability state side
(shuffle-end set-aside-cards to-shuffle)
card nil)
(continue-ability state side
(shuffle-next (sort-by :title (concat set-aside-cards to-shuffle)) nil nil)
card nil))
(continue-ability state side
(shuffle-next set-aside-cards target to-shuffle)
card nil)))}))]
{:abilities [{:label "Install a card from among the top 6 cards of the stack"
:cost [:trash-can]
:async true
:waiting-prompt true
:effect (req (set-aside state side eid (take 6 (:deck runner)))
(let [set-aside-cards (sort-by :title (get-set-aside state side eid))]
(system-msg state side (str "uses " (get-title card)
" to set aside "
(enumerate-str (map get-title set-aside-cards))
" from the top of the stack"))
(wait-for (resolve-ability state side
{:async true
:prompt (str "The set aside cards are: "
(enumerate-str (map get-title set-aside-cards)))
:choices ["OK"]}
card nil)
(continue-ability
state side
{:prompt "Choose a card to install"
:async true
:choices (req (concat
(filter #(and (or (program? %)
(and (resource? %)
(has-subtype? % "Virtual")))