2022-06-21 22:18:13 +08:00
|
|
|
package emu.grasscutter.game.battlepass;
|
|
|
|
|
2022-06-21 07:59:10 -07:00
|
|
|
import org.bson.types.ObjectId;
|
|
|
|
|
|
|
|
import dev.morphia.annotations.Entity;
|
|
|
|
import dev.morphia.annotations.Id;
|
|
|
|
import dev.morphia.annotations.Indexed;
|
|
|
|
import dev.morphia.annotations.Transient;
|
|
|
|
import emu.grasscutter.database.DatabaseHelper;
|
2022-06-21 22:18:13 +08:00
|
|
|
import emu.grasscutter.game.player.Player;
|
|
|
|
import emu.grasscutter.server.packet.send.PacketBattlePassCurScheduleUpdateNotify;
|
|
|
|
|
2022-06-21 07:59:10 -07:00
|
|
|
@Entity(value = "battlepass", useDiscriminator = false)
|
2022-06-21 22:18:13 +08:00
|
|
|
public class BattlePassManager {
|
2022-06-21 07:59:10 -07:00
|
|
|
@Id private ObjectId id;
|
|
|
|
@Transient private Player player;
|
|
|
|
|
|
|
|
@Indexed private int ownerUid;
|
2022-06-21 22:18:13 +08:00
|
|
|
private int point;
|
|
|
|
private int awardTakenLevel;
|
2022-06-21 07:59:10 -07:00
|
|
|
|
|
|
|
@Deprecated // Morphia only
|
|
|
|
public BattlePassManager() {}
|
2022-06-21 22:18:13 +08:00
|
|
|
|
2022-06-21 07:59:10 -07:00
|
|
|
public BattlePassManager(Player player) {
|
|
|
|
this.setPlayer(player);
|
|
|
|
}
|
|
|
|
|
|
|
|
public ObjectId getId() {
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Player getPlayer() {
|
|
|
|
return this.player;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setPlayer(Player player) {
|
|
|
|
this.player = player;
|
|
|
|
this.ownerUid = player.getUid();
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getPoint() {
|
|
|
|
return point;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getAwardTakenLevel() {
|
|
|
|
return awardTakenLevel;
|
2022-06-21 22:18:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public void addPoint(int point){
|
|
|
|
this.point += point;
|
|
|
|
player.getSession().send(new PacketBattlePassCurScheduleUpdateNotify(player.getSession().getPlayer()));
|
2022-06-21 07:59:10 -07:00
|
|
|
this.save();
|
2022-06-21 22:18:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public void updateAwardTakenLevel(int level){
|
|
|
|
this.awardTakenLevel = level;
|
|
|
|
player.getSession().send(new PacketBattlePassCurScheduleUpdateNotify(player.getSession().getPlayer()));
|
2022-06-21 07:59:10 -07:00
|
|
|
this.save();
|
2022-06-21 22:18:13 +08:00
|
|
|
}
|
2022-06-21 07:59:10 -07:00
|
|
|
|
|
|
|
public void save() {
|
|
|
|
DatabaseHelper.saveBattlePass(this);
|
2022-06-21 22:18:13 +08:00
|
|
|
}
|
|
|
|
}
|