
package com.github.epd.sprout.actors.mobs;

import com.github.epd.sprout.Dungeon;
import com.github.epd.sprout.actors.Char;
import com.github.epd.sprout.actors.buffs.Buff;
import com.github.epd.sprout.actors.buffs.Terror;
import com.github.epd.sprout.actors.buffs.Vertigo;
import com.github.epd.sprout.effects.particles.ShadowParticle;
import com.github.epd.sprout.items.RedDewdrop;
import com.github.epd.sprout.messages.Messages;
import com.github.epd.sprout.scenes.GameScene;
import com.github.epd.sprout.sprites.BlueWraithSprite;
import com.watabou.noosa.tweeners.AlphaTweener;
import com.watabou.utils.Random;

public class BlueWraith extends Wraith {

	{
		name = Messages.get(this, "name");
		spriteClass = BlueWraithSprite.class;

		HP = HT = 195;
		defenseSkill = 24;
		baseSpeed = 2f;

		EXP = 11;

		loot = new RedDewdrop();
		lootChance = 1.0f; // by default, see die()

		properties.add(Property.UNDEAD);
		properties.add(Property.EVIL);

	}

	@Override
	public String description() {
		return Messages.get(this, "desc");
	}

	@Override
	public int attackProc(Char enemy, int damage) {
		if (Random.Int(10) == 0) {
			Buff.affect(enemy, Vertigo.class, Vertigo.duration(enemy));
			Buff.affect(enemy, Terror.class, Terror.DURATION).object = enemy.id();
		}

		return damage;
	}

	@Override
	public void adjustStats(int level) {
		this.level = level;
		defenseSkill = 24;
		enemySeen = true;
	}

	@Override
	public int damageRoll() {
		return Random.NormalIntRange(20, 90);
	}

	@Override
	public int attackSkill(Char target) {
		return 46;
	}

	@Override
	public int dr() {
		return 25;
	}

	public static BlueWraith spawnAt(int pos) {

		BlueWraith b = new BlueWraith();
		b.adjustStats(Dungeon.depth);
		b.pos = pos;
		b.state = b.HUNTING;
		GameScene.add(b, SPAWN_DELAY);

		b.sprite.alpha(0);
		b.sprite.parent.add(new AlphaTweener(b.sprite, 1, 0.5f));

		b.sprite.emitter().burst(ShadowParticle.CURSE, 5);

		return b;


	}


	/*private int level;
				
	/*private static final float TIME_TO_ZAP = 1f;

	private static final String TXT_WRAITHFIRE_KILLED = "%s's wraith fire killed you...";*/
	
	/*private static final float SPAWN_DELAY = 2f;

	{
		name = "blue wraith";
		spriteClass = BlueWraithSprite.class;

		HP = HT = 70;
		defenseSkill = 18;

		EXP = 11;
		loot = Generator.Category.POTION;
		
	}

	
	@Override
	public int damageRoll() {
		return Random.NormalIntRange(12, 20);
	}

	
	@Override
	public int dr() {
		return 8;
	}
/*
	@Override
	protected boolean canAttack(Char enemy) {
		return Ballistica.cast(pos, enemy.pos, false, true) == enemy.pos;
	}

	protected boolean doAttack(Char enemy) {

		if (Level.adjacent(pos, enemy.pos)) {

			return super.doAttack(enemy);

		} else {

			boolean visible = Level.fieldOfView[pos]
					|| Level.fieldOfView[enemy.pos];
			if (visible) {
				((BlueWraithSprite) sprite).zap(enemy.pos);
			} else {
				zap();
			}

			return !visible;
		}
	}

	private void zap() {
		spend(TIME_TO_ZAP);

		if (hit(this, enemy, true)) {
			if (enemy == Dungeon.hero && Random.Int(2) == 0) {
				Buff.prolong(enemy, Frost.class, Frost.duration(enemy));
			}

			int dmg = Random.Int(12, 18);
			enemy.damage(dmg, this);

			if (!enemy.isAlive() && enemy == Dungeon.hero) {
				Dungeon.fail(Utils.format(ResultDescriptions.MOB,
						Utils.indefinite(name)));
				GLog.n(TXT_WRAITHFIRE_KILLED, name);
			}
		} else {
			enemy.sprite.showStatus(CharSprite.NEUTRAL, enemy.defenseVerb());
		}
	}

	public void onZapComplete() {
		zap();
		next();
	}

	@Override
	public void call() {
		next();
	}
		*/


}
