From 7c983d04a35b8deec1d04c2cd92220826a921d18 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Thu, 12 Jan 2023 20:35:25 -0600 Subject: [PATCH] refine stat point check --- src/engine/objects/PlayerCharacter.java | 53 ++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/src/engine/objects/PlayerCharacter.java b/src/engine/objects/PlayerCharacter.java index d34aa21a..361ec648 100644 --- a/src/engine/objects/PlayerCharacter.java +++ b/src/engine/objects/PlayerCharacter.java @@ -1302,7 +1302,6 @@ public class PlayerCharacter extends AbstractCharacter { this.calculateSkills(); return true; } - public boolean refineSpi() { boolean worked = false; short newSpi = (short) 0; @@ -1357,6 +1356,58 @@ public class PlayerCharacter extends AbstractCharacter { } } } + + //insert test run for lowered focus lines with trained spells + boolean tester = false; + switch(stat){ + case MBServerStatics.STAT_STR_ID: + tester = refineStr(); + break; + case MBServerStatics.STAT_DEX_ID: + tester = refineDex(); + break; + case MBServerStatics.STAT_CON_ID: + tester = refineCon(); + break; + case MBServerStatics.STAT_INT_ID: + tester = refineInt(null); + break; + case MBServerStatics.STAT_SPI_ID: + tester = refineSpi(); + break; + } + //loop through all skills and all powers to ensure that the refine doesn't yield a power no longer able to be cast + for(CharacterSkill charSkill : this.getSkills().values()) { + for (CharacterPower power : this.getPowers().values()) { + ArrayList reqs = PowerReq.getPowerReqsForRune(power.getPowerID()); + for (PowerReq req : reqs) { + ConcurrentHashMap playerSkills = this.getSkills(); + CharacterSkill playerSkill = playerSkills.get(charSkill.getToken()); + int currentSkillLevel = playerSkill.getTotalSkillPercet(); + if (charSkill.getToken() == req.getToken() && req.getLevel() > currentSkillLevel) { + //refund the point taken in the test + switch(stat){ + case MBServerStatics.STAT_STR_ID: + this.addStr(1); + break; + case MBServerStatics.STAT_DEX_ID: + this.addDex(1); + break; + case MBServerStatics.STAT_CON_ID: + this.addCon(1); + break; + case MBServerStatics.STAT_INT_ID: + this.addInt(1); + break; + case MBServerStatics.STAT_SPI_ID: + this.addSpi(1); + break; + } + return false; + } + } + } + } return true; }