2014-01-18 00:59:31 +00:00
|
|
|
package WayofTime.alchemicalWizardry.common.spell.complex.effect;
|
|
|
|
|
2014-01-25 14:22:59 +00:00
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
2014-01-18 00:59:31 +00:00
|
|
|
import WayofTime.alchemicalWizardry.common.spell.complex.SpellModifier;
|
|
|
|
import WayofTime.alchemicalWizardry.common.spell.complex.SpellParadigm;
|
2014-01-18 16:45:31 +00:00
|
|
|
import WayofTime.alchemicalWizardry.common.spell.complex.SpellParadigmMelee;
|
2014-01-18 00:59:31 +00:00
|
|
|
import WayofTime.alchemicalWizardry.common.spell.complex.SpellParadigmProjectile;
|
2014-01-18 16:45:31 +00:00
|
|
|
import WayofTime.alchemicalWizardry.common.spell.complex.SpellParadigmSelf;
|
|
|
|
import WayofTime.alchemicalWizardry.common.spell.complex.enhancement.SpellEnhancement;
|
2014-01-18 00:59:31 +00:00
|
|
|
|
|
|
|
public abstract class SpellEffect
|
|
|
|
{
|
2014-01-18 23:05:25 +00:00
|
|
|
protected int modifierState;
|
|
|
|
protected int powerEnhancement;
|
|
|
|
protected int costEnhancement;
|
2014-01-19 03:16:39 +00:00
|
|
|
protected int potencyEnhancement;
|
2014-01-18 23:05:25 +00:00
|
|
|
|
|
|
|
public SpellEffect()
|
|
|
|
{
|
|
|
|
this.modifierState = SpellModifier.DEFAULT;
|
|
|
|
this.powerEnhancement = 0;
|
|
|
|
this.costEnhancement = 0;
|
|
|
|
}
|
2014-01-18 00:59:31 +00:00
|
|
|
|
|
|
|
public void enhanceEffect(SpellEnhancement enh)
|
|
|
|
{
|
2014-01-18 16:45:31 +00:00
|
|
|
if(enh!=null)
|
|
|
|
{
|
|
|
|
switch(enh.getState())
|
|
|
|
{
|
|
|
|
case SpellEnhancement.POWER: this.powerEnhancement++; break;
|
|
|
|
case SpellEnhancement.EFFICIENCY: this.costEnhancement++; break;
|
2014-01-19 03:16:39 +00:00
|
|
|
case SpellEnhancement.POTENCY: this.potencyEnhancement++; break;
|
2014-01-18 16:45:31 +00:00
|
|
|
}
|
|
|
|
}
|
2014-01-18 00:59:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void modifyEffect(SpellModifier mod)
|
|
|
|
{
|
|
|
|
if(mod!=null)
|
|
|
|
modifierState = mod.getModifier();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void modifyParadigm(SpellParadigm parad)
|
|
|
|
{
|
|
|
|
if(parad instanceof SpellParadigmProjectile)
|
|
|
|
{
|
|
|
|
this.modifyProjectileParadigm((SpellParadigmProjectile)parad);
|
|
|
|
}
|
2014-01-19 03:16:39 +00:00
|
|
|
if(parad instanceof SpellParadigmSelf)
|
|
|
|
{
|
|
|
|
this.modifySelfParadigm((SpellParadigmSelf)parad);
|
|
|
|
}
|
|
|
|
if(parad instanceof SpellParadigmMelee)
|
|
|
|
{
|
|
|
|
this.modifyMeleeParadigm((SpellParadigmMelee)parad);
|
|
|
|
}
|
2014-01-18 00:59:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void modifyProjectileParadigm(SpellParadigmProjectile parad)
|
|
|
|
{
|
|
|
|
switch(modifierState)
|
|
|
|
{
|
|
|
|
case SpellModifier.DEFAULT: this.defaultModificationProjectile(parad); break;
|
|
|
|
case SpellModifier.OFFENSIVE: this.offensiveModificationProjectile(parad); break;
|
|
|
|
case SpellModifier.DEFENSIVE: this.defensiveModificationProjectile(parad); break;
|
|
|
|
case SpellModifier.ENVIRONMENTAL: this.environmentalModificationProjectile(parad); break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public abstract void defaultModificationProjectile(SpellParadigmProjectile parad);
|
|
|
|
public abstract void offensiveModificationProjectile(SpellParadigmProjectile parad);
|
|
|
|
public abstract void defensiveModificationProjectile(SpellParadigmProjectile parad);
|
|
|
|
public abstract void environmentalModificationProjectile(SpellParadigmProjectile parad);
|
2014-01-18 16:45:31 +00:00
|
|
|
|
|
|
|
public void modifySelfParadigm(SpellParadigmSelf parad)
|
|
|
|
{
|
|
|
|
switch(modifierState)
|
|
|
|
{
|
|
|
|
case SpellModifier.DEFAULT: this.defaultModificationSelf(parad); break;
|
|
|
|
case SpellModifier.OFFENSIVE: this.offensiveModificationSelf(parad); break;
|
|
|
|
case SpellModifier.DEFENSIVE: this.defensiveModificationSelf(parad); break;
|
|
|
|
case SpellModifier.ENVIRONMENTAL: this.environmentalModificationSelf(parad); break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public abstract void defaultModificationSelf(SpellParadigmSelf parad);
|
|
|
|
public abstract void offensiveModificationSelf(SpellParadigmSelf parad);
|
|
|
|
public abstract void defensiveModificationSelf(SpellParadigmSelf parad);
|
|
|
|
public abstract void environmentalModificationSelf(SpellParadigmSelf parad);
|
|
|
|
|
|
|
|
public void modifyMeleeParadigm(SpellParadigmMelee parad)
|
|
|
|
{
|
|
|
|
switch(modifierState)
|
|
|
|
{
|
|
|
|
case SpellModifier.DEFAULT: this.defaultModificationMelee(parad); break;
|
|
|
|
case SpellModifier.OFFENSIVE: this.offensiveModificationMelee(parad); break;
|
|
|
|
case SpellModifier.DEFENSIVE: this.defensiveModificationMelee(parad); break;
|
|
|
|
case SpellModifier.ENVIRONMENTAL: this.environmentalModificationMelee(parad); break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public abstract void defaultModificationMelee(SpellParadigmMelee parad);
|
|
|
|
public abstract void offensiveModificationMelee(SpellParadigmMelee parad);
|
|
|
|
public abstract void defensiveModificationMelee(SpellParadigmMelee parad);
|
|
|
|
public abstract void environmentalModificationMelee(SpellParadigmMelee parad);
|
|
|
|
|
|
|
|
public int getCostForProjectile()
|
|
|
|
{
|
|
|
|
switch(this.modifierState)
|
|
|
|
{
|
|
|
|
case SpellModifier.DEFAULT: return this.getCostForDefaultProjectile();
|
|
|
|
case SpellModifier.OFFENSIVE: return this.getCostForOffenseProjectile();
|
|
|
|
case SpellModifier.DEFENSIVE: return this.getCostForDefenseProjectile();
|
|
|
|
case SpellModifier.ENVIRONMENTAL: return this.getCostForEnvironmentProjectile();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-01-18 23:05:25 +00:00
|
|
|
protected abstract int getCostForDefaultProjectile();
|
|
|
|
protected abstract int getCostForOffenseProjectile();
|
|
|
|
protected abstract int getCostForDefenseProjectile();
|
|
|
|
protected abstract int getCostForEnvironmentProjectile();
|
2014-01-18 16:45:31 +00:00
|
|
|
|
|
|
|
public int getCostForSelf()
|
|
|
|
{
|
|
|
|
switch(this.modifierState)
|
|
|
|
{
|
|
|
|
case SpellModifier.DEFAULT: return this.getCostForDefaultSelf();
|
|
|
|
case SpellModifier.OFFENSIVE: return this.getCostForOffenseSelf();
|
|
|
|
case SpellModifier.DEFENSIVE: return this.getCostForDefenseSelf();
|
|
|
|
case SpellModifier.ENVIRONMENTAL: return this.getCostForEnvironmentSelf();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-01-18 23:05:25 +00:00
|
|
|
protected abstract int getCostForDefaultSelf();
|
|
|
|
protected abstract int getCostForOffenseSelf();
|
|
|
|
protected abstract int getCostForDefenseSelf();
|
|
|
|
protected abstract int getCostForEnvironmentSelf();
|
2014-01-18 16:45:31 +00:00
|
|
|
|
|
|
|
public int getCostForMelee()
|
|
|
|
{
|
|
|
|
switch(this.modifierState)
|
|
|
|
{
|
|
|
|
case SpellModifier.DEFAULT: return this.getCostForDefaultMelee();
|
|
|
|
case SpellModifier.OFFENSIVE: return this.getCostForOffenseMelee();
|
|
|
|
case SpellModifier.DEFENSIVE: return this.getCostForDefenseMelee();
|
|
|
|
case SpellModifier.ENVIRONMENTAL: return this.getCostForEnvironmentMelee();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-01-18 23:05:25 +00:00
|
|
|
protected abstract int getCostForDefaultMelee();
|
|
|
|
protected abstract int getCostForOffenseMelee();
|
|
|
|
protected abstract int getCostForDefenseMelee();
|
|
|
|
protected abstract int getCostForEnvironmentMelee();
|
2014-01-19 21:15:10 +00:00
|
|
|
|
|
|
|
public int getPowerEnhancements()
|
|
|
|
{
|
|
|
|
return this.powerEnhancement;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getCostEnhancements()
|
|
|
|
{
|
|
|
|
return this.costEnhancement;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getPotencyEnhancements()
|
|
|
|
{
|
|
|
|
return this.potencyEnhancement;
|
|
|
|
}
|
2014-01-25 14:22:59 +00:00
|
|
|
|
|
|
|
public NBTTagCompound getTag()
|
|
|
|
{
|
|
|
|
NBTTagCompound tag = new NBTTagCompound();
|
|
|
|
|
|
|
|
tag.setString("Class", this.getClass().getName());
|
|
|
|
tag.setInteger("power", powerEnhancement);
|
|
|
|
tag.setInteger("cost", costEnhancement);
|
|
|
|
tag.setInteger("potency", potencyEnhancement);
|
|
|
|
|
|
|
|
return tag;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static SpellEffect getEffectFromTag(NBTTagCompound tag)
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
Class clazz = Class.forName(tag.getString("Class"));
|
|
|
|
if(clazz !=null)
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
Object obj = clazz.newInstance();
|
|
|
|
if(obj instanceof SpellEffect)
|
|
|
|
{
|
|
|
|
SpellEffect eff = (SpellEffect) obj;
|
|
|
|
|
|
|
|
eff.powerEnhancement = tag.getInteger("power");
|
|
|
|
eff.costEnhancement = tag.getInteger("cost");
|
|
|
|
eff.potencyEnhancement = tag.getInteger("potency");
|
|
|
|
|
|
|
|
return eff;
|
|
|
|
}
|
|
|
|
} catch (InstantiationException e) {
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
e.printStackTrace();
|
|
|
|
} catch (IllegalAccessException e) {
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (ClassNotFoundException e) {
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
2014-01-18 00:59:31 +00:00
|
|
|
}
|