Fixed saving custom builds.

Work on skill tokens.
This commit is contained in:
Jonathan Williams 2014-04-05 15:53:22 -04:00
parent 05d916de3c
commit db2ae49074
4 changed files with 92 additions and 38 deletions

View File

@ -20,13 +20,14 @@ import mineplex.core.itemstack.ItemStackFactory;
import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType;
import mineplex.minecraft.game.classcombat.Class.repository.token.ClientClassToken;
import mineplex.minecraft.game.classcombat.Class.repository.token.CustomBuildToken;
import mineplex.minecraft.game.classcombat.Class.repository.token.SlotToken;
import mineplex.minecraft.game.classcombat.Skill.ISkill;
import mineplex.minecraft.game.classcombat.Skill.ISkill.SkillType;
import mineplex.minecraft.game.classcombat.Skill.SkillFactory;
public class ClientClass
{
private static int MAX_TOKENS = 100;
private ClassManager _classFactory;
private SkillFactory _skillFactory;
private CoreClient _client;
@ -45,6 +46,9 @@ public class ClientClass
private CustomBuildToken _savingCustomBuild;
public int SkillTokens = MAX_TOKENS;
public ClientClass(ClassManager classFactory, SkillFactory skillFactory, CoreClient client, Donor donor, ClientClassToken token)
{
_classFactory = classFactory;
@ -134,6 +138,9 @@ public class ClientClass
{
_savingCustomBuild.PlayerName = _client.GetPlayerName();
System.out.println("Saving build.");
_savingCustomBuild.printInfo();
_classFactory.GetRepository().SaveCustomBuild(_savingCustomBuild);
_savingCustomBuild = null;
}
@ -150,6 +157,8 @@ public class ClientClass
{
customBuild.Active = true;
_activeCustomBuilds.put(pvpClass, customBuild);
calculateTokens();
}
public CustomBuildToken GetActiveCustomBuild(IPvpClass pvpClass)
@ -192,32 +201,32 @@ public class ClientClass
SetDefaultFeet(ItemStackFactory.Instance.CreateStack(_lastClass.GetBoots()));
if (!customBuild.SwordSkill.isEmpty())
_lastSkillMap.put(SkillType.Sword, new AbstractMap.SimpleEntry<ISkill, Integer>(_skillFactory.GetSkill(customBuild.SwordSkill), customBuild.SwordLevel));
_lastSkillMap.put(SkillType.Sword, new AbstractMap.SimpleEntry<ISkill, Integer>(_skillFactory.GetSkill(customBuild.SwordSkill), customBuild.SwordSkillLevel));
else
_lastSkillMap.remove(SkillType.Sword);
if (!customBuild.AxeSkill.isEmpty())
_lastSkillMap.put(SkillType.Axe, new AbstractMap.SimpleEntry<ISkill, Integer>(_skillFactory.GetSkill(customBuild.AxeSkill), customBuild.AxeLevel));
_lastSkillMap.put(SkillType.Axe, new AbstractMap.SimpleEntry<ISkill, Integer>(_skillFactory.GetSkill(customBuild.AxeSkill), customBuild.AxeSkillLevel));
else
_lastSkillMap.remove(SkillType.Axe);
if (!customBuild.BowSkill.isEmpty())
_lastSkillMap.put(SkillType.Bow, new AbstractMap.SimpleEntry<ISkill, Integer>(_skillFactory.GetSkill(customBuild.BowSkill), customBuild.BowLevel));
_lastSkillMap.put(SkillType.Bow, new AbstractMap.SimpleEntry<ISkill, Integer>(_skillFactory.GetSkill(customBuild.BowSkill), customBuild.BowSkillLevel));
else
_lastSkillMap.remove(SkillType.Bow);
if (!customBuild.ClassPassiveASkill.isEmpty())
_lastSkillMap.put(SkillType.PassiveA, new AbstractMap.SimpleEntry<ISkill, Integer>(_skillFactory.GetSkill(customBuild.ClassPassiveASkill), customBuild.ClassPassiveALevel));
_lastSkillMap.put(SkillType.PassiveA, new AbstractMap.SimpleEntry<ISkill, Integer>(_skillFactory.GetSkill(customBuild.ClassPassiveASkill), customBuild.ClassPassiveASkillLevel));
else
_lastSkillMap.remove(SkillType.PassiveA);
if (!customBuild.ClassPassiveBSkill.isEmpty())
_lastSkillMap.put(SkillType.PassiveB, new AbstractMap.SimpleEntry<ISkill, Integer>(_skillFactory.GetSkill(customBuild.ClassPassiveBSkill), customBuild.ClassPassiveBLevel));
_lastSkillMap.put(SkillType.PassiveB, new AbstractMap.SimpleEntry<ISkill, Integer>(_skillFactory.GetSkill(customBuild.ClassPassiveBSkill), customBuild.ClassPassiveBSkillLevel));
else
_lastSkillMap.remove(SkillType.PassiveB);
if (!customBuild.GlobalPassiveSkill.isEmpty())
_lastSkillMap.put(SkillType.GlobalPassive, new AbstractMap.SimpleEntry<ISkill, Integer>(_skillFactory.GetSkill(customBuild.GlobalPassiveSkill), customBuild.GlobalPassiveLevel));
_lastSkillMap.put(SkillType.GlobalPassive, new AbstractMap.SimpleEntry<ISkill, Integer>(_skillFactory.GetSkill(customBuild.GlobalPassiveSkill), customBuild.GlobalPassiveSkillLevel));
else
_lastSkillMap.remove(SkillType.GlobalPassive);
@ -424,6 +433,8 @@ public class ClientClass
if (IsSavingCustomBuild())
_savingCustomBuild.setSkill(skill, level);
calculateTokens();
}
public void RemoveSkill(ISkill skill)
@ -463,4 +474,40 @@ public class ClientClass
return true;
}
private void calculateTokens()
{
if (_gameClass == null)
return;
CustomBuildToken customBuild = _activeCustomBuilds.get(_gameClass);
SkillTokens = MAX_TOKENS;
ISkill swordSkill = _skillFactory.GetSkill(customBuild.SwordSkill);
ISkill axeSkill = _skillFactory.GetSkill(customBuild.AxeSkill);
ISkill bowSkill = _skillFactory.GetSkill(customBuild.BowSkill);
ISkill classPassiveASkill = _skillFactory.GetSkill(customBuild.ClassPassiveASkill);
ISkill classPassiveBSkill = _skillFactory.GetSkill(customBuild.ClassPassiveBSkill);
ISkill globalPassive = _skillFactory.GetSkill(customBuild.GlobalPassiveSkill);
if (ValidSkill(customBuild.SwordSkill, swordSkill, SkillType.Sword))
SkillTokens -= swordSkill.GetTokenCost() * customBuild.SwordSkillLevel;
if (ValidSkill(customBuild.AxeSkill, axeSkill, SkillType.Axe))
SkillTokens -= axeSkill.GetTokenCost() * customBuild.AxeSkillLevel;
if (ValidSkill(customBuild.BowSkill, bowSkill, SkillType.Bow))
SkillTokens -= bowSkill.GetTokenCost() * customBuild.BowSkillLevel;
if (ValidSkill(customBuild.ClassPassiveASkill, classPassiveASkill, SkillType.PassiveA))
SkillTokens -= classPassiveASkill.GetTokenCost() * customBuild.ClassPassiveASkillLevel;
if (ValidSkill(customBuild.ClassPassiveBSkill, classPassiveBSkill, SkillType.PassiveB))
SkillTokens -= classPassiveBSkill.GetTokenCost() * customBuild.ClassPassiveBSkillLevel;
if (ValidSkill(customBuild.GlobalPassiveSkill, globalPassive, SkillType.GlobalPassive))
SkillTokens -= globalPassive.GetTokenCost() * customBuild.GlobalPassiveSkillLevel;
}
}

