<commit_before>"use strict";
var ui = require("./uiutil");
function adrenathrottle(f){
	return function(c){
		if ((c.status.adrenaline || 0)<3 || (c instanceof etg.Creature && c.owner.weapon && c.owner.weapon.status.nothrottle)){
			return f.apply(null, arguments);
		}
	}
}
var Actives = {
ablaze:function(c,t){
	Effect.mkText("2|0", c);
	c.atk += 2;
},
abomination:function(c,t,data){
	if (data.tgt == c && data.active == Actives.mutation){
		Actives.improve(c, c);
		data.evade = true;
	}
},
acceleration:function(c,t){
	Effect.mkText("2|-1", c);
	c.atk += 2;
	c.dmg(1, true);
},
accelerationspell:function(c,t){
	t.lobo();
	t.active.auto = Actives.acceleration;
},
accretion:function(c,t){
	Actives.destroy(c, t);
	c.buffhp(15);
	if (c.truehp() > 45){
		c.die();
		if (c.owner.hand.length < 8){
			new etg.CardInstance(c.card.as(Cards.BlackHole), c.owner).place();
		}
	}
},
accumulation:function(c,t){
	return c.status.charges;
},
adrenaline:function(c,t){
	Effect.mkText("Adrenaline", t);
	t.status.adrenaline = 1;
},
aether:function(c,t){
	Effect.mkText("1:12", c);
	c.owner.spend(etg.Aether, -1);
},
aflatoxin:function(c,t){
	Effect.mkText("Aflatoxin", t);
	t.addpoison(2);
	if (!(t instanceof etg.Player)){
		t.status.aflatoxin = true;
	}
},
aggroskele:function(c,t){
	new etg.Creature(c.card.as(Cards.Skeleton), c.owner).place();
	var dmg = c.owner.creatures.reduce(function(dmg, cr){
		return cr && cr.card.isOf(Cards.Skeleton) ?
			dmg + cr.trueatk() : dmg;
	}, 0);
	Effect.mkText("-"+dmg, t);
	t.dmg(dmg);
},
air:function(c,t){
	Effect.mkText("1:9", c);
	c.owner.spend(etg.Air, -1);
},
alphawolf:function(c,t){
	var pwolf = c.card.as(Cards.PackWolf);
	new etg.Creature(pwolf, c.owner).place();
	new etg.Creature(pwolf, c.owner).place();
},
antimatter:function(c,t){
	Effect.mkText("Antimatter", t);
	t.atk -= t.trueatk()*2;
},
appease:function(c,t){
	Actives.devour(c, t);
	c.status.appeased = true;
},
atk2hp:function(c,t){
	t.buffhp(t.trueatk()-t.hp);
},
axe:function(c,t){
	return c.owner.mark == etg.Fire || c.owner.mark == etg.Time?1:0;
},
axedraw:function(c,t){
	c.defstatus("dive", 0);
	c.status.dive++;
},
bblood:function(c,t){
	Effect.mkText("0|20", t);
	t.buffhp(20);
	t.delay(6);
},
becomearctic:function(c,t){
	c.transform(c.card.as(Cards.ArcticSquid));
},
beguile:function(c,t){
	t.remove();
	t.owner = t.owner.foe;
	t.place();
	if (c != t){
		t.addactive("turnstart", Actives.beguilestop);
	}
},
beguilestop:function(c,t){
	if (t == c.owner){
		c.rmactive("turnstart", "beguilestop");
		Actives.beguile(c, c);
	}
},
blackhole:function(c,t){
	if (!t.sanctuary){
		for (var q=1; q<13; q++){
			c.owner.dmg(-Math.min(t.quanta[q],3));
			t.quanta[q] = Math.max(t.quanta[q]-3,0);
		}
	}
},
bless:function(c,t){
	Effect.mkText("3|3", t);
	t.atk += 3;
	t.buffhp(3);
},
bolsterintodeck:function(c,t){
	c.owner.deck.push(t.card, t.card, t.card);
},
boneyard:function(c,t){
	if (!t.card.isOf(Cards.Skeleton)){
		new etg.Creature(c.card.as(Cards.Skeleton), c.owner).place();
	}
},
bow:function(c,t){
	return c.owner.mark == etg.Air || c.owner.mark == etg.Light?1:0;
},
bounce:function(c,t){
	if (c.owner.hand.length < 8) {
		new etg.CardInstance(c.card, c.owner).place();
		c.remove();
		return true;
	}
},
bravery:function(c,t){
	if (!c.owner.foe.sanctuary){
		for(var i=0; i<2 && c.owner.hand.length<8 && c.owner.foe.hand.length<8; i++){
			c.owner.drawcard();
			c.owner.foe.drawcard();
		}
	}
},
brew:function(c,t){
	Effect.mkText("Brew", c);
	new etg.CardInstance(c.card.as(Cards.Codes[etg.AlchemyList[c.owner.uptoceil(12)]]), c.owner).place();
},
brokenmirror:function(c,t, fromhand){
	if (fromhand && t instanceof etg.Creature && c.owner != t.owner){
		new etg.Creature(c.card.as(Cards.Phantom), c.owner).place();
	}
},
burrow:function(c,t){
	c.status.burrowed = true;
	delete c.status.airborne;
	c.active.cast = Actives.unburrow;
	c.cast = 0;
},
butterfly:function(c,t){
	t.lobo();
	t.active.cast = Actives.destroy;
	t.cast = 3;
	t.castele = etg.Entropy;
},
catapult:function(c,t){
	Effect.mkText("Catapult", t);
	t.die();
	c.owner.foe.dmg(Math.ceil(t.truehp()*(t.status.frozen?150:100)/(t.truehp()+100)));
	if (t.status.poison){
		c.owner.foe.addpoison(t.status.poison);
	}
	if (t.status.frozen){
		c.owner.foe.freeze(3);
	}
},
catlife:function(c,t, data){
	if (!c.owner.creatures[data.index] && c.status.lives > 0){
		c.status.lives--;
		Effect.mkText(c.status.lives + " lives");
		var cl = c.clone(c.owner);
		cl.hp = cl.maxhp = c.card.health;
		cl.atk = c.card.attack;
		c.owner.creatures[data.index] = cl;
	}
},
cell:function(c,t){
	c.transform(c.card.as(Cards.MalignantCell));
},
chimera:function(c,t){
	var atk=0, hp=0;
	c.owner.creatures.forEach(function(cr){
		if (cr){
			atk += cr.trueatk();
			hp += cr.truehp();
		}
	});
	var chim = new etg.Creature(c.card, c.owner);
	chim.atk = atk;
	chim.maxhp = chim.hp = hp;
	chim.active = {};
	chim.status.momentum = true;
	c.owner.creatures[0] = chim;
	c.owner.creatures.length = 1;
	c.owner.creatures.length = 23;
	c.owner.gpull = chim;
},
clear:function(c,t){
	Effect.mkText("Clear", t);
	delete t.status.poison;
	delete t.status.adrenaline;
	delete t.status.aflatoxin;
	delete t.status.momentum;
	delete t.status.psion;
	if (t.status.delayed > 0){
		t.status.delayed--;
	}
	if (t.status.frozen > 0){
		t.status.frozen--;
	}
	t.dmg(-1);
	if (t.hasactive("turnstart", "beguilestop")){
		Actives.beguilestop(t, t.owner);
	}
},
corpseexplosion:function(c,t){
	t.die();
	c.owner.foe.masscc(c, function(c,t){ t.spelldmg(1) }, !c.card.upped);
	var poison = (t.status.poison || 0) + (t.status.poisonous ? 1 : 0);
	if (poison){
		c.owner.foe.addpoison(poison);
	}
},
counter:function(c,t){
	if (!c.status.frozen && !c.status.delayed){
		t.dmg(c.trueatk());
	}
},
cpower:function(c,t){
	var buff = t.owner.upto(25);
	t.buffhp(Math.floor(buff/5)+1);
	t.atk += buff%5+1;
},
cseed:function(c,t){
	Actives[c.owner.choose(["drainlife", "firebolt", "freeze", "gpullspell", "icebolt", "infect", "lightning", "lobotomize", "parallel", "rewind", "snipe", "swave"])](c, t);
},
dagger:function(c){
	return (c.owner.mark == etg.Darkness||c.owner.mark == etg.Death) + c.owner.isCloaked();
},
darkness:function(c){
	c.owner.spend(etg.Darkness, -1);
},
deadalive:function(c){
	c.deatheffect(c.getIndex());
},
deathwish:function(c,t, data){
	var tgt = data.tgt, active = data.active;
	if (!tgt || c.status.frozen || c.status.delayed || c.owner == t.owner || tgt.owner != c.owner || !(tgt instanceof etg.Creature) || !Cards.Targeting[active.activename[0]](t, c)) return;
	if (!tgt.hasactive("spell", "deathwish")) return data.tgt = c;
	var totaldw = 0;
	c.owner.creatures.forEach(function(cr){
		if (cr && cr.hasactive("spell", "deathwish"))totaldw++;
	});
	if (c.owner.rng() < 1/totaldw){
		return data.tgt = c;
	}
},
decrsteam:function(c){
	c.defstatus("steamatk", 0);
	if (c.status.steamatk > 0){
		c.atk--;
		c.status.steamatk--;
	}
},
deckblast:function(c,t){
	c.owner.foe.spelldmg(Math.ceil(c.owner.deck.length/c.owner.deckpower));
	c.owner.deck.length = 0;
},
deja:function(c,t){
	delete c.active.cast;
	Actives.parallel(c, c);
},
deployblobs:function(c,t){
	var blob = c.card.as(Cards.Blob);
	for(var i=0; i<3; i++){
		new etg.Creature(blob, c.owner).place();
	}
	c.atk -= 2;
	c.dmg(2);
},
destroy:function(c,t, dontsalvage, donttalk){
	if (!donttalk){
		Effect.mkText("Destroy", t);
	}
	if (t.status.stackable){
		if(--t.status.charges<=0){
			t.remove();
		}
	}else t.remove();
	if (!dontsalvage){
		t.procactive("destroy", {});
	}
},
destroycard:function(c,t){
	if (!t.owner.sanctuary){
		t.die();
	}
},
devour:function(c,t){
	Effect.mkText("1|1", c);
	c.buffhp(1);
	c.atk += 1;
	if (t.status.poisonous){
		c.addpoison(1);
	}
	t.die();
},
die:function(c,t){
	c.die();
},
disarm:function(c,t){
	if (t instanceof etg.Player && t.weapon){
		Actives.unsummon(c, t.weapon);
	}
},
disc:function(c,t){
	return c.owner.mark == etg.Entropy || c.owner.mark == etg.Aether?1:0;
},
discping:function(c,t){
	t.dmg(1);
	c.remove();
	new etg.CardInstance(c.card, c.owner).place();
},
disfield:function(c,t, dmg){
	if (!c.owner.spend(etg.Chroma, dmg)){
		for(var i=1; i<13; i++){
			c.owner.quanta[i] = 0;
		}
		c.owner.shield = undefined;
	}
	return true;
},
disshield:function(c,t, dmg){
	if (!c.owner.spend(etg.Entropy, Math.ceil(dmg/3))){
		c.owner.quanta[etg.Entropy] = 0;
		c.owner.shield = undefined;
	}
	return true;
},
dive:function(c,t){
	Effect.mkText("Dive", c);
	c.defstatus("dive", 0);
	c.status.dive = c.trueatk();
},
divinity:function(c,t){
	if (c.owner.maxhp < 500){
		c.owner.maxhp = Math.min(c.owner.maxhp + 24, 500);
	}
	c.owner.dmg(-16);
},
drainlife:function(c,t){
	c.owner.dmg(-t.spelldmg(2+Math.floor(c.owner.quanta[etg.Darkness]/5)));
},
draft:function(c,t){
	Effect.mkText("Draft", t);
	c.owner.spend(etg.Air, -2);
	if((t.status.airborne = !t.status.airborne)){
		if (t.active.cast == Actives.burrow){
			delete t.active.cast;
		}
	}
},
drawcopy:function(c,t){
	if (c.owner != t.owner) new etg.CardInstance(t.card, c.owner).place();
},
dryspell:function(c,t){
	function dryeffect(c,t){
		c.spend(etg.Water, -t.spelldmg(1));
	}
	c.owner.foe.masscc(c.owner, dryeffect, true);
},
dshield:function(c,t){
	c.status.immaterial = true;
	c.addactive("turnstart", Actives.dshieldoff);
},
dshieldoff:function(c,t){
	if (c.owner == t){
		delete c.status.immaterial;
		c.rmactive("turnstart", "dshieldoff");
	}
},
duality:function(c,t){
	if (c.owner.foe.deck.length > 0 && c.owner.hand.length < 8){
		new etg.CardInstance(c.owner.foe.deck[c.owner.foe.deck.length-1], c.owner).place();
	}
},
earth:function(c,t){
	Effect.mkText("1:4", c);
	c.owner.spend(etg.Earth, -1);
},
earthquake:function(c,t){
	Effect.mkText("Earthquake", t);
	if (t.status.charges>3){
		t.status.charges -= 3;
	}else{
		t.remove();
	}
	t.procactive("destroy", {});
},
elf:function(c,t,data){
	if (data.tgt == c && data.active == Actives.cseed){
		c.transform(c.card.as(Cards.FallenElf));
		data.evade = true;
	}
},
empathy:function(c,t){
	var healsum = c.owner.countcreatures();
	Effect.mkText("+"+healsum, c);
	c.owner.dmg(-healsum);
	if (!c.owner.spend(etg.Life, Math.floor(healsum/8))){
		c.owner.quanta[etg.Life] = 0;
		c.die();
	}
},
enchant:function(c,t){
	Effect.mkText("Enchant", t);
	t.status.immaterial = true;
},
endow:function(c,t){
	Effect.mkText("Endow", t);
	for (key in t.status) {
		if (typeof t.status[key] == "boolean")
			c.status[key] = c.status[key] || t.status[key]
		else if (typeof t.status[key] == "number")
			c.status[key] = t.status[key] + (c.status[key] ? c.status[key] : 0);
		else
			c.status[key] = t.status[key];
	}
 	if (c.status.adrenaline > 1)
		c.status.adrenaline = 1;
	c.active = etg.clone(t.active);
	c.cast = t.cast;
	c.castele = t.castele;
	if (c.active.cast && c.active.cast == Actives.endow) {
		delete c.active.cast;
	}
	c.atk += t.trueatk();
	if (t.active.buff){
		c.atk -= t.active.buff(t);
	}
	c.buffhp(2);
},
envenom:function(c,t){
	t.addactive("hit", etg.parseActive("poison 1"));
},
epidemic:function(c,t){
	if (t.status.poison){
		c.owner.foe.addpoison(t.status.poison);
	}
},
epoch:function(c,t){
	if (++c.status.epoch > 1) Actives.silence(c, t.owner);
},
epochreset:function(c,t){
	c.status.epoch = 0;
},
evolve:function(c,t){
	c.transform(c.card.as(Cards.Shrieker));
	delete c.status.burrowed;
},
feed:function(c,t){
	t.addpoison(1);
	etg.parseActive("growth 3")(c);
	delete c.status.immaterial;
},
fickle:function(c,t){
	if (t.owner != c.owner && t.owner.sanctuary){
		return;
	}
	var cards = [];
	t.owner.deck.forEach(function(card, i){
		var cost = card.cost;
		if (!card.element || card.element == c.castele) cost += c.cast;
		if (t.owner.canspend(card.costele, cost)){
			cards.push(i);
		}
	});
	if (cards.length > 0){
		var pick = t.owner.choose(cards);
		t.owner.hand[t.getIndex()] = new etg.CardInstance(t.owner.deck[pick], t.owner);
		t.owner.deck[pick] = t.card;
	}
},
fiery:function(c,t){
	return Math.floor(c.owner.quanta[etg.Fire]/5);
},
fire:function(c,t){
	Effect.mkText("1:6", c);
	c.owner.spend(etg.Fire, -1);
},
firebolt:function(c,t){
	t.spelldmg(3+Math.floor(c.owner.quanta[etg.Fire]/4));
	if (t instanceof etg.Player){
		if (t.weapon){
			t.weapon.status.frozen = 0;
		}
	}else{
		t.status.frozen = 0;
	}
},
flatline:function(c,t){
	if (!c.owner.foe.sanctuary){
		c.owner.foe.flatline = true;
	}
},
flyself:function(c,t){
	Actives[c instanceof etg.Weapon ? "flyingweapon" : "livingweapon"](c, c);
},
flyingweapon:function(c,t){
	var cr = new etg.Creature(t.card, t.owner);
	cr.atk = t.atk;
	cr.active = etg.clone(t.active);
	cr.cast = t.cast;
	cr.castele = t.castele;
	cr.status = etg.clone(t.status);
	cr.status.airborne = true;
	cr.usedactive = t.usedactive;
	cr.place();
	t.owner.weapon = undefined;
},
foedraw:function(c,t){
	if (c.owner.hand.length < 8){
		if (!c.owner.foe.deck.length) c.owner.game.setWinner(c.owner);
		else{
			c.owner.deck.push(c.owner.foe.deck.pop());
			c.owner.drawcard();
		}
	}
},
forceplay:function(c,t){
	var card = t.card;
	Effect.mkSpriteFade(require("./gfx").getCardImage(t.card), t, {x:t.owner == t.owner.game.player2 ? -1 : 1, y:0});
	if (t.owner.sanctuary) return;
	if (!t.owner.canspend(card.costele, card.cost)) return;
	t.remove();
	if (t.owner.neuro){
		t.owner.addpoison(1);
	}
	function tgttest(x){
		if (x && tgting(t.owner, x)) {
			tgts.push(x);
		}
	}
	if (card.type <= etg.PermanentEnum){
		var cons = [etg.Permanent, etg.Weapon, etg.Shield, etg.Permanent][card.type];
		new cons(card, t.owner).place(true);
		ui.playSound("permPlay");
	}else if (card.type == etg.SpellEnum){
		var tgting = Cards.Targeting[card.active.activename[0]];
		if (tgting){
			var tgts = [];
			for(var i=0; i<2; i++){
				var pl=i==0?c.owner:c.owner.foe;
				tgttest(pl);
				pl.creatures.forEach(tgttest);
				pl.permanents.forEach(tgttest);
				pl.hand.forEach(tgttest);
				tgttest(pl.shield);
				tgttest(pl.weapon);
			}
			if (tgts.length > 0){
				t.castSpell(c.owner.choose(tgts), card.active);
			}
		}else t.castSpell(undefined, card.active);
	}else if (card.type == etg.CreatureEnum){
		new etg.Creature(card, t.owner).place(true);
		ui.playSound("creaturePlay");
	}
	t.owner.spend(card.costele, card.cost);
},
fractal:function(c,t){
	Effect.mkText("Fractal", t);
	for(var i=6+Math.floor((c.owner.quanta[etg.Aether]-c.card.cost)/2); i>0; i--){
		new etg.CardInstance(t.card, c.owner).place();
	}
	c.owner.quanta[etg.Aether] = 0;
},
freeevade:function(c,t, data){
	var tgt = data.tgt;
	if (tgt instanceof etg.Creature && tgt.owner == c.owner && tgt.owner != t.owner && tgt.status.airborne && !tgt.status.frozen && c.owner.rng() > .8){
		data.evade = true;
	}
},
freeze:function(c,t){
	t.freeze(c.card.upped ? 4 : 3);
},
fungusrebirth:function(c,t){
	c.transform(c.card.as(Cards.Fungus));
},
gaincharge2:function(c,t){
	if (c != t){
		c.status.charges += 2;
	}
},
gaintimecharge:function(c,t, drawstep){
	if (!drawstep && c.owner == t){
		c.defstatus("chargecap", 0);
		if (c.status.chargecap < 4){
			c.status.chargecap++;
			c.status.charges++;
		}
	}
},
gas:function(c,t){
	new etg.Permanent(c.card.as(Cards.UnstableGas), c.owner).place();
},
give:function(c,t){
	c.owner.dmg(c.card.upped?-10:-5);
	if (!(t instanceof etg.CardInstance) && t.hasactive("auto", "singularity")){
		t.die();
	}else if (t instanceof etg.Permanent){
		Actives.steal(c.owner.foe, t);
	}else{
		t.remove();
		t.owner = c.owner.foe;
		t.place();
	}
},
golemhit:function(c,t){
	t.attack(false, 0);
},
gpull:function(c,t){
	Actives.gpullspell(c, c);
},
gpullspell:function(c,t){
	if (t instanceof etg.Creature){
		t.owner.gpull = t;
	}else{
		t = t.owner;
		delete t.gpull;
	}
	Effect.mkText("Pull", t);
},
gratitude:function(c,t){
	Effect.mkText("+4", c);
	c.owner.dmg(-4);
},
grave:function(c,t){
	if (!t.card.isOf(Cards.Singularity)){
		delete c.status.burrowed;
		c.transform(t.card);
	}
},
growth:function(x){
	var n = parseInt(x);
	return function(c,t) {
		Effect.mkText(n+"|"+n, c)
		c.buffhp(n);
		c.atk += n;
	}
},
guard:function(c,t){
	Effect.mkText("Guard", t);
	c.delay(1);
	t.delay(1);
	if (!t.status.airborne){
		t.dmg(c.trueatk());
	}
},
halveatk: function(c, t) {
	t = t || c;
	var storedatk = Math.ceil(t.atk / 2);
	if (!t.status.storedAtk) t.status.storedAtk = 0;
	t.status.storedAtk += storedatk;
	t.atk -= storedatk;
},
hammer:function(c,t){
	return c.owner.mark == etg.Gravity||c.owner.mark == etg.Earth?1:0;
},
hasten:function(c,t){
	c.owner.drawcard();
},
hatch:function(c,t){
	Effect.mkText("Hatch", c);
	c.transform(c.owner.randomcard(c.card.upped, function(x){return x.type == etg.CreatureEnum}));
},
heal:function(c,t){
	t.dmg(-20);
},
heatmirror: function(c, t, fromhand) {
	if (fromhand && t instanceof etg.Creature && c.owner != t.owner) {
		new etg.Creature(c.card.as(Cards.Spark), c.owner).place();
	}
},
holylight:function(c,t){
	t.spelldmg(t.status.nocturnal?10:-10);
},
hope:function(c,t){
	return c.owner.creatures.reduce(function(dr, cr){
		return cr && cr.hasactive("auto", "light") ? dr+1 : dr;
	}, 0);
},
icebolt:function(c,t){
	var bolts = Math.floor(c.owner.quanta[etg.Water]/5);
	if (c.owner.rng() < .35+bolts/20){
		t.freeze(c.card.upped?4:3);
	}
	t.spelldmg(2+bolts);
},
ignite:function(c,t){
	c.die();
	c.owner.foe.spelldmg(20);
	c.owner.foe.masscc(c, function(c,x){x.spelldmg(1)}, true);
},
immolate:function(c,t){
	t.die();
	if (!t.hasactive("auto", "singularity")){
		for(var i=1; i<13; i++)
			c.owner.spend(i, -1);
		c.owner.spend(etg.Fire, c.card.upped?-7:-5);
	}
},
improve:function(c,t){
	Effect.mkText("Improve", t);
	t.status.mutant = true;
	t.transform(t.owner.randomcard(false, function(x){return x.type == etg.CreatureEnum}));
},
inertia:function(c,t, tt){
	if (tt && c.owner == tt.owner){
		c.owner.spend(etg.Gravity, -2);
	}
},
infect:function(c,t){
	Effect.mkText("Infect", t);
	t.addpoison(1);
},
inflation:function(c,t){
	function inflate(p){
		if (p && p.isMaterial() && p.active.cast){
			if (!p.cast)p.castele = 0;
			p.cast++;
		}
	}
	c.owner.creatures.forEach(inflate);
	c.owner.foe.creatures.forEach(inflate);
	c.owner.permanents.forEach(inflate);
	c.owner.foe.permanents.forEach(inflate);
	inflate(c.owner.weapon);
	inflate(c.owner.shield);
	inflate(c.owner.foe.weapon);
	inflate(c.owner.foe.shield);
},
ink:function(c,t){
	var p=new etg.Permanent(Cards.Cloak, c.owner);
	p.status.charges = 1;
	p.place();
},
innovation:function(c,t){
	if (!t.owner.sanctuary){
		t.die();
		for(var i=0; i<3; i++){
			t.owner.drawcard();
		}
	}
},
integrity:function(c,t){
	var tally = [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0];
	var shardActives = [
		["deadalive", "mutation", "paradox", "improve", "improve", "antimatter"],
		["infect", "infect", "infect", "infect", "aflatoxin", "aflatoxin"],
		["devour", "devour", "devour", "devour", "devour", "blackhole"],
		["burrow", "stoneform", "guard", "guard", "bblood", "bblood"],
		["growth 2", "adrenaline", "adrenaline", "adrenaline", "adrenaline", "mitosis"],
		["ablaze", "ablaze", "tempering", "destroy", "destroy", "rage"],
		["steam", "steam", "freeze", "freeze", "nymph", "nymph"],
		["mend", "endow", "endow", "luciferin", "luciferin", "luciferin"],
		["queen", "queen", "snipe", "dive", "gas", "gas"],
		["scarab", "scarab", "deja", "deja", "precognition", "precognition"],
		["siphonstrength", "siphonstrength", "yoink", "liquid", "liquid", "steal"],
		["lobotomize", "lobotomize", "lobotomize", "quint", "quint", "quint"],
	];
	var shardCosts = {
		burrow:1, stoneform:1, guard:1, bblood:2,
		deadalive:1, mutation:2, paradox:2, improve:2, antimatter:4,
		infect:1, aflatoxin:2,
		devour:3, blackhole:4,
		"growth 2":2, adrenaline:2, mitosis:4,
		ablaze:1, tempering:(c.card.upped?2:1), destroy:3, rage:2,
		steam:2, freeze:2, nymph:4,
		mend:1, endow:2, luciferin:4,
		queen:2, snipe:2, dive:2, gas:2,
		scarab:2, deja:4, precognition:2,
		siphonstrength:2, yoink:2, liquid:2, steal:3,
		lobotomize:2, quint:2,
	};
	var stat=c.card.upped?.5:0;
	for(var i=c.owner.hand.length-1; i>=0; i--){
		var card = c.owner.hand[i].card;
		if (etg.ShardList.some(function(x) { return x && card.isOf(Cards.Codes[x]); })){
			if (card.upped){
				stat += .5;
			}
			tally[card.element]++;
			c.owner.hand.splice(i, 1);
		}
	}
	var num=0, shlist=[];
	for(var i=1; i<13; i++){
		stat += tally[i]*2;
		if (tally[i]>num){
			num = tally[i];
			shlist.length = 0;
			shlist[0] = i;
		}else if (num != 0 && tally[i] == num){
			shlist.push(i);
		}
	}
	var active = shardActives[c.owner.choose(shlist)-1][Math.min(num-1,5)];
	c.owner.shardgolem = {
		stat: Math.floor(stat),
		status: {golem: true},
		active: {cast:etg.parseActive(active)},
		cast: shardCosts[active]
	};
	function addActive(event, active){
		etg.Thing.prototype.addactive.call(c.owner.shardgolem, event, active);
	}
	function addStatus(status, val){
		c.owner.shardgolem.status[status] = val === undefined || val;
	}
	[	[[2, "hit", "scramble"]],
		[[0, "death", "growth 1"], [0, "", "nocturnal"]],
		[[1, "", "momentum"]],
		[],
		[[0, "", "poisonous"], [0, "", "adrenaline", 1], [2, "auto", "regenerate"]],
		[[0, "buff", "fiery"]],
		[[0, "", "aquatic"], [2, "hit", "regen"]],
		[[0, "auto", "light"], [1, "blocked", "virtue"], [2, "buff", "martyr"], [3, "ownfreeze", "growth 2"], [4, "hit", "disarm"], [5, "auto", "sanctuary"]],
		[[0, "", "airborne"]],
		[[1, "hit", "neuro"]],
		[[0, "", "nocturnal"], [0, "", "voodoo"], [1, "auto", "siphon"], [2, "hit", "vampire"], [3, "hit", "reducemaxhp"], [4, "destroy", "loot"], [5, "owndeath", "catlife"]],
		[[2, "", "immaterial"]],
	].forEach(function(slist, i){
		slist.forEach(function(data){<commit_msg>Forgot lives to go with catlife<commit_after>"use strict";
var ui = require("./uiutil");
function adrenathrottle(f){
	return function(c){
		if ((c.status.adrenaline || 0)<3 || (c instanceof etg.Creature && c.owner.weapon && c.owner.weapon.status.nothrottle)){
			return f.apply(null, arguments);
		}
	}
}
var Actives = {
ablaze:function(c,t){
	Effect.mkText("2|0", c);
	c.atk += 2;
},
abomination:function(c,t,data){
	if (data.tgt == c && data.active == Actives.mutation){
		Actives.improve(c, c);
		data.evade = true;
	}
},
acceleration:function(c,t){
	Effect.mkText("2|-1", c);
	c.atk += 2;
	c.dmg(1, true);
},
accelerationspell:function(c,t){
	t.lobo();
	t.active.auto = Actives.acceleration;
},
accretion:function(c,t){
	Actives.destroy(c, t);
	c.buffhp(15);
	if (c.truehp() > 45){
		c.die();
		if (c.owner.hand.length < 8){
			new etg.CardInstance(c.card.as(Cards.BlackHole), c.owner).place();
		}
	}
},
accumulation:function(c,t){
	return c.status.charges;
},
adrenaline:function(c,t){
	Effect.mkText("Adrenaline", t);
	t.status.adrenaline = 1;
},
aether:function(c,t){
	Effect.mkText("1:12", c);
	c.owner.spend(etg.Aether, -1);
},
aflatoxin:function(c,t){
	Effect.mkText("Aflatoxin", t);
	t.addpoison(2);
	if (!(t instanceof etg.Player)){
		t.status.aflatoxin = true;
	}
},
aggroskele:function(c,t){
	new etg.Creature(c.card.as(Cards.Skeleton), c.owner).place();
	var dmg = c.owner.creatures.reduce(function(dmg, cr){
		return cr && cr.card.isOf(Cards.Skeleton) ?
			dmg + cr.trueatk() : dmg;
	}, 0);
	Effect.mkText("-"+dmg, t);
	t.dmg(dmg);
},
air:function(c,t){
	Effect.mkText("1:9", c);
	c.owner.spend(etg.Air, -1);
},
alphawolf:function(c,t){
	var pwolf = c.card.as(Cards.PackWolf);
	new etg.Creature(pwolf, c.owner).place();
	new etg.Creature(pwolf, c.owner).place();
},
antimatter:function(c,t){
	Effect.mkText("Antimatter", t);
	t.atk -= t.trueatk()*2;
},
appease:function(c,t){
	Actives.devour(c, t);
	c.status.appeased = true;
},
atk2hp:function(c,t){
	t.buffhp(t.trueatk()-t.hp);
},
axe:function(c,t){
	return c.owner.mark == etg.Fire || c.owner.mark == etg.Time?1:0;
},
axedraw:function(c,t){
	c.defstatus("dive", 0);
	c.status.dive++;
},
bblood:function(c,t){
	Effect.mkText("0|20", t);
	t.buffhp(20);
	t.delay(6);
},
becomearctic:function(c,t){
	c.transform(c.card.as(Cards.ArcticSquid));
},
beguile:function(c,t){
	t.remove();
	t.owner = t.owner.foe;
	t.place();
	if (c != t){
		t.addactive("turnstart", Actives.beguilestop);
	}
},
beguilestop:function(c,t){
	if (t == c.owner){
		c.rmactive("turnstart", "beguilestop");
		Actives.beguile(c, c);
	}
},
blackhole:function(c,t){
	if (!t.sanctuary){
		for (var q=1; q<13; q++){
			c.owner.dmg(-Math.min(t.quanta[q],3));
			t.quanta[q] = Math.max(t.quanta[q]-3,0);
		}
	}
},
bless:function(c,t){
	Effect.mkText("3|3", t);
	t.atk += 3;
	t.buffhp(3);
},
bolsterintodeck:function(c,t){
	c.owner.deck.push(t.card, t.card, t.card);
},
boneyard:function(c,t){
	if (!t.card.isOf(Cards.Skeleton)){
		new etg.Creature(c.card.as(Cards.Skeleton), c.owner).place();
	}
},
bow:function(c,t){
	return c.owner.mark == etg.Air || c.owner.mark == etg.Light?1:0;
},
bounce:function(c,t){
	if (c.owner.hand.length < 8) {
		new etg.CardInstance(c.card, c.owner).place();
		c.remove();
		return true;
	}
},
bravery:function(c,t){
	if (!c.owner.foe.sanctuary){
		for(var i=0; i<2 && c.owner.hand.length<8 && c.owner.foe.hand.length<8; i++){
			c.owner.drawcard();
			c.owner.foe.drawcard();
		}
	}
},
brew:function(c,t){
	Effect.mkText("Brew", c);
	new etg.CardInstance(c.card.as(Cards.Codes[etg.AlchemyList[c.owner.uptoceil(12)]]), c.owner).place();
},
brokenmirror:function(c,t, fromhand){
	if (fromhand && t instanceof etg.Creature && c.owner != t.owner){
		new etg.Creature(c.card.as(Cards.Phantom), c.owner).place();
	}
},
burrow:function(c,t){
	c.status.burrowed = true;
	delete c.status.airborne;
	c.active.cast = Actives.unburrow;
	c.cast = 0;
},
butterfly:function(c,t){
	t.lobo();
	t.active.cast = Actives.destroy;
	t.cast = 3;
	t.castele = etg.Entropy;
},
catapult:function(c,t){
	Effect.mkText("Catapult", t);
	t.die();
	c.owner.foe.dmg(Math.ceil(t.truehp()*(t.status.frozen?150:100)/(t.truehp()+100)));
	if (t.status.poison){
		c.owner.foe.addpoison(t.status.poison);
	}
	if (t.status.frozen){
		c.owner.foe.freeze(3);
	}
},
catlife:function(c,t, data){
	if (!c.owner.creatures[data.index] && c.status.lives > 0){
		c.status.lives--;
		Effect.mkText(c.status.lives + " lives");
		var cl = c.clone(c.owner);
		cl.hp = cl.maxhp = c.card.health;
		cl.atk = c.card.attack;
		c.owner.creatures[data.index] = cl;
	}
},
cell:function(c,t){
	c.transform(c.card.as(Cards.MalignantCell));
},
chimera:function(c,t){
	var atk=0, hp=0;
	c.owner.creatures.forEach(function(cr){
		if (cr){
			atk += cr.trueatk();
			hp += cr.truehp();
		}
	});
	var chim = new etg.Creature(c.card, c.owner);
	chim.atk = atk;
	chim.maxhp = chim.hp = hp;
	chim.active = {};
	chim.status.momentum = true;
	c.owner.creatures[0] = chim;
	c.owner.creatures.length = 1;
	c.owner.creatures.length = 23;
	c.owner.gpull = chim;
},
clear:function(c,t){
	Effect.mkText("Clear", t);
	delete t.status.poison;
	delete t.status.adrenaline;
	delete t.status.aflatoxin;
	delete t.status.momentum;
	delete t.status.psion;
	if (t.status.delayed > 0){
		t.status.delayed--;
	}
	if (t.status.frozen > 0){
		t.status.frozen--;
	}
	t.dmg(-1);
	if (t.hasactive("turnstart", "beguilestop")){
		Actives.beguilestop(t, t.owner);
	}
},
corpseexplosion:function(c,t){
	t.die();
	c.owner.foe.masscc(c, function(c,t){ t.spelldmg(1) }, !c.card.upped);
	var poison = (t.status.poison || 0) + (t.status.poisonous ? 1 : 0);
	if (poison){
		c.owner.foe.addpoison(poison);
	}
},
counter:function(c,t){
	if (!c.status.frozen && !c.status.delayed){
		t.dmg(c.trueatk());
	}
},
cpower:function(c,t){
	var buff = t.owner.upto(25);
	t.buffhp(Math.floor(buff/5)+1);
	t.atk += buff%5+1;
},
cseed:function(c,t){
	Actives[c.owner.choose(["drainlife", "firebolt", "freeze", "gpullspell", "icebolt", "infect", "lightning", "lobotomize", "parallel", "rewind", "snipe", "swave"])](c, t);
},
dagger:function(c){
	return (c.owner.mark == etg.Darkness||c.owner.mark == etg.Death) + c.owner.isCloaked();
},
darkness:function(c){
	c.owner.spend(etg.Darkness, -1);
},
deadalive:function(c){
	c.deatheffect(c.getIndex());
},
deathwish:function(c,t, data){
	var tgt = data.tgt, active = data.active;
	if (!tgt || c.status.frozen || c.status.delayed || c.owner == t.owner || tgt.owner != c.owner || !(tgt instanceof etg.Creature) || !Cards.Targeting[active.activename[0]](t, c)) return;
	if (!tgt.hasactive("spell", "deathwish")) return data.tgt = c;
	var totaldw = 0;
	c.owner.creatures.forEach(function(cr){
		if (cr && cr.hasactive("spell", "deathwish"))totaldw++;
	});
	if (c.owner.rng() < 1/totaldw){
		return data.tgt = c;
	}
},
decrsteam:function(c){
	c.defstatus("steamatk", 0);
	if (c.status.steamatk > 0){
		c.atk--;
		c.status.steamatk--;
	}
},
deckblast:function(c,t){
	c.owner.foe.spelldmg(Math.ceil(c.owner.deck.length/c.owner.deckpower));
	c.owner.deck.length = 0;
},
deja:function(c,t){
	delete c.active.cast;
	Actives.parallel(c, c);
},
deployblobs:function(c,t){
	var blob = c.card.as(Cards.Blob);
	for(var i=0; i<3; i++){
		new etg.Creature(blob, c.owner).place();
	}
	c.atk -= 2;
	c.dmg(2);
},
destroy:function(c,t, dontsalvage, donttalk){
	if (!donttalk){
		Effect.mkText("Destroy", t);
	}
	if (t.status.stackable){
		if(--t.status.charges<=0){
			t.remove();
		}
	}else t.remove();
	if (!dontsalvage){
		t.procactive("destroy", {});
	}
},
destroycard:function(c,t){
	if (!t.owner.sanctuary){
		t.die();
	}
},
devour:function(c,t){
	Effect.mkText("1|1", c);
	c.buffhp(1);
	c.atk += 1;
	if (t.status.poisonous){
		c.addpoison(1);
	}
	t.die();
},
die:function(c,t){
	c.die();
},
disarm:function(c,t){
	if (t instanceof etg.Player && t.weapon){
		Actives.unsummon(c, t.weapon);
	}
},
disc:function(c,t){
	return c.owner.mark == etg.Entropy || c.owner.mark == etg.Aether?1:0;
},
discping:function(c,t){
	t.dmg(1);
	c.remove();
	new etg.CardInstance(c.card, c.owner).place();
},
disfield:function(c,t, dmg){
	if (!c.owner.spend(etg.Chroma, dmg)){
		for(var i=1; i<13; i++){
			c.owner.quanta[i] = 0;
		}
		c.owner.shield = undefined;
	}
	return true;
},
disshield:function(c,t, dmg){
	if (!c.owner.spend(etg.Entropy, Math.ceil(dmg/3))){
		c.owner.quanta[etg.Entropy] = 0;
		c.owner.shield = undefined;
	}
	return true;
},
dive:function(c,t){
	Effect.mkText("Dive", c);
	c.defstatus("dive", 0);
	c.status.dive = c.trueatk();
},
divinity:function(c,t){
	if (c.owner.maxhp < 500){
		c.owner.maxhp = Math.min(c.owner.maxhp + 24, 500);
	}
	c.owner.dmg(-16);
},
drainlife:function(c,t){
	c.owner.dmg(-t.spelldmg(2+Math.floor(c.owner.quanta[etg.Darkness]/5)));
},
draft:function(c,t){
	Effect.mkText("Draft", t);
	c.owner.spend(etg.Air, -2);
	if((t.status.airborne = !t.status.airborne)){
		if (t.active.cast == Actives.burrow){
			delete t.active.cast;
		}
	}
},
drawcopy:function(c,t){
	if (c.owner != t.owner) new etg.CardInstance(t.card, c.owner).place();
},
dryspell:function(c,t){
	function dryeffect(c,t){
		c.spend(etg.Water, -t.spelldmg(1));
	}
	c.owner.foe.masscc(c.owner, dryeffect, true);
},
dshield:function(c,t){
	c.status.immaterial = true;
	c.addactive("turnstart", Actives.dshieldoff);
},
dshieldoff:function(c,t){
	if (c.owner == t){
		delete c.status.immaterial;
		c.rmactive("turnstart", "dshieldoff");
	}
},
duality:function(c,t){
	if (c.owner.foe.deck.length > 0 && c.owner.hand.length < 8){
		new etg.CardInstance(c.owner.foe.deck[c.owner.foe.deck.length-1], c.owner).place();
	}
},
earth:function(c,t){
	Effect.mkText("1:4", c);
	c.owner.spend(etg.Earth, -1);
},
earthquake:function(c,t){
	Effect.mkText("Earthquake", t);
	if (t.status.charges>3){
		t.status.charges -= 3;
	}else{
		t.remove();
	}
	t.procactive("destroy", {});
},
elf:function(c,t,data){
	if (data.tgt == c && data.active == Actives.cseed){
		c.transform(c.card.as(Cards.FallenElf));
		data.evade = true;
	}
},
empathy:function(c,t){
	var healsum = c.owner.countcreatures();
	Effect.mkText("+"+healsum, c);
	c.owner.dmg(-healsum);
	if (!c.owner.spend(etg.Life, Math.floor(healsum/8))){
		c.owner.quanta[etg.Life] = 0;
		c.die();
	}
},
enchant:function(c,t){
	Effect.mkText("Enchant", t);
	t.status.immaterial = true;
},
endow:function(c,t){
	Effect.mkText("Endow", t);
	for (key in t.status) {
		if (typeof t.status[key] == "boolean")
			c.status[key] = c.status[key] || t.status[key]
		else if (typeof t.status[key] == "number")
			c.status[key] = t.status[key] + (c.status[key] ? c.status[key] : 0);
		else
			c.status[key] = t.status[key];
	}
 	if (c.status.adrenaline > 1)
		c.status.adrenaline = 1;
	c.active = etg.clone(t.active);
	c.cast = t.cast;
	c.castele = t.castele;
	if (c.active.cast && c.active.cast == Actives.endow) {
		delete c.active.cast;
	}
	c.atk += t.trueatk();
	if (t.active.buff){
		c.atk -= t.active.buff(t);
	}
	c.buffhp(2);
},
envenom:function(c,t){
	t.addactive("hit", etg.parseActive("poison 1"));
},
epidemic:function(c,t){
	if (t.status.poison){
		c.owner.foe.addpoison(t.status.poison);
	}
},
epoch:function(c,t){
	if (++c.status.epoch > 1) Actives.silence(c, t.owner);
},
epochreset:function(c,t){
	c.status.epoch = 0;
},
evolve:function(c,t){
	c.transform(c.card.as(Cards.Shrieker));
	delete c.status.burrowed;
},
feed:function(c,t){
	t.addpoison(1);
	etg.parseActive("growth 3")(c);
	delete c.status.immaterial;
},
fickle:function(c,t){
	if (t.owner != c.owner && t.owner.sanctuary){
		return;
	}
	var cards = [];
	t.owner.deck.forEach(function(card, i){
		var cost = card.cost;
		if (!card.element || card.element == c.castele) cost += c.cast;
		if (t.owner.canspend(card.costele, cost)){
			cards.push(i);
		}
	});
	if (cards.length > 0){
		var pick = t.owner.choose(cards);
		t.owner.hand[t.getIndex()] = new etg.CardInstance(t.owner.deck[pick], t.owner);
		t.owner.deck[pick] = t.card;
	}
},
fiery:function(c,t){
	return Math.floor(c.owner.quanta[etg.Fire]/5);
},
fire:function(c,t){
	Effect.mkText("1:6", c);
	c.owner.spend(etg.Fire, -1);
},
firebolt:function(c,t){
	t.spelldmg(3+Math.floor(c.owner.quanta[etg.Fire]/4));
	if (t instanceof etg.Player){
		if (t.weapon){
			t.weapon.status.frozen = 0;
		}
	}else{
		t.status.frozen = 0;
	}
},
flatline:function(c,t){
	if (!c.owner.foe.sanctuary){
		c.owner.foe.flatline = true;
	}
},
flyself:function(c,t){
	Actives[c instanceof etg.Weapon ? "flyingweapon" : "livingweapon"](c, c);
},
flyingweapon:function(c,t){
	var cr = new etg.Creature(t.card, t.owner);
	cr.atk = t.atk;
	cr.active = etg.clone(t.active);
	cr.cast = t.cast;
	cr.castele = t.castele;
	cr.status = etg.clone(t.status);
	cr.status.airborne = true;
	cr.usedactive = t.usedactive;
	cr.place();
	t.owner.weapon = undefined;
},
foedraw:function(c,t){
	if (c.owner.hand.length < 8){
		if (!c.owner.foe.deck.length) c.owner.game.setWinner(c.owner);
		else{
			c.owner.deck.push(c.owner.foe.deck.pop());
			c.owner.drawcard();
		}
	}
},
forceplay:function(c,t){
	var card = t.card;
	Effect.mkSpriteFade(require("./gfx").getCardImage(t.card), t, {x:t.owner == t.owner.game.player2 ? -1 : 1, y:0});
	if (t.owner.sanctuary) return;
	if (!t.owner.canspend(card.costele, card.cost)) return;
	t.remove();
	if (t.owner.neuro){
		t.owner.addpoison(1);
	}
	function tgttest(x){
		if (x && tgting(t.owner, x)) {
			tgts.push(x);
		}
	}
	if (card.type <= etg.PermanentEnum){
		var cons = [etg.Permanent, etg.Weapon, etg.Shield, etg.Permanent][card.type];
		new cons(card, t.owner).place(true);
		ui.playSound("permPlay");
	}else if (card.type == etg.SpellEnum){
		var tgting = Cards.Targeting[card.active.activename[0]];
		if (tgting){
			var tgts = [];
			for(var i=0; i<2; i++){
				var pl=i==0?c.owner:c.owner.foe;
				tgttest(pl);
				pl.creatures.forEach(tgttest);
				pl.permanents.forEach(tgttest);
				pl.hand.forEach(tgttest);
				tgttest(pl.shield);
				tgttest(pl.weapon);
			}
			if (tgts.length > 0){
				t.castSpell(c.owner.choose(tgts), card.active);
			}
		}else t.castSpell(undefined, card.active);
	}else if (card.type == etg.CreatureEnum){
		new etg.Creature(card, t.owner).place(true);
		ui.playSound("creaturePlay");
	}
	t.owner.spend(card.costele, card.cost);
},
fractal:function(c,t){
	Effect.mkText("Fractal", t);
	for(var i=6+Math.floor((c.owner.quanta[etg.Aether]-c.card.cost)/2); i>0; i--){
		new etg.CardInstance(t.card, c.owner).place();
	}
	c.owner.quanta[etg.Aether] = 0;
},
freeevade:function(c,t, data){
	var tgt = data.tgt;
	if (tgt instanceof etg.Creature && tgt.owner == c.owner && tgt.owner != t.owner && tgt.status.airborne && !tgt.status.frozen && c.owner.rng() > .8){
		data.evade = true;
	}
},
freeze:function(c,t){
	t.freeze(c.card.upped ? 4 : 3);
},
fungusrebirth:function(c,t){
	c.transform(c.card.as(Cards.Fungus));
},
gaincharge2:function(c,t){
	if (c != t){
		c.status.charges += 2;
	}
},
gaintimecharge:function(c,t, drawstep){
	if (!drawstep && c.owner == t){
		c.defstatus("chargecap", 0);
		if (c.status.chargecap < 4){
			c.status.chargecap++;
			c.status.charges++;
		}
	}
},
gas:function(c,t){
	new etg.Permanent(c.card.as(Cards.UnstableGas), c.owner).place();
},
give:function(c,t){
	c.owner.dmg(c.card.upped?-10:-5);
	if (!(t instanceof etg.CardInstance) && t.hasactive("auto", "singularity")){
		t.die();
	}else if (t instanceof etg.Permanent){
		Actives.steal(c.owner.foe, t);
	}else{
		t.remove();
		t.owner = c.owner.foe;
		t.place();
	}
},
golemhit:function(c,t){
	t.attack(false, 0);
},
gpull:function(c,t){
	Actives.gpullspell(c, c);
},
gpullspell:function(c,t){
	if (t instanceof etg.Creature){
		t.owner.gpull = t;
	}else{
		t = t.owner;
		delete t.gpull;
	}
	Effect.mkText("Pull", t);
},
gratitude:function(c,t){
	Effect.mkText("+4", c);
	c.owner.dmg(-4);
},
grave:function(c,t){
	if (!t.card.isOf(Cards.Singularity)){
		delete c.status.burrowed;
		c.transform(t.card);
	}
},
growth:function(x){
	var n = parseInt(x);
	return function(c,t) {
		Effect.mkText(n+"|"+n, c)
		c.buffhp(n);
		c.atk += n;
	}
},
guard:function(c,t){
	Effect.mkText("Guard", t);
	c.delay(1);
	t.delay(1);
	if (!t.status.airborne){
		t.dmg(c.trueatk());
	}
},
halveatk: function(c, t) {
	t = t || c;
	var storedatk = Math.ceil(t.atk / 2);
	if (!t.status.storedAtk) t.status.storedAtk = 0;
	t.status.storedAtk += storedatk;
	t.atk -= storedatk;
},
hammer:function(c,t){
	return c.owner.mark == etg.Gravity||c.owner.mark == etg.Earth?1:0;
},
hasten:function(c,t){
	c.owner.drawcard();
},
hatch:function(c,t){
	Effect.mkText("Hatch", c);
	c.transform(c.owner.randomcard(c.card.upped, function(x){return x.type == etg.CreatureEnum}));
},
heal:function(c,t){
	t.dmg(-20);
},
heatmirror: function(c, t, fromhand) {
	if (fromhand && t instanceof etg.Creature && c.owner != t.owner) {
		new etg.Creature(c.card.as(Cards.Spark), c.owner).place();
	}
},
holylight:function(c,t){
	t.spelldmg(t.status.nocturnal?10:-10);
},
hope:function(c,t){
	return c.owner.creatures.reduce(function(dr, cr){
		return cr && cr.hasactive("auto", "light") ? dr+1 : dr;
	}, 0);
},
icebolt:function(c,t){
	var bolts = Math.floor(c.owner.quanta[etg.Water]/5);
	if (c.owner.rng() < .35+bolts/20){
		t.freeze(c.card.upped?4:3);
	}
	t.spelldmg(2+bolts);
},
ignite:function(c,t){
	c.die();
	c.owner.foe.spelldmg(20);
	c.owner.foe.masscc(c, function(c,x){x.spelldmg(1)}, true);
},
immolate:function(c,t){
	t.die();
	if (!t.hasactive("auto", "singularity")){
		for(var i=1; i<13; i++)
			c.owner.spend(i, -1);
		c.owner.spend(etg.Fire, c.card.upped?-7:-5);
	}
},
improve:function(c,t){
	Effect.mkText("Improve", t);
	t.status.mutant = true;
	t.transform(t.owner.randomcard(false, function(x){return x.type == etg.CreatureEnum}));
},
inertia:function(c,t, tt){
	if (tt && c.owner == tt.owner){
		c.owner.spend(etg.Gravity, -2);
	}
},
infect:function(c,t){
	Effect.mkText("Infect", t);
	t.addpoison(1);
},
inflation:function(c,t){
	function inflate(p){
		if (p && p.isMaterial() && p.active.cast){
			if (!p.cast)p.castele = 0;
			p.cast++;
		}
	}
	c.owner.creatures.forEach(inflate);
	c.owner.foe.creatures.forEach(inflate);
	c.owner.permanents.forEach(inflate);
	c.owner.foe.permanents.forEach(inflate);
	inflate(c.owner.weapon);
	inflate(c.owner.shield);
	inflate(c.owner.foe.weapon);
	inflate(c.owner.foe.shield);
},
ink:function(c,t){
	var p=new etg.Permanent(Cards.Cloak, c.owner);
	p.status.charges = 1;
	p.place();
},
innovation:function(c,t){
	if (!t.owner.sanctuary){
		t.die();
		for(var i=0; i<3; i++){
			t.owner.drawcard();
		}
	}
},
integrity:function(c,t){
	var tally = [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0];
	var shardActives = [
		["deadalive", "mutation", "paradox", "improve", "improve", "antimatter"],
		["infect", "infect", "infect", "infect", "aflatoxin", "aflatoxin"],
		["devour", "devour", "devour", "devour", "devour", "blackhole"],
		["burrow", "stoneform", "guard", "guard", "bblood", "bblood"],
		["growth 2", "adrenaline", "adrenaline", "adrenaline", "adrenaline", "mitosis"],
		["ablaze", "ablaze", "tempering", "destroy", "destroy", "rage"],
		["steam", "steam", "freeze", "freeze", "nymph", "nymph"],
		["mend", "endow", "endow", "luciferin", "luciferin", "luciferin"],
		["queen", "queen", "snipe", "dive", "gas", "gas"],
		["scarab", "scarab", "deja", "deja", "precognition", "precognition"],
		["siphonstrength", "siphonstrength", "yoink", "liquid", "liquid", "steal"],
		["lobotomize", "lobotomize", "lobotomize", "quint", "quint", "quint"],
	];
	var shardCosts = {
		burrow:1, stoneform:1, guard:1, bblood:2,
		deadalive:1, mutation:2, paradox:2, improve:2, antimatter:4,
		infect:1, aflatoxin:2,
		devour:3, blackhole:4,
		"growth 2":2, adrenaline:2, mitosis:4,
		ablaze:1, tempering:(c.card.upped?2:1), destroy:3, rage:2,
		steam:2, freeze:2, nymph:4,
		mend:1, endow:2, luciferin:4,
		queen:2, snipe:2, dive:2, gas:2,
		scarab:2, deja:4, precognition:2,
		siphonstrength:2, yoink:2, liquid:2, steal:3,
		lobotomize:2, quint:2,
	};
	var stat=c.card.upped?.5:0;
	for(var i=c.owner.hand.length-1; i>=0; i--){
		var card = c.owner.hand[i].card;
		if (etg.ShardList.some(function(x) { return x && card.isOf(Cards.Codes[x]); })){
			if (card.upped){
				stat += .5;
			}
			tally[card.element]++;
			c.owner.hand.splice(i, 1);
		}
	}
	var num=0, shlist=[];
	for(var i=1; i<13; i++){
		stat += tally[i]*2;
		if (tally[i]>num){
			num = tally[i];
			shlist.length = 0;
			shlist[0] = i;
		}else if (num != 0 && tally[i] == num){
			shlist.push(i);
		}
	}
	var active = shardActives[c.owner.choose(shlist)-1][Math.min(num-1,5)];
	c.owner.shardgolem = {
		stat: Math.floor(stat),
		status: {golem: true},
		active: {cast:etg.parseActive(active)},
		cast: shardCosts[active]
	};
	function addActive(event, active){
		etg.Thing.prototype.addactive.call(c.owner.shardgolem, event, active);
	}
	function addStatus(status, val){
		c.owner.shardgolem.status[status] = val === undefined || val;
	}
	[	[[2, "hit", "scramble"]],
		[[0, "death", "growth 1"], [0, "", "nocturnal"]],
		[[1, "", "momentum"]],
		[],
		[[0, "", "poisonous"], [0, "", "adrenaline", 1], [2, "auto", "regenerate"]],
		[[0, "buff", "fiery"]],
		[[0, "", "aquatic"], [2, "hit", "regen"]],
		[[0, "auto", "light"], [1, "blocked", "virtue"], [2, "buff", "martyr"], [3, "ownfreeze", "growth 2"], [4, "hit", "disarm"], [5, "auto", "sanctuary"]],
		[[0, "", "airborne"]],
		[[1, "hit", "neuro"]],
		[[0, "", "nocturnal"], [0, "", "voodoo"], [1, "auto", "siphon"], [2, "hit", "vampire"], [3, "hit", "reducemaxhp"], [4, "destroy", "loot"], [5, "owndeath", "catlife"], [5, "", "lives", 69105]],
		[[2, "", "immaterial"]],
	].forEach(function(slist, i){
		slist.forEach(function(data){
{'fraction_non_alphanumeric': 0.23387526961523297, 'fraction_numerical': 0.01502887492172461, 'mean_word_length': 4.418195526514199, 'pattern_counts': {'":': 2, '<': 45, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '849538', 'n_tokens_mistral': 20707, 'n_tokens_neox': 19563, 'n_words': 2955}