Skip to content

Commit

Permalink
PlayerStats
Browse files Browse the repository at this point in the history
  • Loading branch information
LittleWhole committed May 23, 2022
1 parent 349aeb8 commit 0b02a03
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 14 deletions.
12 changes: 2 additions & 10 deletions src/entities/units/player/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public PlayerState getState() {
protected Arte move;
protected int queue;
protected PlayableCharacter character;
protected PlayerStats stats;
// Abbreviations: LVL, EXP, HP, ATK, DEF, CR, CD, EATK, EDEF, AFF

public Player(Coordinate pos) throws SlickException {
Expand Down Expand Up @@ -191,21 +190,14 @@ public void battleRender(Graphics g, float plrX, float plrY) {

public void gainExp(int amount) {
this.character.gainExp(amount);
this.stats.exp+=amount;
}
public void gainMoney(int amount) {
this.stats.gold+=amount;
}

public int getExp() {
return this.stats.exp;
}
public int getMoney() {
return this.stats.gold;
return character.getExp();
}

public int getLevel() {
return this.stats.level;
return character.getLevel();
}

@Override
Expand Down
8 changes: 4 additions & 4 deletions src/gamestates/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ public void render(GameContainer gc, StateBasedGame sbg, Graphics g) throws Slic
npc.render(gc, plrPosition.getX(), plrPosition.getY());
plr.render(g);
g.drawString("Coords: " + plr.getPosition().toString(), 100, 200);
DrawUtilities.drawStringCentered(g,"Level: " + plr.getLevel(), 100, 50);
DrawUtilities.drawStringCentered(g, "Exp: " + plr.getExp(), 100, 100);
DrawUtilities.drawStringCentered(g, "Money: " + plr.getMoney(), 100, 150);
DrawUtilities.drawStringCentered(g,"Level: " + Main.stats.level, 100, 50);
DrawUtilities.drawStringCentered(g, "Exp: " + Main.stats.exp + "/" + Main.stats.maxExp, 100, 100);
DrawUtilities.drawStringCentered(g, "Gold: " + Main.stats.gold, 100, 150);
if(Main.debug) {
plr.drawHitBox(g);
enemy.drawHitBox(g);
Expand Down Expand Up @@ -183,7 +183,7 @@ public void update(GameContainer gc, StateBasedGame sbg, int delta) throws Slick
public void enter(GameContainer gc, StateBasedGame sbg) throws SlickException {
System.out.println("Entering game");
plr.gainExp(BattleState.expGain);
plr.gainMoney(BattleState.currencyGain);
Main.stats.gainGold(BattleState.currencyGain);
// Reset time
time = 0;
System.out.println("[VERBOSE] Time reset");
Expand Down
20 changes: 20 additions & 0 deletions src/playerdata/PlayerStats.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,25 @@ public PlayerStats() {

public void update() {
maxExp = Constants.LevelingConstants.MAX_EXP(level);
if (exp >= maxExp) {
level++;
exp = exp - maxExp;
}
}

public void gainGold(int amount) {
gold += amount;
}

public void gainExp(int amount) {
exp += amount;
if (exp >= maxExp) {
level++;
exp = exp - maxExp;
}
}

public void gainLevel(int amount) {
level += amount;
}
}

0 comments on commit 0b02a03

Please sign in to comment.