/
ys.js
2464 lines (2423 loc) · 72.3 KB
/
ys.js
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
//make it a class so we can reset
function Game () {
this.me = new Player(true);
this.op = new Player(false);
this.hist = []; //array of strings (spells that YS played)
this.summon = function (f,m){
if (f) this.me.board.add(m);
else this.op.board.add(m);
}
this.kill = function (f,s){
if (f) this.me.board.kill(this,s);
else this.op.board.kill(this,s);
}
}
//f = "friendly": boolean (true = me, false = opponent)
function Player (f) {
this.name = f? "Me": "Opponent";
this.me = f;
this.hp = 30;
this.maxhp = 30;
this.armor = 0;
this.atk = 0; //HERO atk (not total)
this.weap = 0; //WEAPON atk
this.dur = 0; //weapon durability
this.maxmana = 10; //total mana crystals
this.mana = 10; //full crystals
this.deck = 10; //cards left in deck
this.fat = 1; //next fatigue damage
this.hand = []; //array of strings
this.secrets = []; //array of strings
this.board = new Board(f);
this.notes = [];
this.frozen = false;
this.cs = false; //commanding shout 1.2
this.damage = function (i, game) {
if (i < 1) return;
var temp = this.armor;
this.armor -= i;
i -= temp;
if (this.armor < 0) this.armor = 0;
if (i > 0){
this.hp -= i;
//check death externally
}
}
this.heal = function (i) {
this.hp += i;
if (this.hp > this.maxhp) this.hp = this.maxhp;
}
this.addHand = function (s) {
if (this.hand.length < 10) this.hand.push(s);
}
this.discardRand = function () {
var i = random(this.hand.length-1);
this.hand.splice(i,1);
}
this.addSecret = function (s) {
if (this.secrets.length < 5 && this.secrets.indexOf(s) == -1) this.secrets.push(s);
}
this.drawx = function (x) {
while (x--) this.draw();
}
this.draw = function (msg) {
if (!msg) msg = "";
if (this.deck > 0){
this.deck--;
this.addHand("[Drawn from deck"+msg+"]");
}
else {
//fatigue
this.damage(this.fat,null);
this.fat++;
}
}
this.addManaEmpty = function (i){
this.maxmana += i;
if (this.maxmana > 10) this.maxmana = 10;
}
this.addManaFull = function (i){
this.addManaEmpty(i);
this.mana += i;
if (this.mana > 10) this.mana = 10;
}
//"duck typing"
this.isMinion = false;
this.isPlayer = true;
this.id = -1;
}
function Board (f) {
this.friend = f; //friendly or enemy board
this.mins = []; //array of minions
this.size = function(){
return this.mins.length;
}
//returns true if was able to add minion, false otherwise
this.add = function (m) {
if (this.mins.length < 7){
m.friend = this.friend;
m.slot = this.mins.length;
this.mins.push(m);
return true;
}
else return false;
}
this.kill = function (game,s) {
var m = this.mins[s];
this.mins.splice(s,1);
this.updateSlots();
m.die(game);
}
this.updateSlots = function () {
var i = this.mins.length;
while (i--){
this.mins[i].slot = i;
this.mins[i].friend = this.friend;
}
}
}
var nextId = 1;
//n = name: string
//a,h = attack,health: int
function Minion (n,a,h) {
this.name = n;
this.id = nextId++;
this.origatk = a; //needed for silence
this.orighp = h;
this.atk = a; //current
this.hp = h; //current
this.maxhp = h;
//with these ^ shouldn't need to track buff number
//these will be set when added to board
this.friend = false;
this.slot = -1;
this.tribe = "";
this.notes = []; // notes like blessing of wisdom, etc (and deathrattles, temp!)
this.taunt = false;
this.divine = false;
this.charge = false;
this.immune = false; //assume that Yogg can target Immune creatures
this.wind = false;
this.stealth = false;
this.frozen = false;
//extra stuff
this.leokk = false;
this.igb = false; //imp gang boss
this.ds = false; //dreadsteed
this.tk = false; //tiny knight of evil
this.wg = false; //wrathguard
this.origtaunt = false; //feral spirits, etc
this.origcharge = false; //huffer, etc
//deathrattles:
// Ancestral Spirit Give a minion "Deathrattle: Resummon this minion."
this.as = 0;
// Soul of the Forest Give your minions "Deathrattle: Summon a 2/2 Treant."
this.sf = 0;
// Explorer's Hat Give a minion +1/+1 and "Deathrattle: Add an Explorer's Hat to your hand."
this.eh = 0;
// Infest Give your minions: "Deathrattle: Add a random Beast to your hand"
this.sp = 0;
//can manipulate atk directly
this.buffhp = function (i) { //for double just pass in this.hp
this.maxhp += i;
this.hp += i;
}
this.silence = function () {
var full = false;
if (this.maxhp == this.hp) full = true;
this.atk = this.origatk;
this.maxhp = this.orighp;
if (this.hp > this.maxhp) this.hp = this.maxhp; //I'm pretty sure this is right
if (full) this.hp = this.maxhp; //1.2.2
this.notes = []; // notes like blessing of wisdom, etc (and deathrattles, temp!)
this.taunt = false;
this.divine = false;
this.immune = false;
this.charge = false;
this.wind = false;
this.stealth = false;
this.frozen = false;
this.as = 0;
this.sf = 0;
this.eh = 0;
this.sp = 0;
}
this.damage = function (i, game) {
if (i < 1 || this.immune) return;
if (this.divine) {
this.divine = false;
return;
}
this.hp -= i;
if (this.hp < 1) {
//1.2
var who = game.me;
if (!this.friend) who = game.op;
if (who.cs) this.hp = 1;
else this.kill(game);
}
}
this.heal = function (i) {
this.hp += i;
if (this.hp > this.maxhp) this.hp = this.maxhp;
}
this.kill = function (game) {
game.kill(this.friend,this.slot);
}
this.die = function (game) {
//"deathrattles"
while (this.as > 0) { //IMPERFECT
var m = new Minion(this.name,this.origatk,this.orighp);
if (this.origtaunt) m.taunt = true;
if (this.origcharge) m.charge = true;
m.tribe = this.tribe;
game.summon(this.friend,m);
this.as--;
}
while (this.sf > 0) {
game.summon(this.friend, new Minion("Treant",2,2));
this.sf--;
}
while (this.eh > 0) {
var c = "Explorer's Hat";
if (this.friend) game.me.addHand(c);
else game.op.addHand(c);
this.eh--;
}
while (this.sp > 0) {
var c = "[Random Beast]";
if (this.friend) game.me.addHand(c);
else game.op.addHand(c);
this.sp--;
}
}
this.cardText = function () {
var ret = "<b>" + this.name + "</b>";
if (this.taunt) ret += "<br>Taunt";
if (this.immune) ret += "<br>Immune";
if (this.divine) ret += "<br>Divine Shield";
if (this.charge) ret += "<br>Charge";
if (this.wind) ret += "<br>Windfury";
if (this.stealth) ret += "<br>Stealth";
if (this.frozen) ret += "<br>Frozen";
return ret;
}
this.getNotes = function () {
var ret = this.notes.slice(0);
if (this.as > 0) ret.push("Ancestral Spirit"+(this.as > 1? " ("+this.as+")": ""));
if (this.sf > 0) ret.push("Soul of the Forest"+(this.sf > 1? " ("+this.sf+")": ""));
if (this.eh > 0) ret.push("Explorer's Hat"+(this.eh > 1? " ("+this.eh+")": ""));
if (this.sp > 0) ret.push("[Add Random Beast]"+(this.sp > 1? " ("+this.sp+")": ""));
return ret;
}
//"duck typing"
this.isMinion = true;
this.isPlayer = false;
}
////////////////////////////////
//random helpers
//passing 1 argument rolls from 0-arg
function random(min, max){
if (max === undefined){
max = min;
min = 0;
}
if (min > max){
var temp = min;
min = max;
max = temp;
}
else if (max == min) return min;
return Math.floor(Math.random()*(max-min+1)+min);
}
//50/50 true/false
function flip(){
return !random(1);
}
//for now, just flip
function joust(){
return flip();
}
////////////////////////////////
//chooser helpers
//returns a random minion from either side
function aminion(game){
var both = game.me.board.size() + game.op.board.size();
if (both == 0) return null;
var i = random(both-1);
if (i < game.me.board.size()){
return game.me.board.mins[i];
}
else{
i -= game.me.board.size();
return game.op.board.mins[i];
}
}
//random enemy minion
function enemyminion(game){
if (game.op.board.size() == 0) return null;
return game.op.board.mins[random(game.op.board.size()-1)];
}
//random friendly minion
function myminion(game){
if (game.me.board.size() == 0) return null;
return game.me.board.mins[random(game.me.board.size()-1)];
}
//random enemy character
//BE CAREFUL WITH THE OBJECT RETURNED FROM THIS (or check isPlayer/isMinion)
function enemy(game){
var both = game.op.board.size() + 1;
var i = random(both-1);
if (i < game.op.board.size()){
return game.op.board.mins[i];
}
else return game.op;
}
//random friendly character
//BE CAREFUL WITH THE OBJECT RETURNED FROM THIS (or check isPlayer/isMinion)
function friendly(game){
var both = game.me.board.size() + 1;
var i = random(both-1);
if (i < game.me.board.size()){
return game.me.board.mins[i];
}
else return game.me;
}
//random friendly character
//BE CAREFUL WITH THE OBJECT RETURNED FROM THIS (or check isPlayer/isMinion)
function character(game){
var both = game.me.board.size() + game.op.board.size();
var i = random(both+2-1);
if (i < game.me.board.size()){
return game.me.board.mins[i];
}
i -= game.me.board.size();
if (i < game.op.board.size()){
return game.op.board.mins[i];
}
i -= game.op.board.size();
if (i) return game.me;
else return game.op;
}
function dotoenemymins(game, f){
var pointers = [];
for (var i=0; i<game.op.board.size(); i++){
pointers.push(game.op.board.mins[i]);
}
var i = pointers.length;
while (i--){
f(pointers[i]);
}
}
function dotomymins(game, f){
var pointers = [];
for (var i=0; i<game.me.board.size(); i++){
pointers.push(game.me.board.mins[i]);
}
var i = pointers.length;
while (i--){
f(pointers[i]);
}
}
function dotoallmins(game, f){
dotomymins(game, f);
dotoenemymins(game, f);
}
function remove(game,friend,slot){
var m = null;
if (friend){
m = game.me.board.mins.splice(slot,1)[0];
game.me.board.updateSlots();
}
else{
m = game.op.board.mins.splice(slot,1)[0];
game.op.board.updateSlots();
}
return m;
}
function replace(game,friend,slot,m){
var who = game.me;
if (!friend) who = game.op;
who.board.mins[slot] = m;
who.board.updateSlots();
}
//f is a function that takes a minion and returns bool
//returns array of mins that match f
function matchmins(game,friend,enemy,f){
if (!friend && !enemy) return [];
var ret = [];
if (friend) {
dotomymins(game, function (m) {
if (f(m)) ret.push(m);
});
}
if (enemy) {
dotoenemymins(game, function (m) {
if (f(m)) ret.push(m);
});
}
return ret;
}
//looks at friend/slot minion and runs f on adjacent mins
//f is a function that takes a minion
function dotoadj(game,friend,slot,f){
var who = game.me;
if (!friend) who = game.op;
var m1 = null;
var m2 = null;
if (who.board.size()-1 >= slot+1) m1 = who.board.mins[slot+1];
if (slot-1 >= 0 && who.board.size()-1 >= slot-1) m2 = who.board.mins[slot-1];
if (m1) f(m1);
if (m2) f(m2);
}
function trackRandDam(log,add){
if (!(add in log)) log[add] = 0;
log[add]++;
}
function randLogToString(log){
var s = [];
for (k in log) {
var v = log[k];
s.push(k+" for "+v);
}
return s.join(", ");
}
////////////////////////////////
//all "effect" functions return a string that will be logged in history
var spells = [
{name:"Ancestral Healing",effect: function(game){
//Restore a minion to full Health and give it Taunt.
var m = aminion(game);
if (!m) return this.name + " fizzled";
var h = m.maxhp - m.hp ;
m.heal(h);
m.taunt = true;
return this.name + " healed "+(m.friend? "my ": "opponent's ")+m.name+" for "+h+" and gave it Taunt";
}},
{name:"Ancestral Knowledge",effect: function(game){
//Draw 2 cards.
game.me.drawx(2);
return this.name + " drew 2 cards";
}},
{name:"Ancestral Spirit",effect: function(game){
//Give a minion "Deathrattle: Resummon this minion."
var m = aminion(game);
if (!m) return this.name + " fizzled";
m.as++;
return this.name + " on "+(m.friend? "my ": "opponent's ")+m.name;
}},
{name:"Animal Companion",effect: function(game){
//Summon a random Beast Companion.
if (game.me.board.size() > 6) return this.name + " fizzled";
var i = random(2);
var m = new Minion("Misha",4,4);
m.taunt = true;
if (i == 1){
m = new Minion("Huffer",4,2);
m.charge = true;
}
else if (i == 2){
m = new Minion("Leokk",2,4); //IMPERFECT
m.leokk = true;
}
m.tribe = "Beast";
game.summon(true, m);
return this.name + " summoned "+m.name;
}},
{name:"Anyfin Can Happen",effect: function(game){
//Summon 7 Murlocs that died this game.
if (game.me.board.size() > 6) return this.name + " fizzled";
var n = random(1,6);//IMPERFECT
var count = n;
while (n--){
var m = new Minion("Murloc Raider",2,1);
switch(random(11)){
case 0:
break;
case 1:
m = new Minion("Murloc Warleader",3,3); //IMPERFECT
break;
case 2:
m = new Minion("Murloc Tidehunter",2,1); //IMPERFECT
break;
case 3:
m = new Minion("Murloc Knight",3,4);
break;
case 4:
m = new Minion("Murloc Tidecaller",1,2);
break;
case 5:
m = new Minion("Murloc Tinyfin",1,1);
break;
case 6:
m = new Minion("Grimscale Oracle",1,1); //IMPERFECT
break;
case 7:
m = new Minion("Coldlight Oracle",2,2);
break;
case 8:
m = new Minion("Bluegill Warrior",2,1);
m.charge = true;
break;
case 9:
m = new Minion("Old Murk-Eye",2,4); //IMPERFECT
m.charge = true;
break;
case 10:
m = new Minion("Coldlight Seer",2,3);
break;
case 11:
m = new Minion("Sir Finley Mrrgglton",1,3);
break;
}
game.summon(true,m);
}
return this.name + " summoned "+count;
}},
{name:"Arcane Blast",effect: function(game){
//Deal 2 damage to a minion. This spell gets double bonus from Spell Damage.
var m = aminion(game);
if (!m) return this.name + " fizzled";
m.damage(2,game);
return this.name + " damaged "+(m.friend? "my ": "opponent's ")+m.name+" for 2";
}},
{name:"Arcane Explosion",effect: function(game){
//Deal 1 damage to all enemy minions.
dotoenemymins(game, function (m) {
m.damage(1,game);
});
return this.name;
}},
{name:"Arcane Intellect",effect: function(game){
//Draw 2 cards.
game.me.drawx(2);
return this.name + " drew 2 cards";
}},
{name:"Arcane Missiles",effect: function(game){
//Deal 3 damage randomly split among all enemies.
//1.2
var log = {};
var i = 3;
while (i--){
var c = enemy(game);
c.damage(1,game);
trackRandDam(log,(c.isPlayer? "": c.friend? "my ": "opponent's ")+c.name);
}
return this.name + " damaged: "+randLogToString(log);
}},
{name:"Arcane Shot",effect: function(game){
//Deal 2 damage.
var c = character(game);
c.damage(2,game);
return this.name + " damaged "+(c.isPlayer? "": c.friend? "my ": "opponent's ")+c.name+" for 2";
}},
{name:"Assassinate",effect: function(game){
//Destroy an enemy minion.
var m = enemyminion(game);
if (!m) return this.name + " fizzled";
m.kill(game);
return this.name + " killed "+(m.friend? "my ": "opponent's ")+m.name;
}},
{name:"Astral Communion",effect: function(game){
//Gain 10 Mana Crystals. Discard your hand.
game.me.hand = [];
//1.2
var excess = false;
if (game.me.maxmana == 10) {
excess = true;
game.me.addHand("Excess Mana");
}
else {
game.me.addManaFull(10);
game.me.mana = 10;
}
if (excess) return this.name + " gave Excess Mana";
else return this.name + " added Mana Crystals";
}},
{name:"Avenging Wrath",effect: function(game){
//Deal 8 damage randomly split among all enemies.
//1.2
var log = {};
var i = 8;
while (i--){
var c = enemy(game);
c.damage(1,game);
trackRandDam(log,(c.isPlayer? "": c.friend? "my ": "opponent's ")+c.name);
}
return this.name + " damaged: "+randLogToString(log);
}},
{name:"Backstab",effect: function(game){
//Deal 2 damage to an undamaged minion.
var mins = matchmins(game,true,true, function (m) {
return m.hp == m.maxhp;
});
var l = mins.length;
if (l == 0) return this.name + " fizzled";
var m = mins[random(l-1)];
m.damage(2,game);
return this.name + " damaged "+(m.friend? "my ": "opponent's ")+m.name+" for 2";
}},
{name:"Ball of Spiders",effect: function(game){
//Summon three 1/1 Webspinners.
if (game.me.board.size() > 6) return this.name + " fizzled";
var i = 3;
while (i--){
var m = new Minion("Webspinner",1,1);
m.tribe = "Beast";
m.sp++;
game.summon(true,m);
}
return this.name + " summoned Webspinners";
}},
{name:"Bane of Doom",effect: function(game){
//Deal 2 damage to a character. If that kills it, summon a random Demon.
var c = character(game);
c.damage(2,game);
var sumn = false;
if (c.hp < 1 && game.me.board.size() < 7){
var sumn = true;
var demons = [];
var m = new Minion("Flame Imp",3,2);
m.tribe = "Demon";
demons.push(m);
m = new Minion("Tiny Knight of Evil",3,2);
m.tk = true;
m.tribe = "Demon";
demons.push(m);
m = new Minion("Dreadsteed",1,1);
m.ds = true;
m.tribe = "Demon";
demons.push(m);
m = new Minion("Pit Lord",5,6);
m.tribe = "Demon";
demons.push(m);
m = new Minion("Voidwalker",1,3);
m.taunt = true;
m.tribe = "Demon";
demons.push(m);
m = new Minion("Imp Gang Boss",2,4);
m.igb = true;
m.tribe = "Demon";
demons.push(m);
m = new Minion("Dread Infernal",6,6);
m.tribe = "Demon";
demons.push(m);
m = new Minion("Void Crusher",5,4);
m.tribe = "Demon";
demons.push(m);
m = new Minion("Blood Imp",0,1);
m.stealth = true;
m.tribe = "Demon";
demons.push(m);
m = new Minion("Illidan Stormrage",7,5);
m.tribe = "Demon";
demons.push(m);
m = new Minion("Wrathguard",4,3);
m.wg = true;
m.tribe = "Demon";
demons.push(m);
m = new Minion("Fearsome Doomguard",6,8);
m.tribe = "Demon";
demons.push(m);
m = new Minion("Doomguard",5,7);
m.charge = true;
m.tribe = "Demon";
demons.push(m);
m = new Minion("Void Terror",3,3);
m.tribe = "Demon";
demons.push(m);
m = new Minion("Succubus",4,3);
m.tribe = "Demon";
demons.push(m);
m = new Minion("Lord Jaraxxus",3,15);
m.tribe = "Demon";
demons.push(m);
m = new Minion("Felguard",3,5);
m.taunt = true;
m.tribe = "Demon";
demons.push(m);
var n = demons[random(demons.length-1)];
game.summon(true,n);
}
return this.name + " damaged "+(c.isPlayer? "": c.friend? "my ": "opponent's ")+c.name+" for 2"+(sumn? " and summoned "+n.name: "");
}},
{name:"Bash",effect: function(game){
//Deal 3 damage. Gain 3 Armor.
var c = character(game);
c.damage(3,game);
game.me.armor += 3;
return this.name + " damaged "+(c.isPlayer? "": c.friend? "my ": "opponent's ")+c.name+" for 3 and I gained 3 Armor";
}},
{name:"Battle Rage",effect: function(game){
//Draw a card for each damaged friendly character.
var i = 0;
if (game.me.hp < game.me.maxhp) i++; //1.2
dotomymins(game, function (m) {
if (m.hp < m.maxhp) i++;
});
game.me.drawx(i);
return this.name + " drew "+i+" cards";
}},
{name:"Bear Trap",effect: function(game){
//Secret
game.me.addSecret(this.name); return this.name;
}},
{name:"Beneath the Grounds",effect: function(game){
//Shuffle 3 Ambushes into your opponent's deck
game.op.deck += 3; //IMPERFECT?
return this.name;
}},
{name:"Bestial Wrath",effect: function(game){
//Give a friendly Beast +2 Attack and Immune this turn.
var mins = matchmins(game,true,false, function (m) {
return m.tribe == "Beast";
});
var l = mins.length;
if (l == 0) return this.name + " fizzled";
var m = mins[random(l-1)];
m.atk += 2;
m.immune = true;
return this.name + " on "+(m.friend? "my ": "opponent's ")+m.name;
}},
{name:"Betrayal",effect: function(game){
//Force an enemy minion to deal its damage to the minions next to it.
var n = enemyminion(game);
if (!n) return this.name + " fizzled";
dotoadj(game,false,n.slot, function (m) {
m.damage(n.atk,game);
});
return this.name + " damaged "+(n.friend? "my ": "opponent's ")+n.name+"'s adjacent minions for "+n.atk;
}},
{name:"Bite",effect: function(game){
//Give your hero +4 Attack this turn and 4 Armor.
game.me.armor += 4;
game.me.atk += 4;
return this.name;
}},
{name:"Blade Flurry",effect: function(game){
//Destroy your weapon and deal its damage to all enemies.
if (game.me.dur < 1) return this.name + " fizzled";
var d = game.me.weap;
game.me.weap = 0;
game.me.dur = 0;
dotoenemymins(game, function (m) {
m.damage(d,game);
});
return this.name + " for "+d;
}},
{name:"Blessed Champion",effect: function(game){
//Double a minion's Attack.
var m = aminion(game);
if (!m) return this.name + " fizzled";
m.atk *= 2;
return this.name + " doubled "+(m.friend? "my ": "opponent's ")+m.name+"'s Attack";
}},
{name:"Blessing of Kings",effect: function(game){
//Give a minion +4/+4.
var m = aminion(game);
if (!m) return this.name + " fizzled";
m.atk += 4;
m.buffhp(4);
return this.name + " on "+(m.friend? "my ": "opponent's ")+m.name;
}},
{name:"Blessing of Might",effect: function(game){
//Give a minion +3 Attack.
var m = aminion(game);
if (!m) return this.name + " fizzled";
m.atk += 3;
return this.name + " on "+(m.friend? "my ": "opponent's ")+m.name;
}},
{name:"Blessing of Wisdom",effect: function(game){
//Choose a minion. Whenever it attacks, draw a card.
var m = aminion(game);
if (!m) return this.name + " fizzled";
m.notes.push(this.name);
return this.name + " on "+(m.friend? "my ": "opponent's ")+m.name;
}},
{name:"Blizzard",effect: function(game){
//Deal 2 damage to all enemy minions and Freeze them.
dotoenemymins(game, function (m) {
m.damage(2,game);
m.frozen = true;
});
return this.name;
}},
{name:"Bloodlust",effect: function(game){
//Give your minions +3 Attack this turn.
dotomymins(game, function (m) {
m.atk += 3;
});
return this.name;
}},
{name:"Bolster",effect: function(game){
//Give your Taunt minions +2/+2.
dotomymins(game, function (m) {
if (m.taunt){
m.atk += 2;
m.buffhp(2);
}
});
return this.name;
}},
{name:"Brawl",effect: function(game){
//Destroy all minions except one.
var both = game.me.board.size() + game.op.board.size();
if (both < 2) return this.name + " fizzled";
var n = aminion(game); //1.2
dotoallmins(game, function (m) {
if (m.id == n.id) return;
m.kill(game);
});
return this.name + " left only "+(n.friend? "my ": "opponent's ")+n.name+" alive";
}},
{name:"Burgle",effect: function(game){
//Add 2 random class cards to your hand (from your opponent's class).
game.me.addHand("[Burgled]");
game.me.addHand("[Burgled]");
return this.name;
}},
{name:"Charge",effect: function(game){
//Give a friendly minion +2 Attack and Charge.
var m = myminion(game);
if (!m) return this.name + " fizzled";
m.atk += 2;
m.charge = true;
return this.name + " on "+(m.friend? "my ": "opponent's ")+m.name;
}},
{name:"Circle of Healing",effect: function(game){
//Restore 4 Health to ALL minions.
dotoallmins(game, function (m) {
m.heal(4);
});
return this.name;
}},
{name:"Claw",effect: function(game){
//Give your hero +2 Attack this turn and 2 Armor.
game.me.armor += 2;
game.me.atk += 2;
return this.name;
}},
{name:"Cleave",effect: function(game){
//Deal 2 damage to two random enemy minions.
if (game.op.board.size() < 2) return this.name + " fizzled";
var a = random(game.op.board.size()-1);
var b = a;
while (b == a) b = random(game.op.board.size()-1);
var m1 = null;
var m2 = null;
dotoenemymins(game, function (m) {
if (m.slot == a) m1 = m;
if (m.slot == b) m2 = m;
});
m1.damage(2,game);
m2.damage(2,game);
return this.name + " damaged opponent's "+m1.name+" and "+m2.name+" for 2";
}},
{name:"Cold Blood",effect: function(game){
//Give a minion +2 Attack
var m = aminion(game);
if (!m) return this.name + " fizzled";
m.atk += 2;
return this.name + " on "+(m.friend? "my ": "opponent's ")+m.name;
}},
{name:"Commanding Shout",effect: function(game){
//Your minions can't be reduced below 1 Health this turn. Draw a card.
game.me.notes.push(this.name);
game.me.cs = true; //1.2
game.me.draw();
return this.name;
}},
{name:"Competitive Spirit",effect: function(game){
//Secret
game.me.addSecret(this.name); return this.name;
}},
{name:"Conceal",effect: function(game){
//Give your minions Stealth until your next turn.
dotomymins(game, function (m) {
m.stealth = true;
});
return this.name;
}},
{name:"Cone of Cold",effect: function(game){
//Freeze a minion and the minions next to it, and deal 1 damage to them.
var n = aminion(game);
if (!n) return this.name + " fizzled";
dotoadj(game,n.friend,n.slot, function (m) {
m.damage(1,game);
m.frozen = true;
});
n.damage(1,game);
n.frozen = true;
return this.name + " on "+(n.friend? "my ": "opponent's ")+n.name+" and adjacent minions";
}},
{name:"Confuse",effect: function(game){
//Swap the Attack and Health of all minions.
dotoallmins(game, function (m) {
var temp = m.hp;
m.hp = m.atk;
m.maxhp = m.atk;
m.atk = temp;
if (m.hp < 1) m.kill(game); //1.2
});
return this.name;
}},
{name:"Consecration",effect: function(game){
//Deal 2 damage to all enemies.
dotoenemymins(game, function (m) {
m.damage(2,game);
});
game.op.damage(2,null);
return this.name;
}},
{name:"Convert",effect: function(game){
//Put a copy of an enemy minion into your hand.
var m = enemyminion(game);
if (!m) return this.name + " fizzled";
game.me.addHand(m.name);
return this.name + " added a copy of "+m.name;
}},
{name:"Corruption",effect: function(game){
//Choose an enemy minion. At the start of your turn, destroy it.
var m = enemyminion(game);
if (!m) return this.name + " fizzled";
m.notes.push(this.name);
return this.name + " on opponent's "+m.name;
}},
{name:"Counterspell",effect: function(game){
//Secret
game.me.addSecret(this.name); return this.name;
}},
{name:"Curse of Rafaam",effect: function(game){
//Give your opponent a 'Cursed!' card.
game.op.addHand("Cursed!");
return this.name;
}},
{name:"Dark Bargain",effect: function(game){
//Destroy 2 random enemy minions. Discard 2 random cards
if (game.op.board.size() < 2) return this.name + " fizzled";
var i = 2;
var mins = "";
while (i--){
var s = random(game.op.board.size()-1);
var m = game.op.board.mins[s];
if (mins.length == 0) mins += m.name + " and ";
else mins += m.name;
game.kill(false,s);
}
game.me.discardRand();
game.me.discardRand();
return this.name + " on opponent's "+mins+" and discarded 2";
}},
{name:"Dart Trap",effect: function(game){
//Secret
game.me.addSecret(this.name); return this.name;
}},
{name:"Deadly Poison",effect: function(game){
//Give your weapon +2 Attack.
if (game.me.dur < 1) return this.name + " fizzled";
game.me.weap += 2;
return this.name;
}},
{name:"Deadly Shot",effect: function(game){