Implement commissions

This commit is contained in:
Melledy
2025-11-12 03:25:23 -08:00
parent d4a7aa0320
commit be4a006c66
19 changed files with 526 additions and 40 deletions
@@ -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;
}
}