View File

@ -18,22 +18,22 @@ public class CustomBuildToken
public String PvpClass = "";
public String SwordSkill = "";
public Integer SwordLevel = 0;
public Integer SwordSkillLevel = 0;
public String AxeSkill = "";
public Integer AxeLevel = 0;
public Integer AxeSkillLevel = 0;
public String BowSkill = "";
public Integer BowLevel = 0;
public Integer BowSkillLevel = 0;
public String ClassPassiveASkill = "";
public Integer ClassPassiveALevel = 0;
public Integer ClassPassiveASkillLevel = 0;
public String ClassPassiveBSkill = "";
public Integer ClassPassiveBLevel = 0;
public Integer ClassPassiveBSkillLevel = 0;
public String GlobalPassiveSkill = "";
public Integer GlobalPassiveLevel = 0;
public Integer GlobalPassiveSkillLevel = 0;
public List<SlotToken> Slots = new ArrayList<SlotToken>();
@ -49,22 +49,22 @@ public class CustomBuildToken
System.out.println("PvpClass : " + PvpClass);
System.out.println("SwordSkill : " + SwordSkill);
System.out.println("SwordLevel : " + SwordLevel);
System.out.println("SwordLevel : " + SwordSkillLevel);
System.out.println("AxeSkill : " + AxeSkill);
System.out.println("AxeLevel : " + AxeLevel);
System.out.println("AxeLevel : " + AxeSkillLevel);
System.out.println("BowSkill : " + BowSkill);
System.out.println("BowLevel : " + BowLevel);
System.out.println("BowLevel : " + BowSkillLevel);
System.out.println("ClassPassiveASkill : " + ClassPassiveASkill);
System.out.println("ClassPassiveALevel : " + ClassPassiveALevel);
System.out.println("ClassPassiveALevel : " + ClassPassiveASkillLevel);
System.out.println("ClassPassiveBSkill : " + ClassPassiveBSkill);
System.out.println("ClassPassiveBLevel : " + ClassPassiveBLevel);
System.out.println("ClassPassiveBLevel : " + ClassPassiveBSkillLevel);
System.out.println("GlobalPassiveSkill : " + GlobalPassiveSkill);
System.out.println("GlobalPassiveLevel : " + GlobalPassiveLevel);
System.out.println("GlobalPassiveLevel : " + GlobalPassiveSkillLevel);
for (SlotToken token : Slots)
{
@ -78,29 +78,29 @@ public class CustomBuildToken
{
case Axe:
AxeSkill = skill.GetName();
AxeLevel = level;
AxeSkillLevel = level;
break;
case Bow:
BowSkill = skill.GetName();
BowLevel = level;
BowSkillLevel = level;
break;
case Class:
break;
case GlobalPassive:
GlobalPassiveSkill = skill.GetName();
GlobalPassiveLevel = level;
GlobalPassiveSkillLevel = level;
break;
case PassiveA:
ClassPassiveASkill = skill.GetName();
ClassPassiveALevel = level;
ClassPassiveASkillLevel = level;
break;
case PassiveB:
ClassPassiveBSkill = skill.GetName();
ClassPassiveBLevel = level;
ClassPassiveBSkillLevel = level;
break;
case Sword:
SwordSkill = skill.GetName();
SwordLevel = level;
SwordSkillLevel = level;
break;
default:
break;
@ -122,17 +122,17 @@ public class CustomBuildToken
switch (skill.GetSkillType())
{
case Axe:
return AxeLevel;
return AxeSkillLevel;
case Bow:
return BowLevel;
return BowSkillLevel;
case GlobalPassive:
return GlobalPassiveLevel;
return GlobalPassiveSkillLevel;
case PassiveA:
return ClassPassiveALevel;
return ClassPassiveASkillLevel;
case PassiveB:
return ClassPassiveBLevel;
return ClassPassiveBSkillLevel;
case Sword:
return SwordLevel;
return SwordSkillLevel;
default:
return 0;
}

View File

@ -1,7 +1,6 @@
package mineplex.minecraft.game.classcombat.shop.page;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import mineplex.core.account.CoreClientManager;
@ -59,6 +58,8 @@ public class SkillPage extends ShopPageBase<ClassShopManager, ClassCombatShop>
ClientClass clientClass = Plugin.GetClassManager().Get(Player);
System.out.println("Custombuild being displayed.");
clientClass.GetSavingCustomBuild().printInfo();
BuildClassSkills(_pvpClass, clientClass);
BuildGlobalSkills(clientClass);
//BuildItemPacks();
@ -136,10 +137,7 @@ public class SkillPage extends ShopPageBase<ClassShopManager, ClassCombatShop>
String name = (locked ? ChatColor.RED + skill.GetName() + " (Locked)" : skill.GetName() +
ChatColor.RESET + C.Bold + " - " + ChatColor.GREEN + C.Bold + "Level " + (hasSkill ? level : 0) + "/" + skill.getMaxLevel());
//XXX Need this
int remainingTokens = 9999;
if (locked)
{
skillLore.add(C.cYellow + skill.GetGemCost() + " Gems");
@ -155,10 +153,10 @@ public class SkillPage extends ShopPageBase<ClassShopManager, ClassCombatShop>
if (!hasSkill || level < skill.getMaxLevel())
{
skillLore.add(C.cYellow + "Skill Token Cost: " + C.cWhite + skill.GetTokenCost());
skillLore.add(C.cYellow + "Skill Tokens Remaining: " + C.cWhite + remainingTokens);
skillLore.add(C.cYellow + "Skill Tokens Remaining: " + C.cWhite + clientClass.SkillTokens);
skillLore.add("");
if (remainingTokens >= skill.GetTokenCost())
if (clientClass.SkillTokens >= skill.GetTokenCost())
{
if (hasSkill)
skillLore.add(C.cGreen + "Left-Click to Upgrade to Level " + (level + 1));

View File

@ -18,13 +18,22 @@
PvpClass = customBuild.PvpClass;
SwordSkill = customBuild.SwordSkill;
SwordSkillLevel = customBuild.SwordSkillLevel;
AxeSkill = customBuild.AxeSkill;
AxeSkillLevel = customBuild.AxeSkillLevel;
BowSkill = customBuild.BowSkill;
BowSkillLevel = customBuild.BowSkillLevel;
ClassPassiveASkill = customBuild.ClassPassiveASkill;
ClassPassiveASkillLevel = customBuild.ClassPassiveASkillLevel;
ClassPassiveBSkill = customBuild.ClassPassiveBSkill;
ClassPassiveBSkillLevel = customBuild.ClassPassiveBSkillLevel;
GlobalPassiveSkill = customBuild.GlobalPassiveSkill;
GlobalPassiveSkillLevel = customBuild.GlobalPassiveSkillLevel;
Slots = new List<SlotToken>();