mirror of
https://github.com/Melledy/Nebula.git
synced 2025-12-14 13:24:43 +01:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
898e8dd43f | ||
|
|
29db60fd0a | ||
|
|
7577bf87d4 |
@@ -29,7 +29,7 @@ java {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
version = '1.1.0'
|
version = '1.1.1'
|
||||||
|
|
||||||
var shouldGenerateProto = System.getenv("GENERATE_PROTO") == "true"
|
var shouldGenerateProto = System.getenv("GENERATE_PROTO") == "true"
|
||||||
System.out.println(shouldGenerateProto ? "Generating proto files" : "Skipping proto generation")
|
System.out.println(shouldGenerateProto ? "Generating proto files" : "Skipping proto generation")
|
||||||
|
|||||||
@@ -1,10 +1,15 @@
|
|||||||
package emu.nebula.data.resources;
|
package emu.nebula.data.resources;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import emu.nebula.data.BaseDef;
|
import emu.nebula.data.BaseDef;
|
||||||
import emu.nebula.data.ResourceType;
|
import emu.nebula.data.ResourceType;
|
||||||
|
import emu.nebula.game.character.GameCharacter;
|
||||||
import emu.nebula.game.inventory.ItemRewardList;
|
import emu.nebula.game.inventory.ItemRewardList;
|
||||||
import emu.nebula.game.inventory.ItemRewardParam;
|
import emu.nebula.game.inventory.ItemRewardParam;
|
||||||
import emu.nebula.util.JsonUtils;
|
import emu.nebula.util.JsonUtils;
|
||||||
|
|
||||||
|
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@@ -35,6 +40,8 @@ public class AgentDef extends BaseDef {
|
|||||||
private String BonusPreview4;
|
private String BonusPreview4;
|
||||||
|
|
||||||
private transient Int2ObjectMap<AgentDurationDef> durations;
|
private transient Int2ObjectMap<AgentDurationDef> durations;
|
||||||
|
private transient Int2IntOpenHashMap tags;
|
||||||
|
private transient Int2IntOpenHashMap extraTags;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId() {
|
public int getId() {
|
||||||
@@ -45,14 +52,83 @@ public class AgentDef extends BaseDef {
|
|||||||
this.durations.put(duration.getTime(), duration);
|
this.durations.put(duration.getTime(), duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasTags(List<GameCharacter> characters) {
|
||||||
|
// Get character tags
|
||||||
|
var characterTags = new Int2IntOpenHashMap();
|
||||||
|
|
||||||
|
for (var character : characters) {
|
||||||
|
var data = character.getData().getDes();
|
||||||
|
|
||||||
|
for (int tag : data.getTag()) {
|
||||||
|
characterTags.addTo(tag, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate that we have the tags
|
||||||
|
for (var entry : this.tags.int2IntEntrySet()) {
|
||||||
|
int reqTagId = entry.getIntKey();
|
||||||
|
int reqTagCount = entry.getIntValue();
|
||||||
|
|
||||||
|
// Get amount of tags that we have from our characters
|
||||||
|
int characterTagCount = characterTags.get(reqTagId);
|
||||||
|
|
||||||
|
if (reqTagCount > characterTagCount) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasExtraTags(List<GameCharacter> characters) {
|
||||||
|
// Get character tags
|
||||||
|
var characterTags = new Int2IntOpenHashMap();
|
||||||
|
|
||||||
|
for (var character : characters) {
|
||||||
|
var data = character.getData().getDes();
|
||||||
|
|
||||||
|
for (int tag : data.getTag()) {
|
||||||
|
characterTags.addTo(tag, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate that we have the tags
|
||||||
|
for (var entry : this.extraTags.int2IntEntrySet()) {
|
||||||
|
int reqTagId = entry.getIntKey();
|
||||||
|
int reqTagCount = entry.getIntValue();
|
||||||
|
|
||||||
|
// Get amount of tags that we have from our characters
|
||||||
|
int characterTagCount = characterTags.get(reqTagId);
|
||||||
|
|
||||||
|
if (reqTagCount > characterTagCount) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoad() {
|
public void onLoad() {
|
||||||
|
// Cache durations
|
||||||
this.durations = new Int2ObjectOpenHashMap<>();
|
this.durations = new Int2ObjectOpenHashMap<>();
|
||||||
|
|
||||||
this.addDuration(new AgentDurationDef(this.Time1, this.RewardPreview1, this.BonusPreview1));
|
this.addDuration(new AgentDurationDef(this.Time1, this.RewardPreview1, this.BonusPreview1));
|
||||||
this.addDuration(new AgentDurationDef(this.Time2, this.RewardPreview2, this.BonusPreview2));
|
this.addDuration(new AgentDurationDef(this.Time2, this.RewardPreview2, this.BonusPreview2));
|
||||||
this.addDuration(new AgentDurationDef(this.Time3, this.RewardPreview3, this.BonusPreview3));
|
this.addDuration(new AgentDurationDef(this.Time3, this.RewardPreview3, this.BonusPreview3));
|
||||||
this.addDuration(new AgentDurationDef(this.Time4, this.RewardPreview4, this.BonusPreview4));
|
this.addDuration(new AgentDurationDef(this.Time4, this.RewardPreview4, this.BonusPreview4));
|
||||||
|
|
||||||
|
// Cache tags
|
||||||
|
this.tags = new Int2IntOpenHashMap();
|
||||||
|
this.extraTags = new Int2IntOpenHashMap();
|
||||||
|
|
||||||
|
for (int tag : this.Tags) {
|
||||||
|
this.tags.addTo(tag, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int tag : this.ExtraTags) {
|
||||||
|
this.extraTags.addTo(tag, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import lombok.Getter;
|
|||||||
@Getter
|
@Getter
|
||||||
@ResourceType(name = "StarTowerFloorExp.json")
|
@ResourceType(name = "StarTowerFloorExp.json")
|
||||||
public class StarTowerFloorExpDef extends BaseDef {
|
public class StarTowerFloorExpDef extends BaseDef {
|
||||||
|
private int Id;
|
||||||
private int StarTowerId;
|
private int StarTowerId;
|
||||||
private int Stage;
|
private int Stage;
|
||||||
private int NormalExp;
|
private int NormalExp;
|
||||||
@@ -16,6 +17,6 @@ public class StarTowerFloorExpDef extends BaseDef {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return StarTowerId;
|
return Id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import dev.morphia.annotations.Entity;
|
|||||||
import dev.morphia.annotations.Id;
|
import dev.morphia.annotations.Id;
|
||||||
import emu.nebula.data.GameData;
|
import emu.nebula.data.GameData;
|
||||||
import emu.nebula.database.GameDatabaseObject;
|
import emu.nebula.database.GameDatabaseObject;
|
||||||
|
import emu.nebula.game.character.GameCharacter;
|
||||||
import emu.nebula.game.player.Player;
|
import emu.nebula.game.player.Player;
|
||||||
import emu.nebula.game.player.PlayerChangeInfo;
|
import emu.nebula.game.player.PlayerChangeInfo;
|
||||||
import emu.nebula.game.player.PlayerManager;
|
import emu.nebula.game.player.PlayerManager;
|
||||||
@@ -58,13 +59,23 @@ public class AgentManager extends PlayerManager implements GameDatabaseObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Make sure we own the characters
|
// Make sure we own the characters
|
||||||
|
var characters = new ArrayList<GameCharacter>();
|
||||||
|
|
||||||
for (int charId : charIds) {
|
for (int charId : charIds) {
|
||||||
if (!getPlayer().getCharacters().hasCharacter(charId)) {
|
var character = getPlayer().getCharacters().getCharacterById(charId);
|
||||||
|
|
||||||
|
// Also check if character fits the commission level requirement
|
||||||
|
if (character == null || character.getLevel() < data.getLevel()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
characters.add(character);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO verify char tags for rewards
|
// Check char tags
|
||||||
|
if (!data.hasTags(characters)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
// Create agent
|
// Create agent
|
||||||
var agent = new Agent(data, processTime, charIds.toArray());
|
var agent = new Agent(data, processTime, charIds.toArray());
|
||||||
@@ -139,12 +150,30 @@ public class AgentManager extends PlayerManager implements GameDatabaseObject {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create rewards
|
// Check if we had extra tags
|
||||||
var rewards = duration.getRewards().generate();
|
var characters = new ArrayList<GameCharacter>();
|
||||||
result.setRewards(rewards);
|
|
||||||
|
|
||||||
// Add to inventory
|
for (int charId : agent.getCharIds()) {
|
||||||
this.getPlayer().getInventory().addItems(rewards, change);
|
var character = getPlayer().getCharacters().getCharacterById(charId);
|
||||||
|
if (character == null) continue;
|
||||||
|
|
||||||
|
characters.add(character);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create rewards
|
||||||
|
result.setRewards(duration.getRewards().generate());
|
||||||
|
|
||||||
|
// Add rewards to inventory
|
||||||
|
this.getPlayer().getInventory().addItems(result.getRewards(), change);
|
||||||
|
|
||||||
|
// Add bonus rewards if we meet the requirements
|
||||||
|
if (data.hasExtraTags(characters)) {
|
||||||
|
// Get bonus rewards
|
||||||
|
result.setBonus(duration.getBonus().generate());
|
||||||
|
|
||||||
|
// Add rewards to inventory
|
||||||
|
this.getPlayer().getInventory().addItems(result.getBonus(), change);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set results in change info
|
// Set results in change info
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import java.util.List;
|
|||||||
import dev.morphia.annotations.Entity;
|
import dev.morphia.annotations.Entity;
|
||||||
|
|
||||||
import emu.nebula.GameConstants;
|
import emu.nebula.GameConstants;
|
||||||
|
import emu.nebula.Nebula;
|
||||||
import emu.nebula.data.GameData;
|
import emu.nebula.data.GameData;
|
||||||
import emu.nebula.data.resources.PotentialDef;
|
import emu.nebula.data.resources.PotentialDef;
|
||||||
import emu.nebula.data.resources.StarTowerDef;
|
import emu.nebula.data.resources.StarTowerDef;
|
||||||
@@ -227,35 +228,33 @@ public class StarTowerGame {
|
|||||||
return gold;
|
return gold;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int levelUp(int exp, int picks) {
|
public int levelUp(int picks) {
|
||||||
if (this.teamExp + exp >= this.nextLevelExp) {
|
if (this.teamExp >= this.nextLevelExp) {
|
||||||
// Level up
|
// Level up
|
||||||
this.teamLevel++;
|
this.teamLevel++;
|
||||||
|
|
||||||
// Add 1 to pending potential picks
|
// Add 1 to pending potential picks
|
||||||
picks++;
|
picks++;
|
||||||
|
|
||||||
// Handle excess exp
|
// Subtract target exp
|
||||||
if (this.teamExp + exp - this.nextLevelExp > 0) {
|
this.teamExp = this.teamExp - this.nextLevelExp;
|
||||||
int excessExp = this.teamExp + exp - this.nextLevelExp;
|
|
||||||
return levelUp(excessExp, picks);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Next level
|
// Update next level exp
|
||||||
this.nextLevelExp = GameData.getStarTowerTeamExpDataTable().get(this.teamLevel + 1).getNeedExp();
|
this.nextLevelExp = GameData.getStarTowerTeamExpDataTable().get(this.teamLevel + 1).getNeedExp();
|
||||||
}
|
|
||||||
else {
|
// Re-check and continue processing if we still got exp
|
||||||
// Update current team exp
|
if (this.teamExp > 0) {
|
||||||
this.teamExp += exp;
|
return levelUp(picks);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return picks
|
// Return picks
|
||||||
return picks;
|
return picks;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int levelUp(int exp) {
|
public int levelUp() {
|
||||||
int potentialPicks = 0;
|
int potentialPicks = 0;
|
||||||
return this.levelUp(exp, potentialPicks);
|
return this.levelUp(potentialPicks);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cases
|
// Cases
|
||||||
@@ -480,7 +479,11 @@ public class StarTowerGame {
|
|||||||
// Handle leveling up
|
// Handle leveling up
|
||||||
|
|
||||||
// Get relevant floor exp data
|
// Get relevant floor exp data
|
||||||
var floorExpData = GameData.getStarTowerFloorExpDataTable().get(this.getId());
|
// fishiatee: THERE'S NO LINQ IN JAVAAAAAAAAAAAAA
|
||||||
|
var floorExpData = GameData.getStarTowerFloorExpDataTable().stream()
|
||||||
|
.filter(f -> f.getStarTowerId() == this.getId())
|
||||||
|
.findFirst()
|
||||||
|
.orElseThrow();
|
||||||
int expReward = 0;
|
int expReward = 0;
|
||||||
|
|
||||||
// Determine appropriate exp reward
|
// Determine appropriate exp reward
|
||||||
@@ -504,7 +507,8 @@ public class StarTowerGame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Level up
|
// Level up
|
||||||
this.pendingPotentialCases += this.levelUp(expReward);
|
this.teamExp += expReward;
|
||||||
|
this.pendingPotentialCases += this.levelUp();
|
||||||
|
|
||||||
// Add clear time
|
// Add clear time
|
||||||
this.battleTime += proto.getVictory().getTime();
|
this.battleTime += proto.getVictory().getTime();
|
||||||
|
|||||||
Reference in New Issue
Block a user