mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-12-22 03:45:10 +01:00
Refactoring (#1660)
* Refactor a couple of iterators * Use side-effect instead of second iterator * Make World::onTick return shouldDelete instead of success * Replace Shop iterator with side effects * Scene * Clean up Expeditions * Refactor Expeditions * Clean up Expeditions, Player * Limit Expeditions by AR * Lombokify props Co-authored-by: AnimeGitB <AnimeGitB@bigblueball.in>
This commit is contained in:
@@ -1,44 +1,24 @@
|
||||
package emu.grasscutter.game.expedition;
|
||||
|
||||
import dev.morphia.annotations.Entity;
|
||||
import emu.grasscutter.net.proto.AvatarExpeditionInfoOuterClass.AvatarExpeditionInfo;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Entity
|
||||
@Getter @Setter
|
||||
public class ExpeditionInfo {
|
||||
|
||||
public int getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(int state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public int getExpId() {
|
||||
return expId;
|
||||
}
|
||||
|
||||
public void setExpId(int expId) {
|
||||
this.expId = expId;
|
||||
}
|
||||
|
||||
public int getHourTime() {
|
||||
return hourTime;
|
||||
}
|
||||
|
||||
public void setHourTime(int hourTime) {
|
||||
this.hourTime = hourTime;
|
||||
}
|
||||
|
||||
public int getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setStartTime(int startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
private int state;
|
||||
private int expId;
|
||||
private int hourTime;
|
||||
private int startTime;
|
||||
|
||||
public AvatarExpeditionInfo toProto() {
|
||||
return AvatarExpeditionInfo.newBuilder()
|
||||
.setStateValue(this.getState())
|
||||
.setExpId(this.getExpId())
|
||||
.setHourTime(this.getHourTime())
|
||||
.setStartTime(this.getStartTime())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,15 @@
|
||||
package emu.grasscutter.game.expedition;
|
||||
|
||||
import emu.grasscutter.game.inventory.GameItem;
|
||||
import emu.grasscutter.utils.Utils;
|
||||
import lombok.Getter;
|
||||
|
||||
public class ExpeditionRewardData {
|
||||
private int itemId;
|
||||
private int minCount;
|
||||
private int maxCount;
|
||||
@Getter private int itemId;
|
||||
@Getter private int minCount;
|
||||
@Getter private int maxCount;
|
||||
|
||||
public int getItemId() {
|
||||
return itemId;
|
||||
public GameItem getReward() {
|
||||
return new GameItem(itemId, Utils.randomRange(minCount, maxCount));
|
||||
}
|
||||
|
||||
public int getMinCount() { return minCount; }
|
||||
|
||||
public int getMaxCount() {
|
||||
return maxCount;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,15 +1,20 @@
|
||||
package emu.grasscutter.game.expedition;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ExpeditionRewardDataList {
|
||||
public int getHourTime() {
|
||||
return hourTime;
|
||||
}
|
||||
public List<ExpeditionRewardData> getExpeditionRewardData() {
|
||||
return expeditionRewardData;
|
||||
}
|
||||
import emu.grasscutter.game.inventory.GameItem;
|
||||
import lombok.Getter;
|
||||
|
||||
private int hourTime;
|
||||
private List<ExpeditionRewardData> expeditionRewardData;
|
||||
public class ExpeditionRewardDataList {
|
||||
@Getter private int hourTime;
|
||||
@Getter private List<ExpeditionRewardData> expeditionRewardData;
|
||||
|
||||
public List<GameItem> getRewards() {
|
||||
List<GameItem> rewards = new ArrayList<>();
|
||||
if (expeditionRewardData != null) {
|
||||
expeditionRewardData.forEach(data -> rewards.add(data.getReward()));
|
||||
}
|
||||
return rewards;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,15 +2,9 @@ package emu.grasscutter.game.expedition;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
public class ExpeditionRewardInfo {
|
||||
public int getExpId() {
|
||||
return expId;
|
||||
}
|
||||
|
||||
public List<ExpeditionRewardDataList> getExpeditionRewardDataList() {
|
||||
return expeditionRewardDataList;
|
||||
}
|
||||
|
||||
private int expId;
|
||||
private List<ExpeditionRewardDataList> expeditionRewardDataList;
|
||||
@Getter private int expId;
|
||||
@Getter private List<ExpeditionRewardDataList> expeditionRewardDataList;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user