Skip to content

Commit bf6c672

Browse files
committed
Read points earned and level from database
1 parent e122651 commit bf6c672

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

src/main/java/br/com/pinter/tqrespec/gui/AttributesPaneController.java

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ public class AttributesPaneController implements Initializable {
7878
private int lifeMin;
7979
private int manaStep;
8080
private int manaMin;
81+
private int attrPointsStep;
82+
private int skillPointsStep;
83+
private int maxLevel;
8184
private boolean characterIsLoading = false;
8285

8386
@Inject
@@ -362,27 +365,27 @@ private void setSkillField(int value) {
362365
}
363366

364367
private void setCharLevelField(int value) {
365-
if (value < 1 || value > 85) {
368+
if (value < 1 || value > maxLevel) {
366369
return;
367370
}
368371
charLevelProperty = playerProps().charLevelProperty().asObject();
369372
LevelIntegerSpinnerValueFactory charLevelFactory = new LevelIntegerSpinnerValueFactory(
370-
1, 85, playerProps().getAttrAvailable(), playerProps().attrAvailableProperty(), playerProps().skillAvailableProperty());
373+
1, maxLevel, playerProps().getAttrAvailable(), playerProps().attrAvailableProperty(), playerProps().skillAvailableProperty());
371374
charLevelSpinner.setValueFactory(charLevelFactory);
372375
charLevelSpinner.getValueFactory().valueProperty().bindBidirectional(charLevelProperty);
373376
playerProps().charLevelProperty().addListener(
374377
(observable, oldValue, newValue) -> {
375378
if (newValue.intValue() > oldValue.intValue()) {
376-
playerProps().setAttrAvailable(playerProps().getAttrAvailable() + 2);
377-
playerProps().setSkillAvailable(playerProps().getSkillAvailable() + 3);
379+
playerProps().setAttrAvailable(playerProps().getAttrAvailable() + attrPointsStep);
380+
playerProps().setSkillAvailable(playerProps().getSkillAvailable() + skillPointsStep);
378381
}
379382

380383
if (newValue.intValue() < oldValue.intValue()) {
381-
if (mc.isFreeLvl() && (playerProps().getAttrAvailable() - 2) >= 0 || !mc.isFreeLvl()) {
382-
playerProps().setAttrAvailable(playerProps().getAttrAvailable() - 2);
384+
if (mc.isFreeLvl() && (playerProps().getAttrAvailable() - attrPointsStep) >= 0 || !mc.isFreeLvl()) {
385+
playerProps().setAttrAvailable(playerProps().getAttrAvailable() - attrPointsStep);
383386
}
384-
if (mc.isFreeLvl() && (playerProps().getSkillAvailable() - 3) >= 0 || !mc.isFreeLvl()) {
385-
playerProps().setSkillAvailable(playerProps().getSkillAvailable() - 3);
387+
if (mc.isFreeLvl() && (playerProps().getSkillAvailable() - skillPointsStep) >= 0 || !mc.isFreeLvl()) {
388+
playerProps().setSkillAvailable(playerProps().getSkillAvailable() - skillPointsStep);
386389
}
387390
}
388391
playerProps().setCharLevel(newValue.intValue());
@@ -493,6 +496,9 @@ public void loadCharHandler() {
493496
lifeMin = Math.round(db.player().getPc().getCharacterLife());
494497
manaStep = db.player().getPlayerLevels().getManaIncrement();
495498
manaMin = Math.round(db.player().getPc().getCharacterMana());
499+
attrPointsStep = db.player().getPlayerLevels().getCharacterModifierPoints();
500+
skillPointsStep = db.player().getPlayerLevels().getSkillModifierPoints();
501+
maxLevel = db.player().getPlayerLevels().getMaxPlayerLevel();
496502

497503
clearProperties();
498504
if (playerProps().getAttrAvailable() < 0 || playerProps().getStr() < 0 || playerProps().getDex() < 0
@@ -666,7 +672,8 @@ public void decrement(int v) {
666672
int step = v * this.getAmountToStepBy();
667673
int newValue = oldValue - step;
668674

669-
if (newValue >= this.getMin() && ((!mc.isFreeLvl() && attrAvailable.get() >= 2 && skillAvailable.get() >= 3) || mc.isFreeLvl())) {
675+
if (newValue >= this.getMin() && ((!mc.isFreeLvl() && attrAvailable.get() >= attrPointsStep && skillAvailable.get() >= skillPointsStep)
676+
|| mc.isFreeLvl())) {
670677
setValue(newValue);
671678
}
672679
}

0 commit comments

Comments
 (0)