-
Notifications
You must be signed in to change notification settings - Fork 25
/
spells.lua
10064 lines (9432 loc) · 287 KB
/
spells.lua
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
local tinymaids = require("tinymaids")
local floor,ceil,min,max = math.floor, math.ceil, math.min, math.max
local abs = math.abs
local random = math.random
local new_student_orientation = function(player, opponent, my_idx, my_card)
local target_idxs = shuffle(player:field_idxs_with_preds({pred.follower,
pred.faction[my_card.faction]}))
local buff = OnePlayerBuff(player)
for i=1,2 do
if target_idxs[i] then
buff[target_idxs[i]] = {atk={"+",2},sta={"+",2}}
end
end
buff:apply()
end
local court_jester = function(group_pred)
return function(player, opponent, my_idx, my_card)
local target_idxs = shuffle(player:field_idxs_with_preds({pred.follower,
pred.faction[my_card.faction]}))
local group_idxs = player:field_idxs_with_preds({pred.follower,
pred.faction[my_card.faction], group_pred})
if #group_idxs ~= 0 and #group_idxs ~= #target_idxs then
local buff = OnePlayerBuff(player)
for i=1,2 do
buff[target_idxs[i]] = {atk={"+",3},sta={"+",3}}
end
buff:apply()
end
end
end
local sitas_suit = function(group_pred)
return function(player, opponent, my_idx, my_card)
local amt = 2
for _,tar_pred in ipairs({pred[my_card.faction], group_pred}) do
local target_idxs = shuffle(player:field_idxs_with_preds({pred.follower,
tar_pred}))
local buff = OnePlayerBuff(player)
--print("Sita's suit found "..#target_idxs.." followers")
for i=1,2 do
if target_idxs[i] then
buff[target_idxs[i]] = {atk={"+",amt},sta={"+",amt}}
end
end
buff:apply()
amt = amt - 1
end
end
end
local halloween = function(player, opponent)
local target = opponent:hand_idxs_with_preds(pred.spell, pred.neg(pred.halloween))[1]
local slot = player:first_empty_field_slot()
if target and slot then
player.field[slot] = Card(opponent.hand[target].id)
end
end
spell_func = {
-- heartless blow
[200001] = function(player, opponent)
local first_dmg = 4
local second_dmg = 2
if #player:field_idxs_with_preds() <= #player.opponent:field_idxs_with_preds() then
first_dmg = 5
second_dmg = 3
end
local target_idxs = shuffle(opponent:field_idxs_with_preds({pred.follower}))
if target_idxs[1] then
OneBuff(opponent, target_idxs[1], {sta={"-",first_dmg}}):apply()
end
if pred.sita(player.character) then
if target_idxs[2] then
target_idxs[1] = target_idxs[2]
end
if target_idxs[1] and opponent.field[target_idxs[1]] then
OneBuff(opponent, target_idxs[1], {sta={"-",second_dmg}}):apply()
end
end
end,
-- new student orientation
[200002] = new_student_orientation,
-- cooking failure
[200003] = function(player)
if #player:field_idxs_with_preds({pred.cook_club}) > 0 then
local target_idxs = shuffle(player:field_idxs_with_preds({pred.follower, pred.faction.V}))
local buff = OnePlayerBuff(player)
local atk_up, sta_up = 1,2
if #target_idxs >= 2 and
pred.cook_club(player.field[target_idxs[1]]) and
pred.cook_club(player.field[target_idxs[2]]) then
atk_up, sta_up = 2,3
end
for i=1,min(2,#target_idxs) do
buff[target_idxs[i]] = {atk={"+",atk_up},def={"+",1},sta={"+",sta_up},size={"+",1}}
end
buff:apply()
end
end,
-- ward rupture
[200004] = function(player, opponent)
local card, other_card = player.field[3], opponent.field[3]
if card and other_card and pred.faction.V(card) and pred.follower(card) then
local amount = abs(card.size - other_card.size)
OneBuff(player, 3, {atk={"+",amount},def={"+",amount},sta={"+",amount}}):apply()
end
end,
-- new recipe
[200005] = function(player)
OneBuff(player,0,{life={"+",bound(0,8-player:field_size(),5)}}):apply()
end,
-- shrink
[200006] = function(player, opponent)
local target_idx = opponent:field_idxs_with_most_and_preds(
pred.size, {pred.follower})[1]
if target_idx then
local card = opponent.field[target_idx]
OneBuff(opponent,target_idx,{sta={"=",floor(card.sta/2)},
atk={"=",floor(card.atk/2)},def={"=",floor(card.def/2)},
size={"=",floor(card.size/2)}}):apply()
end
end,
-- balance
[200007] = function(player, opponent)
if abs(player.character.life - opponent.character.life) <= 20 then
-- set life equal
local buff = GlobalBuff(player)
local new_life = ceil((player.character.life + opponent.character.life)/2)
buff.field[player][0] = {life={"=",new_life}}
buff.field[opponent][0] = {life={"=",new_life}}
buff:apply()
-- send cards to grave
local more_stuff,less_stuff = player, opponent
if less_stuff:ncards_in_field() > more_stuff:ncards_in_field() then
more_stuff,less_stuff = less_stuff,more_stuff
end
while less_stuff:ncards_in_field() < more_stuff:ncards_in_field() do
more_stuff:field_to_grave(more_stuff:field_idxs_with_preds({})[1])
end
-- discard cards from hand
local hand_pred = pred.t
if pred.faction.V(player.character) then
hand_pred = pred.follower
end
for i=1,#player.hand do
while player.hand[i] and hand_pred(player.hand[i]) do
player:hand_to_grave(i)
end
end
end
end,
-- rumored order
[200008] = function(player)
local target_idx = player:field_idxs_with_most_and_preds(pred.size,
{pred.faction.V, pred.follower})[1]
if target_idx then
OneBuff(player,target_idx,{size={"-",2},sta={"+",2}}):apply()
end
end,
-- omnivore
[200009] = function(player)
local target_idxs = shuffle(player:field_idxs_with_preds(pred.follower))
local sizes = {}
local buff_amount = 1
for i=1,#player.hand do
if not sizes[player.hand[i].size] then
sizes[player.hand[i].size] = true
buff_amount = buff_amount + 1
end
end
if #target_idxs > 0 then
local buff = OnePlayerBuff(player)
for i=1,min(#target_idxs,2) do
buff[target_idxs[i]] = {sta={"+",buff_amount}}
end
buff:apply()
end
end,
-- volcano
[200010] = function(player, opponent)
local target_idx = uniformly(opponent:field_idxs_with_preds(pred.follower))
if target_idx then
local x = #player:hand_idxs_with_preds(pred.faction.V, pred.follower)
OneBuff(opponent, target_idx, {atk={"-",x},def={"-",x},sta={"-",x}}):apply()
end
end,
-- accident
[200011] = function(player, opponent)
local debuff_amount = #player:field_idxs_with_preds({pred.maid,pred.follower})
local target_idxs = shuffle(opponent:field_idxs_with_preds(pred.follower))
local def_amt = 0
if debuff_amount == 2 then
def_amt = 1
end
local buff = OnePlayerBuff(opponent)
for i=1,min(2,#target_idxs) do
buff[target_idxs[i]] = {atk={"-",debuff_amount},def={"-",def_amt},sta={"-",debuff_amount}}
end
buff:apply()
end,
-- new maid training
[200012] = new_student_orientation,
-- she did it
[200013] = function(player)
if #player:field_idxs_with_preds({pred.maid,pred.follower}) > 0 then
local buff = OnePlayerBuff(player)
local target_idxs = player:field_idxs_with_preds(pred.follower)
local reduced_amount = 0
for _,idx in ipairs(target_idxs) do
reduced_amount = reduced_amount + player.field[idx].size - 1
buff[idx] = {size={"=",1}}
end
buff:apply()
local target_idx = uniformly(target_idxs)
local atk_amt = 0
if pred.maid(player.field[target_idx]) then
atk_amt = floor(reduced_amount/2)
end
OneBuff(player,target_idx,{size={"+",reduced_amount},
sta={"+",floor(reduced_amount/2)}, atk={"+",atk_amt}}):apply()
end
end,
-- noble sacrifice
[200014] = function(player)
local target_idx = player:field_idxs_with_most_and_preds(pred.size,
{pred.follower, pred.faction.A})[1]
if target_idx then
local life_gain = player.field[target_idx].size*2
player:field_to_grave(target_idx)
OneBuff(player,0,{life={"+",min(life_gain,9)}}):apply()
end
end,
-- tighten security
[200015] = function(player)
local target_idx = player:field_idxs_with_preds({pred.faction.A, pred.follower})[1]
if target_idx then
local buff = GlobalBuff(player)
local def_amt = #(player:hand_idxs_with_preds({pred.faction.A}))
local other_amt = ceil(abs(def_amt - player.field[target_idx].def)/2)
buff.field[player][target_idx] = {def={"=", def_amt},atk={"+", other_amt},
sta={"+", other_amt}}
buff:apply()
end
end,
-- bondage
[200016] = function(player, opponent)
local buff = OnePlayerBuff(opponent)
local target_idxs = shuffle(opponent:field_idxs_with_preds(pred.follower))
for i=1,min(3,#target_idxs) do
buff[target_idxs[i]] = {size={"+",1}}
end
buff:apply()
end,
-- curse
[200017] = function(player, opponent)
if player.character.faction == "A" then
local debuff = GlobalBuff(player)
local tar1, tar2 = unpack(shuffled(
opponent:field_idxs_with_preds({pred.follower})))
for _,idx in ipairs({tar1,tar2}) do
debuff.field[opponent][idx] = {atk={"-",2},sta={"-",2}}
end
debuff:apply()
end
end,
-- swap spell
[200018] = function(player, opponent)
local card = player.field[3]
local idx = opponent:field_idxs_with_preds(pred.follower)[1]
if card and pred.follower(card) and idx then
local other_card = opponent.field[idx]
local buff = GlobalBuff(player)
buff.field[player][3],buff.field[opponent][idx] = {},{}
for _,stat in ipairs({"atk","def","sta","size"}) do
buff.field[player][3][stat] = {"=",other_card[stat]}
buff.field[opponent][idx][stat] = {"=",card[stat]}
end
buff:apply()
end
end,
-- mass recall
[200019] = function(player, opponent)
for i=1,5 do
if opponent.field[i] and opponent.field[i].size <= 3 then
opponent:field_to_grave(i)
end
if player.field[i] and player.field[i].faction ~= "A" then
player:field_to_grave(i)
end
end
end,
-- forced entry
[200020] = function(player, opponent)
if player.field[3] and opponent.field[3] then
if player.field[3].size < opponent.field[3].size then
player:destroy(3)
elseif player.field[3].size > opponent.field[3].size then
opponent:destroy(3)
else
opponent:field_to_grave(3)
end
end
end,
-- saint's blessing
[200021] = function(player)
local target_idxs = player:field_idxs_with_preds(pred.C, pred.follower)
local buff = OnePlayerBuff(player)
for _,idx in ipairs(target_idxs) do
buff[idx] = {sta={"+",3}}
if pred.luthica(player.character) then
buff[idx].atk = {"+",3}
end
end
buff:apply()
end,
-- close encounter
[200022] = new_student_orientation,
-- entry denied
[200023] = function(player, opponent)
local my_idx = player:field_idxs_with_preds({pred.follower})[1]
local other_idx = opponent:field_idxs_with_most_and_preds(
pred.size, {pred.follower})[1]
if my_idx then
player.field[my_idx].active = false
OneBuff(player,my_idx,{atk={"+",3}}):apply()
end
if my_idx and other_idx then
opponent.field[other_idx].active = false
OneImpact(opponent, other_idx):apply()
end
end,
-- healing magic
[200024] = function(player)
OneBuff(player, 0, {life = {"+", #player.hand}}):apply()
end,
-- sky surprise
[200025] = function(player, opponent)
local old_idx = player:get_follower_idxs()[1]
local new_idx = opponent:first_empty_field_slot()
if old_idx and new_idx then
local card = player.field[old_idx]
opponent.field[new_idx] = card
player.field[old_idx] = nil
card.active = false
OneBuff(opponent, 0, {life={"-",ceil(card.size/2)}}):apply()
OneBuff(opponent, new_idx, {size={"=",1}}):apply()
end
end,
-- meadow leisure
[200026] = function(player)
local target_idx = uniformly(player:field_idxs_with_preds(pred.follower))
if target_idx then
local ncards = player:ncards_in_field()
OneBuff(player, target_idx, {atk={"+",ncards-1},sta={"+",ncards+1}}):apply()
end
end,
-- knight's letter
[200027] = function(player, opponent)
if player:ncards_in_field() == opponent:ncards_in_field() then
local target_idxs = shuffle(opponent:field_idxs_with_preds())
for i=1,min(2,#target_idxs) do
opponent:field_to_bottom_deck(target_idxs[i])
end
end
end,
-- shield break
[200028] = function(player, opponent)
local target_idx = opponent:field_idxs_with_most_and_preds(pred.def,pred.follower)[1]
if target_idx then
local def = opponent.field[target_idx].def
if def > 0 then
OneBuff(opponent,target_idx,{def={"-",2*def}}):apply()
end
end
end,
-- sentry's testimony
[200029] = function(player)
local knight_idxs = player:grave_idxs_with_preds(pred.follower, pred.knight)
local target_idx = uniformly(player:field_idxs_with_preds(pred.follower))
if target_idx then
OneBuff(player,target_idx,{atk={"+",#knight_idxs},sta={"+",#knight_idxs}}):apply()
end
for i = #player.grave, 1, -1 do
player:grave_to_exile(i)
end
end,
-- pacifism
[200030] = function(player, opponent)
local buff = OnePlayerBuff(player)
for i=1,5 do
if player.field[i] and pred.follower(player.field[i]) then
player.field[i].active = false
if pred.faction.C(player.field[i]) then
buff[i]={size={"-",1},atk={"+",2},sta={"+",2}}
end
end
if opponent.field[i] then
opponent.field[i].active = false
end
end
buff:apply()
end,
-- flina's command
[200031] = function(player)
local target_idxs = shuffle(player:field_idxs_with_preds({pred.faction.D, pred.follower}))
local buff = OnePlayerBuff(player)
for i=1,2 do
if target_idxs[i] then
buff[target_idxs[i]] = {sta={"+",3}}
end
end
buff:apply()
local target_idxs2 = shuffle(player:field_idxs_with_preds({pred.follower}))
local buff2 = OnePlayerBuff(player)
for i=1,2 do
if target_idxs2[i] then
buff2[target_idxs2[i]] = {atk={"+",1}}
end
end
buff2:apply()
end,
-- blood reversal
[200032] = new_student_orientation,
-- vampiric rites
[200033] = function(player)
local idxs = player:get_follower_idxs()
local debuff= GlobalBuff(player)
local buff_stats = {sta={"+",0}, atk={"+",0}, size={"+",0}}
for _,idx in ipairs(idxs) do
local card = player.field[idx]
local debuff_stats = {sta={"-", card.sta-1}, size={"-", card.size-1}}
debuff.field[player][idx] = debuff_stats
if player.field[idx].atk > 0 then
debuff_stats.atk = {"-", player.field[idx].atk - 1}
end
for k,v in pairs(debuff_stats) do
buff_stats[k][2] = buff_stats[k][2] + debuff_stats[k][2]
end
end
local target_idx = player:field_idxs_with_least_and_preds(
pred.size, {pred.follower, pred.faction.D})[1]
debuff:apply()
if target_idx then
local buff = GlobalBuff(player)
buff.field[player][target_idx] = buff_stats
buff:apply()
end
end,
-- blood target
[200034] = function(player)
local target_idx = player:field_idxs_with_preds({pred.follower,pred.faction.D})[1]
if target_idx then
local life = min(10,player.field[target_idx].sta-1)
local buff = OnePlayerBuff(player)
buff[target_idx] = {sta={"=",1}, atk={"+",min(floor(life/2),3)}}
buff[0] = {life = {"+",life}}
buff:apply()
end
end,
-- sacrifice
[200035] = function(player, opponent)
local buff = GlobalBuff(player)
buff.field[player][0] = {life={"-",1}}
buff.field[opponent][0] = {life={"-",4}}
buff:apply()
end,
-- full moon power
[200036] = function(player)
local targets = player:field_idxs_with_preds(pred.follower,
pred.union(pred.scardel, pred.crescent, pred.flina))
local buff = OnePlayerBuff(player)
for _,idx in ipairs(targets) do
buff[idx] = {atk={"+",3}}
end
buff:apply()
end,
-- pass the blood
[200037] = function(player)
local card = player.field[3]
if card and pred.follower(card) and pred.faction.D(card) then
local def = 0
for i=1,5 do
if player.field[i] and pred.follower(player.field[i]) then
def = def + player.field[i].def
end
end
def = min(def,5)
OneBuff(player,3,{atk={"+",def},sta={"+",def}}):apply()
end
end,
-- overwhelm
[200038] = function(player,opponent)
local life = opponent.character.life
local buff = OnePlayerBuff(opponent)
for i=1,5 do
if opponent.field[i] and pred.follower(opponent.field[i]) and
opponent.field[i].sta + opponent.field[i].def > life then
buff[i]={def={"-",floor(life/2)}}
end
end
buff:apply()
end,
-- forced confinement
[200039] = function(player, opponent)
local target = opponent:field_idxs_with_most_and_preds(pred.sta,pred.follower)[1]
if player.character.faction == "D" and target then
OneBuff(player,0,{life={"-",ceil(opponent.field[target].size/2)}}):apply()
opponent:field_to_bottom_deck(target)
end
end,
-- evil eye
[200040] = function(player,opponent)
local idxs = opponent:field_idxs_with_preds(pred.follower)
local buff = OnePlayerBuff(opponent)
for _,idx in ipairs(idxs) do
buff[idx] = {atk={"-",2},def={"-",2}}
if pred.faction.D(player.character) then
buff[idx].sta={"-",2}
end
end
buff:apply()
-- this card is actually supposed to be able to kill something
-- with the first clause, then check the 2nd clause against the new
-- number of followers!
local idxs = opponent:field_idxs_with_preds(pred.follower)
if #idxs <= 2 then
local buff = OnePlayerBuff(opponent)
for _,idx in ipairs(idxs) do
buff[idx] = {atk={"-",1},def={"-",1}}
end
buff:apply()
end
end,
-- student council justice
[200041] = function(player, opponent)
local n_council = #player:field_idxs_with_preds({pred.follower, pred.student_council})
local n_vita = #player:field_idxs_with_preds({pred.follower, pred.faction.V})
if n_council > 0 then
local targets = shuffle(opponent:field_idxs_with_preds(pred.follower))
local buff = OnePlayerBuff(opponent)
for i=1,min(2,#targets) do
if n_vita == 1 then
buff[targets[i]] = {atk={"-",2}}
elseif n_vita == 2 then
buff[targets[i]] = {sta={"-",3}}
elseif n_vita >= 3 then
buff[targets[i]] = {atk={"-",2},def={"-",1},sta={"-",2}}
end
end
buff:apply()
end
end,
-- student council kick
[200042] = function(player, opponent)
local kicker = player:field_idxs_with_preds({pred.follower, pred.active, pred.student_council})[1]
local target = opponent:field_idxs_with_most_and_preds(pred.size, pred.follower)[1]
if kicker then
player.field[kicker].active = false
if target then
-- TODO: can this spell heal the enemy follower??
OneBuff(opponent, target, {sta={"-",player.field[kicker].atk + 1}}):apply()
end
end
end,
-- book thief
[200043] = function(player, opponent)
local nlibrarians = #player:field_idxs_with_preds({pred.follower, pred.library_club})
local spells = opponent:field_idxs_with_preds(pred.spell)
local new_idx = player:first_empty_field_slot()
if nlibrarians >= #spells and new_idx then
local old_idx = uniformly(spells)
if old_idx then
player.field[new_idx] = opponent.field[old_idx]
opponent.field[old_idx] = nil
end
end
end,
-- tower of books
[200044] = function(player, opponent)
local nvita = #player:field_idxs_with_preds({pred.follower, pred.faction.V})
local spell = opponent:hand_idxs_with_preds({pred.spell,
function(card) return card.size < 3 end})[1]
if spell and nvita > 0 then
local buff = GlobalBuff(player)
buff.hand[opponent][spell] = {size={"+",nvita}}
buff:apply()
end
end,
-- empowering chant
[200045] = function(player, opponent)
local card = player.field[2]
if card and card.type == "follower" then
OneBuff(player,2,{atk={"+",2},sta={"+",5}}):apply()
if player.character.faction ~= "V" then
card.skills = {}
end
end
end,
-- feast
[200046] = function(player, opponent)
if pred.sita(player.character) then
OneBuff(player,0,{life={"+",4}}):apply()
end
end,
-- reunion
[200047] = function(player, opponent)
local maxsize = #player.hand
if player.character.faction == "V" then
maxsize = maxsize + 1
end
local old_idx = uniformly(opponent:field_idxs_with_preds({pred.follower,
function(card) return card.size <= maxsize end}))
local new_idx = player:first_empty_field_slot()
if old_idx and new_idx then
player.field[new_idx] = opponent.field[old_idx]
opponent.field[old_idx] = nil
OneBuff(player,new_idx,{size={"-",1}}):apply()
end
end,
-- unwilling sacrifice
[200048] = function(player, opponent)
local sac = player:field_idxs_with_least_and_preds(pred.sta, pred.follower, pred.A)[1]
if sac then
local sta = player.field[sac].sta
player:field_to_grave(sac)
local target = opponent:field_idxs_with_preds({pred.follower,
function(card) return card.atk > sta end})[1]
if target then
OneBuff(opponent,target,{atk={"-",sta}}):apply()
end
end
end,
-- shoddy magic
[200049] = function(player, opponent)
local targets = shuffle(opponent:field_idxs_with_preds(pred.follower))
local buff = OnePlayerBuff(opponent)
for i=1,min(#targets,2) do
buff[targets[i]] = {sta={"-",uniformly({2,4})}}
end
buff:apply()
end,
-- lineage maintenance
[200050] = function(player, opponent)
local buff = OnePlayerBuff(player)
for i=1,5 do
local card = player.field[i]
if card and pred.faction.A(card) and pred.follower(card) and
card.size == i then
buff[i] = {atk={"+",3},sta={"+",3}}
end
end
buff:apply()
end,
-- magic stone found
[200051] = function(player, opponent)
local idx = player:hand_idxs_with_preds(pred.faction.A)[1]
if idx then
player:hand_to_grave(idx)
local targets = shuffle(opponent:field_idxs_with_preds(pred.follower))
local buff = OnePlayerBuff(opponent)
for i=1,min(#targets,2) do
buff[targets[i]] = {atk={"-",1},def={"-",2}}
end
buff:apply()
end
end,
-- magic summit invite
[200052] = function(player, opponent)
local target = player:field_idxs_with_preds({pred.follower, pred.faction.A})[2]
local first = player.field[1]
if target and first and pred.follower(first) then
OneBuff(player,target,{def={"=",first.def},sta={"=",first.sta}}):apply()
end
end,
-- sister's letter
[200053] = function(player, opponent)
local targets = opponent:field_idxs_with_most_and_preds(pred.size,pred.follower)
local buff = OnePlayerBuff(opponent)
for _,idx in ipairs(targets) do
buff[idx] = {atk={"-",idx},def={"-",idx},sta={"-",idx}}
end
buff:apply()
end,
-- dark secret
-- note: it does nothing if sizes are equal...
[200054] = function(player, opponent)
local fake = {size = 0}
local larger = opponent.field[2] or fake
local smaller = opponent.field[4] or fake
local lidx, sidx = 2, 4
if smaller.size > larger.size then
smaller, larger = larger, smaller
sidx, lidx = lidx, sidx
end
if larger.size ~= smaller.size then
if larger ~= fake then
if pred.faction.A(player.character) then
opponent:destroy(lidx)
else
opponent:field_to_grave(lidx)
end
end
if smaller ~= fake then
if pred.faction.A(player.character) then
opponent:field_to_grave(sidx)
else
opponent:field_to_bottom_deck(sidx)
end
end
end
end,
-- no turning back
[200055] = function(player, opponent)
local idx1 = uniformly(player:field_idxs_with_preds(pred.follower))
local idx2 = uniformly(opponent:field_idxs_with_preds(pred.follower))
if idx1 then
if opponent:field_size() % 2 == 1 then
if idx2 then
OneImpact(opponent, idx2):apply()
opponent:destroy(idx2)
end
else
OneImpact(player, idx1):apply()
player:field_to_grave(idx1)
end
end
end,
-- sense of belonging
[200056] = function(player, opponent)
local old_idx = uniformly(opponent:field_idxs_with_preds(pred.follower,
function(card) return card.faction ~= opponent.character.faction end))
local new_idx = player:first_empty_field_slot()
if old_idx and new_idx then
OneImpact(opponent, old_idx):apply()
player.field[new_idx] = opponent.field[old_idx]
opponent.field[old_idx] = nil
player.field[new_idx].active = false
end
end,
-- study of miracles
[200057] = function(player, opponent)
local targets = player:field_idxs_with_preds({pred.follower, pred.seeker})
local buff = OnePlayerBuff(player)
for _,idx in ipairs(targets) do
buff[idx] = {atk={"+",2},sta={"+",1}}
end
buff:apply()
end,
-- proof of miracles
[200058] = function(player, opponent)
local ncards = #player.hand
local target = uniformly(player:field_idxs_with_preds({pred.follower,pred.faction.C}))
local buff = OnePlayerBuff(player)
buff[0] = {life={"-",floor(ncards/2)}}
if target then
buff[target] = {atk={"+",ncards},sta={"+",ncards}}
end
buff:apply()
end,
-- quick service
[200059] = function(player, opponent)
local followers = player:field_idxs_with_preds(pred.follower)
for _,idx in ipairs(followers) do
player:field_to_grave(idx)
end
-- TODO: does this pick first or at random?
local target = player:hand_idxs_with_preds({pred.follower, pred.faction.C,
function(card) return card.size <= #followers + 2 end })[1]
if target and player.field[4] == nil then
local card = player:remove_from_hand(target)
player.field[4] = card
local buff_size = ceil(#player:grave_idxs_with_preds(pred.faction.C) / 2)
OneBuff(player, 4, {atk={"+",buff_size},sta={"+",buff_size}}):apply()
end
end,
-- mother demon rumor
[200060] = function(player, opponent)
local fake = {size=0}
local card1 = opponent.field[1] or fake
local card2 = opponent.field[2]
if card2 and card1.size + card2.size >= 6 then
OneImpact(opponent, 2):apply()
opponent:destroy(2)
end
end,
-- luthica's ward
[200061] = function(player, opponent)
local amt = 0
for i=1,4 do
local idx = uniformly(player:grave_idxs_with_preds())
if idx then
player:grave_to_exile(idx)
amt = amt + 1
end
end
local targets = shuffle(player:field_idxs_with_preds(pred.follower))
local buff = OnePlayerBuff(player)
for i=1,min(#targets,2) do
if pred.C(player.field[targets[i]]) then
buff[targets[i]] = {atk={"+",2*amt},sta={"+",2*amt}}
else
buff[targets[i]] = {atk={"+",2+amt},sta={"+",2+amt}}
end
end
buff:apply()
end,
-- spell change
[200062] = function(player, opponent)
local my_idx = player:hand_idxs_with_preds(pred.spell)[1]
local other_idx = opponent:hand_idxs_with_preds(pred.spell)[1]
if my_idx and other_idx then
player.hand[my_idx], opponent.hand[other_idx] =
opponent.hand[other_idx], player.hand[my_idx]
end
end,
-- prank's price
[200063] = function(player, opponent)
if #player.hand >= 2 and #opponent.hand >= 2 then
player:hand_to_grave(1)
player:hand_to_grave(1)
opponent:hand_to_grave(1)
opponent:hand_to_grave(1)
end
end,
-- strega blood
[200064] = function(player, opponent)
local targets = player:field_idxs_with_preds({pred.follower, pred.witch})
local buff = OnePlayerBuff(player)
for _,idx in ipairs(targets) do
buff[idx] = {atk={"+",1}, sta={"+",3}}
end
buff[0] = {life={"-",1}}
buff:apply()
end,
-- strega blade
[200065] = function(player, opponent)
local witch = player:field_idxs_with_least_and_preds(pred.size,
{pred.follower, pred.witch})[1]
if witch then
local buff = GlobalBuff(player)
-- TODO: determine whether this card can increase atk.
local reduced_amount = player.field[witch].sta-1
buff.field[player][witch] = {sta={"=",1}}
if player.field[witch].atk > 0 then
reduced_amount = reduced_amount + player.field[witch].atk-1
buff.field[player][witch].atk = {"=",1}
end
local target = opponent:field_idxs_with_preds(pred.follower)[1]
if target then
buff.field[opponent][target] = {sta={"-",math.ceil(reduced_amount / 2)}}
end
buff:apply()
end
end,
-- tower visitor
[200066] = function(player, opponent)
local big_idx = player:field_idxs_with_most_and_preds(pred.size,
{pred.follower, pred.faction.D})[1]
if big_idx then
local cutoff = player.field[big_idx].size
local targets = opponent:field_idxs_with_preds({pred.follower,
function(card) return card.size < cutoff end})
local buff = OnePlayerBuff(opponent)
for _,idx in ipairs(targets) do
buff[idx] = {def={"-",2},sta={"-",2}}
end
buff:apply()
end
end,
-- vampiric education
[200067] = function(player, opponent)
local total_size = 0
for i=1,#player.hand do
total_size = total_size + player.hand[i].size
end
local targets = shuffle(player:field_idxs_with_preds({pred.follower, pred.faction.D}))
local buff = OnePlayerBuff(player)
for i=1,min(#targets,2) do
buff[targets[i]] = {sta={"+",ceil(total_size/2)}}
end
buff:apply()
end,
-- fatal blow
[200068] = function(player, opponent)
local maxsize = #player.hand + player:ncards_in_field()
local life = 0
for i=1,5 do
if player.field[i] and player.field[i].size <= maxsize then
player:field_to_grave(i)
end
if opponent.field[i] and opponent.field[i].size <= maxsize then
opponent:field_to_grave(i)
life = life + 1
end
end
OneBuff(player,0,{life={"-",life}}):apply()
end,
-- good job
[200069] = function(player, opponent)
local buff = GlobalBuff(player)
for i=1,5 do
if player.field[i] and pred.follower(player.field[i]) then
buff.field[player][i] = {atk = {"+",1}}
end
if opponent.field[i] and pred.follower(opponent.field[i]) then
buff.field[opponent][i] = {atk = {"+",1}}
end
end
buff:apply()
end,
-- thank you
[200070] = function(player, opponent)
local buff = GlobalBuff(player)
for i=1,5 do
if player.field[i] and pred.follower(player.field[i]) then
buff.field[player][i] = {def = {"+",1}}
end
if opponent.field[i] and pred.follower(opponent.field[i]) then
buff.field[opponent][i] = {def = {"+",1}}
end
end
buff:apply()
end,
-- pleased to meet you
[200071] = function(player, opponent)