halaman baru
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user