mirror of
https://github.com/Melledy/Nebula.git
synced 2026-09-20 01:29:54 +02:00
Implement commissions
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
package emu.nebula.game.agent;
|
||||
|
||||
import dev.morphia.annotations.Entity;
|
||||
import emu.nebula.Nebula;
|
||||
import emu.nebula.data.resources.AgentDef;
|
||||
import emu.nebula.proto.Public.AgentInfo;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@Entity(useDiscriminator = false)
|
||||
public class Agent {
|
||||
private int id;
|
||||
private int duration; // Minutes
|
||||
private long start; // Seconds
|
||||
private int[] charIds;
|
||||
|
||||
private long end; // Milliseconds
|
||||
|
||||
@Deprecated // Morphia only
|
||||
public Agent() {
|
||||
|
||||
}
|
||||
|
||||
public Agent(AgentDef data, int duration, int[] charIds) {
|
||||
this.id = data.getId();
|
||||
this.start = Nebula.getCurrentTime();
|
||||
this.duration = duration;
|
||||
this.charIds = charIds;
|
||||
|
||||
this.end = (this.start + (duration * 60)) * 1000;
|
||||
}
|
||||
|
||||
public boolean isCompleted() {
|
||||
return System.currentTimeMillis() >= this.getEnd();
|
||||
}
|
||||
|
||||
// Proto
|
||||
|
||||
public AgentInfo toProto() {
|
||||
var proto = AgentInfo.newInstance()
|
||||
.setId(this.getId())
|
||||
.setProcessTime(this.getDuration())
|
||||
.setStartTime(this.getStart())
|
||||
.addAllCharIds(this.getCharIds());
|
||||
|
||||
return proto;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user