Started working on allowing RitualDiviner to do directions.
Completed refactorization of spell system. Increased protection against void damage while void sigil is in Bound Armour. Added an OnRitualStop with an Enum input providing the action. Added more events.
This commit is contained in:
parent
69abce8f85
commit
beea2e875a
97 changed files with 4234 additions and 1414 deletions
|
@ -0,0 +1,11 @@
|
|||
package WayofTime.alchemicalWizardry.api.rituals;
|
||||
|
||||
public enum RitualBreakMethod
|
||||
{
|
||||
REDSTONE,
|
||||
BREAK_MRS,
|
||||
BREAK_STONE,
|
||||
ACTIVATE, //When an activation crystal activates the MRS, overwriting the current ritual
|
||||
DEACTIVATE,
|
||||
EXPLOSION, //When the MRS is destroyed by an explosion
|
||||
}
|
|
@ -38,16 +38,34 @@ public class RitualComponent
|
|||
|
||||
public int getX(int direction)
|
||||
{
|
||||
return this.x;
|
||||
switch(direction)
|
||||
{
|
||||
case 2:
|
||||
return -this.getZ();
|
||||
case 3:
|
||||
return -this.getX();
|
||||
case 4:
|
||||
return this.getZ();
|
||||
default: return this.getX();
|
||||
}
|
||||
}
|
||||
|
||||
public int getZ(int direction)
|
||||
{
|
||||
return this.z;
|
||||
switch(direction)
|
||||
{
|
||||
case 2:
|
||||
return this.getX();
|
||||
case 3:
|
||||
return -this.getZ();
|
||||
case 4:
|
||||
return -this.getX();
|
||||
default: return this.getZ();
|
||||
}
|
||||
}
|
||||
|
||||
public int getStoneType()
|
||||
{
|
||||
return this.stoneType;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +1,11 @@
|
|||
package WayofTime.alchemicalWizardry.api.rituals;
|
||||
|
||||
import WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent;
|
||||
import WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentStack;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.List;
|
||||
import WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent;
|
||||
import WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentStack;
|
||||
|
||||
public abstract class RitualEffect
|
||||
{
|
||||
|
@ -16,7 +16,7 @@ public abstract class RitualEffect
|
|||
return true;
|
||||
}
|
||||
|
||||
public void onRitualBroken(IMasterRitualStone ritualStone)
|
||||
public void onRitualBroken(IMasterRitualStone ritualStone, RitualBreakMethod method)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -324,16 +324,18 @@ public class Rituals
|
|||
return false;
|
||||
}
|
||||
|
||||
public static void onRitualBroken(IMasterRitualStone ritualStone, String ritualID)
|
||||
public static void onRitualBroken(IMasterRitualStone ritualStone, String ritualID, RitualBreakMethod method)
|
||||
{
|
||||
if (ritualMap.containsKey(ritualID))
|
||||
{
|
||||
Rituals ritual = ritualMap.get(ritualID);
|
||||
if (ritual != null && ritual.effect != null)
|
||||
{
|
||||
ritual.effect.onRitualBroken(ritualStone);
|
||||
ritual.effect.onRitualBroken(ritualStone, method);
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println(method);
|
||||
}
|
||||
|
||||
public static int getNumberOfRituals()
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
package WayofTime.alchemicalWizardry.api.spell;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public abstract class ComplexSpellEffect
|
||||
{
|
||||
public final ComplexSpellType type;
|
||||
public final ComplexSpellModifier modifier;
|
||||
|
||||
protected int powerEnhancement;
|
||||
protected int costEnhancement;
|
||||
protected int potencyEnhancement;
|
||||
|
||||
public ComplexSpellEffect(ComplexSpellType type, ComplexSpellModifier modifier)
|
||||
{
|
||||
this.type = type;
|
||||
this.modifier = modifier;
|
||||
}
|
||||
|
||||
public ComplexSpellEffect(ComplexSpellType type, ComplexSpellModifier modifier, int power, int cost, int potency)
|
||||
{
|
||||
this(type, modifier);
|
||||
|
||||
this.powerEnhancement = power;
|
||||
this.costEnhancement = cost;
|
||||
this.potencyEnhancement = potency;
|
||||
}
|
||||
|
||||
public abstract void modifyParadigm(SpellParadigm parad);
|
||||
|
||||
public ComplexSpellType getType()
|
||||
{
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public ComplexSpellModifier getModifier()
|
||||
{
|
||||
return this.modifier;
|
||||
}
|
||||
|
||||
public abstract ComplexSpellEffect copy(int power, int cost, int potency);
|
||||
|
||||
public abstract int getCostOfEffect();
|
||||
|
||||
// public NBTTagCompound getTag()
|
||||
// {
|
||||
// NBTTagCompound tag = new NBTTagCompound();
|
||||
//
|
||||
// tag.setString("Class", this.getClass().getName());
|
||||
// tag.setInteger("modifier", modifierState);
|
||||
// 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.modifierState = tag.getInteger("modifier");
|
||||
// eff.powerEnhancement = tag.getInteger("power");
|
||||
// eff.costEnhancement = tag.getInteger("cost");
|
||||
// eff.potencyEnhancement = tag.getInteger("potency");
|
||||
//
|
||||
// return eff;
|
||||
// }
|
||||
// } catch (InstantiationException e)
|
||||
// {
|
||||
// e.printStackTrace();
|
||||
// } catch (IllegalAccessException e)
|
||||
// {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
// } catch (ClassNotFoundException e)
|
||||
// {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package WayofTime.alchemicalWizardry.api.spell;
|
||||
|
||||
public class ComplexSpellModifier
|
||||
{
|
||||
public static ComplexSpellModifier DEFAULT = new ComplexSpellModifier();
|
||||
public static ComplexSpellModifier OFFENSIVE = new ComplexSpellModifier();
|
||||
public static ComplexSpellModifier DEFENSIVE = new ComplexSpellModifier();
|
||||
public static ComplexSpellModifier ENVIRONMENTAL = new ComplexSpellModifier();
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package WayofTime.alchemicalWizardry.api.spell;
|
||||
|
||||
public class ComplexSpellType
|
||||
{
|
||||
public static ComplexSpellType FIRE = new ComplexSpellType();
|
||||
public static ComplexSpellType ICE = new ComplexSpellType();
|
||||
public static ComplexSpellType EARTH = new ComplexSpellType();
|
||||
public static ComplexSpellType WIND = new ComplexSpellType();
|
||||
}
|
|
@ -0,0 +1,501 @@
|
|||
package WayofTime.alchemicalWizardry.api.spell;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import WayofTime.alchemicalWizardry.common.spell.complex.enhancement.SpellEnhancement;
|
||||
|
||||
/**
|
||||
* New wrapper class to enclose the ComplexSpellEffect
|
||||
*/
|
||||
public class SpellEffect
|
||||
{
|
||||
public ComplexSpellType type;
|
||||
public ComplexSpellModifier modifier;
|
||||
|
||||
protected int powerEnhancement;
|
||||
protected int costEnhancement;
|
||||
protected int potencyEnhancement;
|
||||
|
||||
public SpellEffect()
|
||||
{
|
||||
this(ComplexSpellType.FIRE);
|
||||
}
|
||||
|
||||
public SpellEffect(ComplexSpellType type)
|
||||
{
|
||||
this(type, ComplexSpellModifier.DEFAULT);
|
||||
}
|
||||
|
||||
public SpellEffect(ComplexSpellType type, ComplexSpellModifier modifier)
|
||||
{
|
||||
this.type = type;
|
||||
this.modifier = modifier;
|
||||
|
||||
this.powerEnhancement = 0;
|
||||
this.potencyEnhancement = 0;
|
||||
this.costEnhancement = 0;
|
||||
}
|
||||
|
||||
public void enhanceEffect(SpellEnhancement enh)
|
||||
{
|
||||
if (enh != null)
|
||||
{
|
||||
switch (enh.getState())
|
||||
{
|
||||
case SpellEnhancement.POWER:
|
||||
this.powerEnhancement++;
|
||||
break;
|
||||
case SpellEnhancement.EFFICIENCY:
|
||||
this.costEnhancement++;
|
||||
break;
|
||||
case SpellEnhancement.POTENCY:
|
||||
this.potencyEnhancement++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void modifyEffect(ComplexSpellModifier mod)
|
||||
{
|
||||
if(mod != null)
|
||||
{
|
||||
this.modifier = mod;
|
||||
}
|
||||
}
|
||||
|
||||
public void modifyParadigm(SpellParadigm parad) //When modifying the paradigm it will instead get the class name and ask the registry
|
||||
{
|
||||
if(parad == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Class paraClass = parad.getClass();
|
||||
|
||||
ComplexSpellEffect effect = SpellEffectRegistry.getSpellEffect(paraClass, type, modifier, powerEnhancement, potencyEnhancement, costEnhancement);
|
||||
|
||||
if(effect != null)
|
||||
{
|
||||
effect.modifyParadigm(parad);
|
||||
}
|
||||
}
|
||||
|
||||
public int getCostOfEffect(SpellParadigm parad)
|
||||
{
|
||||
if(parad == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
Class paraClass = parad.getClass();
|
||||
|
||||
ComplexSpellEffect effect = SpellEffectRegistry.getSpellEffect(paraClass, type, modifier, powerEnhancement, potencyEnhancement, costEnhancement);
|
||||
|
||||
if(effect == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return effect.getCostOfEffect();
|
||||
}
|
||||
|
||||
public NBTTagCompound getTag()
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
|
||||
tag.setString("Class", this.getClass().getName());
|
||||
tag.setString("type", SpellEffectRegistry.getKeyForType(type));
|
||||
tag.setString("modifier", SpellEffectRegistry.getKeyForModifier(modifier));
|
||||
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.type = SpellEffectRegistry.getTypeForKey(tag.getString("type"));
|
||||
eff.modifier = SpellEffectRegistry.getModifierForKey(tag.getString("modifier"));
|
||||
eff.powerEnhancement = tag.getInteger("power");
|
||||
eff.costEnhancement = tag.getInteger("cost");
|
||||
eff.potencyEnhancement = tag.getInteger("potency");
|
||||
|
||||
return eff;
|
||||
}
|
||||
} catch (InstantiationException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
} catch (ClassNotFoundException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getPowerEnhancements()
|
||||
{
|
||||
return this.powerEnhancement;
|
||||
}
|
||||
|
||||
public int getPotencyEnhancements()
|
||||
{
|
||||
return this.potencyEnhancement;
|
||||
}
|
||||
|
||||
public int getCostEnhancements()
|
||||
{
|
||||
return this.costEnhancement;
|
||||
}
|
||||
}
|
||||
|
||||
//package WayofTime.alchemicalWizardry.common.spell.complex.effect;
|
||||
//
|
||||
//import WayofTime.alchemicalWizardry.common.spell.complex.*;
|
||||
//import WayofTime.alchemicalWizardry.common.spell.complex.enhancement.SpellEnhancement;
|
||||
//import net.minecraft.nbt.NBTTagCompound;
|
||||
//
|
||||
//public abstract class SpellEffect
|
||||
//{
|
||||
// protected int modifierState;
|
||||
// protected int powerEnhancement;
|
||||
// protected int costEnhancement;
|
||||
// protected int potencyEnhancement;
|
||||
//
|
||||
// public SpellEffect()
|
||||
// {
|
||||
// this.modifierState = SpellModifier.DEFAULT;
|
||||
// this.powerEnhancement = 0;
|
||||
// this.costEnhancement = 0;
|
||||
// this.potencyEnhancement = 0;
|
||||
// }
|
||||
//
|
||||
// public void enhanceEffect(SpellEnhancement enh)
|
||||
// {
|
||||
// if (enh != null)
|
||||
// {
|
||||
// switch (enh.getState())
|
||||
// {
|
||||
// case SpellEnhancement.POWER:
|
||||
// this.powerEnhancement++;
|
||||
// break;
|
||||
// case SpellEnhancement.EFFICIENCY:
|
||||
// this.costEnhancement++;
|
||||
// break;
|
||||
// case SpellEnhancement.POTENCY:
|
||||
// this.potencyEnhancement++;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public void modifyEffect(SpellModifier mod)
|
||||
// {
|
||||
// if (mod != null)
|
||||
// modifierState = mod.getModifier();
|
||||
// }
|
||||
//
|
||||
// public void modifyParadigm(SpellParadigm parad) //When modifying the paradigm it will instead get the class name and ask the registry
|
||||
// {
|
||||
// if (parad instanceof SpellParadigmProjectile)
|
||||
// {
|
||||
// this.modifyProjectileParadigm((SpellParadigmProjectile) parad);
|
||||
// }
|
||||
// if (parad instanceof SpellParadigmSelf)
|
||||
// {
|
||||
// this.modifySelfParadigm((SpellParadigmSelf) parad);
|
||||
// }
|
||||
// if (parad instanceof SpellParadigmMelee)
|
||||
// {
|
||||
// this.modifyMeleeParadigm((SpellParadigmMelee) parad);
|
||||
// }
|
||||
// if (parad instanceof SpellParadigmTool)
|
||||
// {
|
||||
// this.modifyToolParadigm((SpellParadigmTool) parad);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// 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);
|
||||
//
|
||||
// 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 void modifyToolParadigm(SpellParadigmTool parad)
|
||||
// {
|
||||
// switch (modifierState)
|
||||
// {
|
||||
// case SpellModifier.DEFAULT:
|
||||
// this.defaultModificationTool(parad);
|
||||
// break;
|
||||
// case SpellModifier.OFFENSIVE:
|
||||
// this.offensiveModificationTool(parad);
|
||||
// break;
|
||||
// case SpellModifier.DEFENSIVE:
|
||||
// this.defensiveModificationTool(parad);
|
||||
// break;
|
||||
// case SpellModifier.ENVIRONMENTAL:
|
||||
// this.environmentalModificationTool(parad);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public abstract void defaultModificationTool(SpellParadigmTool parad);
|
||||
//
|
||||
// public abstract void offensiveModificationTool(SpellParadigmTool parad);
|
||||
//
|
||||
// public abstract void defensiveModificationTool(SpellParadigmTool parad);
|
||||
//
|
||||
// public abstract void environmentalModificationTool(SpellParadigmTool 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;
|
||||
// }
|
||||
//
|
||||
// protected abstract int getCostForDefaultProjectile();
|
||||
//
|
||||
// protected abstract int getCostForOffenseProjectile();
|
||||
//
|
||||
// protected abstract int getCostForDefenseProjectile();
|
||||
//
|
||||
// protected abstract int getCostForEnvironmentProjectile();
|
||||
//
|
||||
// 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;
|
||||
// }
|
||||
//
|
||||
// protected abstract int getCostForDefaultSelf();
|
||||
//
|
||||
// protected abstract int getCostForOffenseSelf();
|
||||
//
|
||||
// protected abstract int getCostForDefenseSelf();
|
||||
//
|
||||
// protected abstract int getCostForEnvironmentSelf();
|
||||
//
|
||||
// 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;
|
||||
// }
|
||||
//
|
||||
// protected abstract int getCostForDefaultMelee();
|
||||
//
|
||||
// protected abstract int getCostForOffenseMelee();
|
||||
//
|
||||
// protected abstract int getCostForDefenseMelee();
|
||||
//
|
||||
// protected abstract int getCostForEnvironmentMelee();
|
||||
//
|
||||
// public int getCostForTool()
|
||||
// {
|
||||
// switch (this.modifierState)
|
||||
// {
|
||||
// case SpellModifier.DEFAULT:
|
||||
// return this.getCostForDefaultTool();
|
||||
// case SpellModifier.OFFENSIVE:
|
||||
// return this.getCostForOffenseTool();
|
||||
// case SpellModifier.DEFENSIVE:
|
||||
// return this.getCostForDefenseTool();
|
||||
// case SpellModifier.ENVIRONMENTAL:
|
||||
// return this.getCostForEnvironmentTool();
|
||||
// }
|
||||
// return 0;
|
||||
// }
|
||||
//
|
||||
// protected abstract int getCostForDefaultTool();
|
||||
//
|
||||
// protected abstract int getCostForOffenseTool();
|
||||
//
|
||||
// protected abstract int getCostForDefenseTool();
|
||||
//
|
||||
// protected abstract int getCostForEnvironmentTool();
|
||||
//
|
||||
// public int getPowerEnhancements()
|
||||
// {
|
||||
// return this.powerEnhancement;
|
||||
// }
|
||||
//
|
||||
// public int getCostEnhancements()
|
||||
// {
|
||||
// return this.costEnhancement;
|
||||
// }
|
||||
//
|
||||
// public int getPotencyEnhancements()
|
||||
// {
|
||||
// return this.potencyEnhancement;
|
||||
// }
|
||||
//
|
||||
// public NBTTagCompound getTag()
|
||||
// {
|
||||
// NBTTagCompound tag = new NBTTagCompound();
|
||||
//
|
||||
// tag.setString("Class", this.getClass().getName());
|
||||
// tag.setInteger("modifier", modifierState);
|
||||
// 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.modifierState = tag.getInteger("modifier");
|
||||
// eff.powerEnhancement = tag.getInteger("power");
|
||||
// eff.costEnhancement = tag.getInteger("cost");
|
||||
// eff.potencyEnhancement = tag.getInteger("potency");
|
||||
//
|
||||
// return eff;
|
||||
// }
|
||||
// } catch (InstantiationException e)
|
||||
// {
|
||||
// e.printStackTrace();
|
||||
// } catch (IllegalAccessException e)
|
||||
// {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
// } catch (ClassNotFoundException e)
|
||||
// {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
//}
|
|
@ -0,0 +1,159 @@
|
|||
package WayofTime.alchemicalWizardry.api.spell;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class SpellEffectRegistry
|
||||
{
|
||||
public static Map<Class<? extends SpellParadigm>, List<ComplexSpellEffect>> effectRegistry = new HashMap();
|
||||
public static Map<String, ComplexSpellType> typeRegistry = new HashMap();
|
||||
public static Map<String, ComplexSpellModifier> modifierRegistry = new HashMap();
|
||||
|
||||
public static void registerSpellEffect(Class<? extends SpellParadigm> paraClass, ComplexSpellEffect effect)
|
||||
{
|
||||
if(paraClass == null || effect == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(effectRegistry.containsKey(paraClass))
|
||||
{
|
||||
List<ComplexSpellEffect> effectList = effectRegistry.get(paraClass);
|
||||
ComplexSpellType type = effect.getType();
|
||||
ComplexSpellModifier modifier = effect.getModifier();
|
||||
|
||||
if(type == null || modifier == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for(ComplexSpellEffect eff : effectList)
|
||||
{
|
||||
if(type.equals(eff.getType()) && modifier.equals(eff.getModifier()))
|
||||
{
|
||||
effectList.remove(eff);
|
||||
effectList.add(effect);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
effectList.add(effect);
|
||||
}else
|
||||
{
|
||||
List<ComplexSpellEffect> effectList = new LinkedList();
|
||||
effectList.add(effect);
|
||||
effectRegistry.put(paraClass, effectList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param paraClass
|
||||
* @param type
|
||||
* @param mod
|
||||
* @return A copy of the spell effect
|
||||
*/
|
||||
public static ComplexSpellEffect getSpellEffect(Class<? extends SpellParadigm> paraClass, ComplexSpellType type, ComplexSpellModifier mod)
|
||||
{
|
||||
return SpellEffectRegistry.getSpellEffect(paraClass, type, mod, 0, 0, 0);
|
||||
}
|
||||
|
||||
public static ComplexSpellEffect getSpellEffect(Class<? extends SpellParadigm> paraClass, ComplexSpellType type, ComplexSpellModifier mod, int power, int potency, int cost)
|
||||
{
|
||||
System.out.println("Debuging");
|
||||
|
||||
if(paraClass == null || type == null || mod == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
List<ComplexSpellEffect> list = effectRegistry.get(paraClass);
|
||||
|
||||
if(list == null || list.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
for(ComplexSpellEffect effect : list)
|
||||
{
|
||||
if(effect != null && type.equals(effect.type) && mod.equals(effect.modifier))
|
||||
{
|
||||
return effect.copy(power, cost, potency);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void registerSpellType(String key, ComplexSpellType type)
|
||||
{
|
||||
typeRegistry.put(key, type);
|
||||
}
|
||||
|
||||
public static void registerSpellModifier(String key, ComplexSpellModifier modifier)
|
||||
{
|
||||
modifierRegistry.put(key, modifier);
|
||||
}
|
||||
|
||||
public static ComplexSpellType getTypeForKey(String key)
|
||||
{
|
||||
return typeRegistry.get(key);
|
||||
}
|
||||
|
||||
public static String getKeyForType(ComplexSpellType type)
|
||||
{
|
||||
if(type == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
for(Entry<String, ComplexSpellType> entry : typeRegistry.entrySet())
|
||||
{
|
||||
if(type.equals(entry.getValue()))
|
||||
{
|
||||
return entry.getKey();
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
public static ComplexSpellModifier getModifierForKey(String key)
|
||||
{
|
||||
return modifierRegistry.get(key);
|
||||
}
|
||||
|
||||
public static String getKeyForModifier(ComplexSpellModifier modifier)
|
||||
{
|
||||
if(modifier == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
for(Entry<String, ComplexSpellModifier> entry : modifierRegistry.entrySet())
|
||||
{
|
||||
if(modifier.equals(entry.getValue()))
|
||||
{
|
||||
return entry.getKey();
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
public static void initiateRegistry()
|
||||
{
|
||||
SpellEffectRegistry.registerSpellType("FIRE", ComplexSpellType.FIRE);
|
||||
SpellEffectRegistry.registerSpellType("WATER", ComplexSpellType.ICE);
|
||||
SpellEffectRegistry.registerSpellType("EARTH", ComplexSpellType.EARTH);
|
||||
SpellEffectRegistry.registerSpellType("AIR", ComplexSpellType.WIND);
|
||||
|
||||
SpellEffectRegistry.registerSpellModifier("DEFAULT", ComplexSpellModifier.DEFAULT);
|
||||
SpellEffectRegistry.registerSpellModifier("OFFENSIVE", ComplexSpellModifier.OFFENSIVE);
|
||||
SpellEffectRegistry.registerSpellModifier("DEFENSIVE", ComplexSpellModifier.DEFENSIVE);
|
||||
SpellEffectRegistry.registerSpellModifier("ENVIRONMENTAL", ComplexSpellModifier.ENVIRONMENTAL);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,132 @@
|
|||
package WayofTime.alchemicalWizardry.api.spell;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import WayofTime.alchemicalWizardry.common.spell.complex.enhancement.SpellEnhancement;
|
||||
|
||||
public abstract class SpellParadigm
|
||||
{
|
||||
protected List<SpellEffect> bufferedEffectList = new LinkedList();
|
||||
|
||||
public void addBufferedEffect(SpellEffect effect)
|
||||
{
|
||||
if (effect != null)
|
||||
{
|
||||
this.bufferedEffectList.add(effect);
|
||||
}
|
||||
}
|
||||
|
||||
public void modifyBufferedEffect(ComplexSpellModifier modifier)
|
||||
{
|
||||
SpellEffect effect = this.getBufferedEffect();
|
||||
if (effect != null)
|
||||
{
|
||||
effect.modifyEffect(modifier);
|
||||
}
|
||||
}
|
||||
|
||||
public void applyEnhancement(SpellEnhancement enh)
|
||||
{
|
||||
if (enh != null)
|
||||
{
|
||||
if (bufferedEffectList.isEmpty())
|
||||
{
|
||||
this.enhanceParadigm(enh);
|
||||
} else
|
||||
{
|
||||
SpellEffect effect = this.getBufferedEffect();
|
||||
if (effect != null)
|
||||
{
|
||||
effect.enhanceEffect(enh);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public abstract void enhanceParadigm(SpellEnhancement enh);
|
||||
|
||||
public abstract void castSpell(World world, EntityPlayer entityPlayer, ItemStack itemStack);
|
||||
|
||||
public void applySpellEffect(SpellEffect effect)
|
||||
{
|
||||
effect.modifyParadigm(this);
|
||||
}
|
||||
|
||||
public void applyAllSpellEffects()
|
||||
{
|
||||
for (SpellEffect effect : bufferedEffectList)
|
||||
{
|
||||
this.applySpellEffect(effect);
|
||||
}
|
||||
}
|
||||
|
||||
public SpellEffect getBufferedEffect()
|
||||
{
|
||||
if (bufferedEffectList.isEmpty())
|
||||
{
|
||||
return null;
|
||||
} else
|
||||
{
|
||||
return bufferedEffectList.get(bufferedEffectList.size() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
public int getTotalCost()
|
||||
{
|
||||
int cost = 0;
|
||||
if (this.bufferedEffectList != null && !this.bufferedEffectList.isEmpty())
|
||||
{
|
||||
for(SpellEffect effect : bufferedEffectList)
|
||||
{
|
||||
cost += effect.getCostOfEffect(this);
|
||||
}
|
||||
|
||||
return (int) (cost * Math.sqrt(this.bufferedEffectList.size()));
|
||||
}
|
||||
|
||||
return getDefaultCost();
|
||||
}
|
||||
|
||||
public abstract int getDefaultCost();
|
||||
|
||||
public int getBufferedEffectPower()
|
||||
{
|
||||
SpellEffect eff = this.getBufferedEffect();
|
||||
|
||||
if (eff != null)
|
||||
{
|
||||
return eff.getPowerEnhancements();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getBufferedEffectCost()
|
||||
{
|
||||
SpellEffect eff = this.getBufferedEffect();
|
||||
|
||||
if (eff != null)
|
||||
{
|
||||
return eff.getCostEnhancements();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getBufferedEffectPotency()
|
||||
{
|
||||
SpellEffect eff = this.getBufferedEffect();
|
||||
|
||||
if (eff != null)
|
||||
{
|
||||
return eff.getPotencyEnhancements();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue