Added the framework for a ritual that grants downgrades (instead of the potion method)

This commit is contained in:
WayofTime 2016-10-08 21:23:16 -04:00
parent 43f86abc58
commit ed8427c04e
13 changed files with 661 additions and 4 deletions

View file

@ -109,7 +109,7 @@ public class LivingArmour implements ILivingArmour
if (nextLevel > currentLevel)
{
int upgradePointDifference = upgrade.getCostOfUpgrade() - upgradeMap.get(key).getCostOfUpgrade();
if (Math.abs(upgradePointDifference) >= 0 && totalUpgradePoints + upgradePointDifference <= maxUpgradePoints)
if (totalUpgradePoints + upgradePointDifference <= maxUpgradePoints)
{
upgradeMap.put(key, upgrade);
totalUpgradePoints += upgradePointDifference;
@ -142,6 +142,36 @@ public class LivingArmour implements ILivingArmour
return false;
}
@Override
public boolean canApplyUpgrade(EntityPlayer user, LivingArmourUpgrade upgrade)
{
String key = upgrade.getUniqueIdentifier();
if (upgradeMap.containsKey(key))
{
//Check if this is a higher level than the previous upgrade
int nextLevel = upgrade.getUpgradeLevel();
int currentLevel = upgradeMap.get(key).getUpgradeLevel();
if (nextLevel > currentLevel)
{
int upgradePointDifference = upgrade.getCostOfUpgrade() - upgradeMap.get(key).getCostOfUpgrade();
if (totalUpgradePoints + upgradePointDifference <= maxUpgradePoints)
{
return true;
}
}
} else
{
int upgradePoints = upgrade.getCostOfUpgrade();
if (totalUpgradePoints + upgradePoints <= maxUpgradePoints)
{
return true;
}
}
return false;
}
@Override
public void notifyPlayerOfUpgrade(EntityPlayer user, LivingArmourUpgrade upgrade)
{