Add 1.5x progression modifier for tiers the player has already reached

This commit is contained in:
Electroblob77
2020-06-04 12:27:10 +01:00
parent e54453e6c6
commit 92b54edb4a
4 changed files with 58 additions and 9 deletions
@@ -2,6 +2,7 @@ package electroblob.wizardry.data;
import com.google.common.collect.EvictingQueue;
import electroblob.wizardry.Wizardry;
import electroblob.wizardry.constants.Tier;
import electroblob.wizardry.enchantment.Imbuement;
import electroblob.wizardry.entity.living.ISummonedCreature;
import electroblob.wizardry.event.SpellCastEvent;
@@ -109,6 +110,9 @@ public class WizardData implements INBTSerializable<NBTTagCompound> {
* {@link WizardData#discoverSpell(Spell)} instead. */
public Set<Spell> spellsDiscovered;
/** The highest {@link Tier} this player has upgraded a wand to, used to apply progression modifiers. */
private Tier maxTierReached = Tier.NOVICE;
private Set<UUID> allies;
/** List of usernames of this player's allies. May not be accurate 100% of the time. This is here so that a player
* can view the usernames of their allies even when those allies are not online. <b> Do not use this for any other
@@ -257,6 +261,24 @@ public class WizardData implements INBTSerializable<NBTTagCompound> {
return spellsDiscovered.add(spell);
}
/**
* Sets the tier this player has reached to the given tier, if they have not yet reached it.
* @param tier The tier the player has reached
*/
public void setTierReached(Tier tier){
if(!hasReachedTier(tier)) this.maxTierReached = tier;
}
/**
* Returns true if this player has previously upgraded a wand to the given tier.
* @param tier The tier to check for
* @return True if this player has already upgraded a wand to the given tier, false if not. This does not include
* wands that were purchased at the given tier, unless they have since been upgraded.
*/
public boolean hasReachedTier(Tier tier){
return tier.level >= maxTierReached.level;
}
// Recent spell tracking
/**
@@ -485,6 +507,7 @@ public class WizardData implements INBTSerializable<NBTTagCompound> {
this.allyNames = data.allyNames;
this.selectedMinion = data.selectedMinion;
this.spellsDiscovered = data.spellsDiscovered;
this.maxTierReached = data.maxTierReached;
this.recentSpells = data.recentSpells;
for(IVariable variable : data.spellData.keySet()){
@@ -530,6 +553,8 @@ public class WizardData implements INBTSerializable<NBTTagCompound> {
}
properties.setIntArray("discoveredSpells", spells);
properties.setInteger("maxTierReached", maxTierReached.ordinal());
NBTExtras.storeTagSafely(properties, "recentSpells", NBTExtras.listToNBT(recentSpells, s -> new NBTTagInt(s.metadata())));
storedVariables.forEach(k -> k.write(properties, this.spellData.get(k)));
@@ -553,6 +578,8 @@ public class WizardData implements INBTSerializable<NBTTagCompound> {
spellsDiscovered.add(Spell.byMetadata(id));
}
this.maxTierReached = Tier.values()[nbt.getInteger("maxTierReached")];
// Probably won't be null but we may as well just reinitialise it instead of clearing it
this.recentSpells = EvictingQueue.create(MAX_RECENT_SPELLS);
this.recentSpells.addAll(NBTExtras.NBTToList(nbt.getTagList("recentSpells", NBT.TAG_INT),