32 lines
473 B
Dart
32 lines
473 B
Dart
class PlayerPoints {
|
|
int xp;
|
|
int gp;
|
|
int sp;
|
|
int level;
|
|
|
|
PlayerPoints({
|
|
required this.xp,
|
|
required this.gp,
|
|
required this.sp,
|
|
required this.level,
|
|
});
|
|
|
|
void addXP(int value) {
|
|
xp += value;
|
|
if (xp >= xpToNextLevel()) {
|
|
levelUp();
|
|
}
|
|
}
|
|
|
|
void addGP(int value) => gp += value;
|
|
void addSP(int value) => sp += value;
|
|
|
|
int xpToNextLevel() => 1000 + (level * 200);
|
|
|
|
void levelUp() {
|
|
level++;
|
|
sp++;
|
|
xp = 0;
|
|
}
|
|
}
|