Commit 2b799958 authored by ShiroSaki's avatar ShiroSaki Committed by Melledy
Browse files

Refactor support for codex(aka archive) animal, weapon, reliquary

parent 117a947b
...@@ -64,8 +64,16 @@ public class GameData { ...@@ -64,8 +64,16 @@ public class GameData {
private static final Int2ObjectMap<SceneData> sceneDataMap = new Int2ObjectLinkedOpenHashMap<>(); private static final Int2ObjectMap<SceneData> sceneDataMap = new Int2ObjectLinkedOpenHashMap<>();
private static final Int2ObjectMap<FetterData> fetterDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap<FetterData> fetterDataMap = new Int2ObjectOpenHashMap<>();
private static final Int2ObjectMap<CodexQuest> codexQuestMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap<CodexQuestData> codexQuestDataMap = new Int2ObjectOpenHashMap<>();
private static final Int2ObjectMap<CodexQuest> codexQuestIdMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap<CodexQuestData> codexQuestDataIdMap = new Int2ObjectOpenHashMap<>();
private static final Int2ObjectMap<CodexAnimalData> codexAnimalDataMap = new Int2ObjectOpenHashMap<>();
private static final Int2ObjectMap<CodexWeaponData> codexWeaponDataMap = new Int2ObjectOpenHashMap<>();
private static final Int2ObjectMap<CodexWeaponData> codexWeaponDataIdMap = new Int2ObjectOpenHashMap<>();
private static final Int2ObjectMap<CodexMaterialData> codexMaterialDataMap = new Int2ObjectOpenHashMap<>();
private static final Int2ObjectMap<CodexMaterialData> codexMaterialDataIdMap = new Int2ObjectOpenHashMap<>();
private static final Int2ObjectMap<CodexReliquaryData> codexReliquaryDataMap = new Int2ObjectOpenHashMap<>();
private static final Int2ObjectMap<CodexReliquaryData> codexReliquaryDataIdMap = new Int2ObjectOpenHashMap<>();
private static final ArrayList<CodexReliquaryData> codexReliquaryArrayList = new ArrayList<>();
private static final Int2ObjectMap<FetterCharacterCardData> fetterCharacterCardDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap<FetterCharacterCardData> fetterCharacterCardDataMap = new Int2ObjectOpenHashMap<>();
private static final Int2ObjectMap<RewardData> rewardDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap<RewardData> rewardDataMap = new Int2ObjectOpenHashMap<>();
private static final Int2ObjectMap<WorldLevelData> worldLevelDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap<WorldLevelData> worldLevelDataMap = new Int2ObjectOpenHashMap<>();
...@@ -294,9 +302,17 @@ public class GameData { ...@@ -294,9 +302,17 @@ public class GameData {
return fetters; return fetters;
} }
public static Int2ObjectMap<CodexQuest> getCodexQuestMap(){return codexQuestMap;} public static Int2ObjectMap<CodexQuestData> getCodexQuestDataIdMap(){return codexQuestDataIdMap;}
public static Int2ObjectMap<CodexQuest> getCodexQuestIdMap(){return codexQuestIdMap;} public static Int2ObjectMap<CodexAnimalData> getCodexAnimalDataMap(){return codexAnimalDataMap;}
public static Int2ObjectMap<CodexWeaponData> getCodexWeaponDataIdMap(){return codexWeaponDataIdMap;}
public static Int2ObjectMap<CodexMaterialData> getCodexMaterialDataIdMap(){return codexMaterialDataIdMap;}
public static Int2ObjectMap<CodexReliquaryData> getcodexReliquaryIdMap(){return codexReliquaryDataIdMap;}
public static ArrayList<CodexReliquaryData> getcodexReliquaryArrayList(){return codexReliquaryArrayList;}
public static Int2ObjectMap<WorldLevelData> getWorldLevelDataMap() { public static Int2ObjectMap<WorldLevelData> getWorldLevelDataMap() {
return worldLevelDataMap; return worldLevelDataMap;
......
package emu.grasscutter.data.def;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
@ResourceType(name = {"AnimalCodexExcelConfigData.json"})
public class CodexAnimalData extends GameResource {
private int Id;
private String Type;
private int DescribeId;
private int SortOrder;
private CodexAnimalUnlockCondition BAINKHIIMJE;
@Override
public int getId() {
return Id;
}
public String getType() {
return Type;
}
public int getDescribeId() {
return DescribeId;
}
public int getSortOrder() {
return SortOrder;
}
public CodexAnimalUnlockCondition getUnlockCondition() {
return BAINKHIIMJE;
}
public enum CodexAnimalUnlockCondition {
CODEX_COUNT_TYPE_KILL,
CODEX_COUNT_TYPE_CAPTURE
}
}
package emu.grasscutter.data.def;
import emu.grasscutter.data.GameData;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
@ResourceType(name = {"MaterialCodexExcelConfigData.json"})
public class CodexMaterialData extends GameResource {
private int Id;
private int MaterialId;
private int SortOrder;
public int getSortOrder() {
return SortOrder;
}
public int getMaterialId() {
return MaterialId;
}
public int getId() {
return Id;
}
@Override
public void onLoad() {
GameData.getCodexMaterialDataIdMap().put(this.getMaterialId(), this);
}
}
package emu.grasscutter.data.def; package emu.grasscutter.data.def;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.data.GameData; import emu.grasscutter.data.GameData;
import emu.grasscutter.data.GameResource; import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType; import emu.grasscutter.data.ResourceType;
@ResourceType(name = {"QuestCodexExcelConfigData.json"}, loadPriority = ResourceType.LoadPriority.HIGH) @ResourceType(name = {"QuestCodexExcelConfigData.json"})
public class CodexQuest extends GameResource { public class CodexQuestData extends GameResource {
private int Id; private int Id;
private int ParentQuestId; private int ParentQuestId;
private int ChapterId; private int ChapterId;
...@@ -36,7 +35,7 @@ public class CodexQuest extends GameResource { ...@@ -36,7 +35,7 @@ public class CodexQuest extends GameResource {
@Override @Override
public void onLoad() { public void onLoad() {
if(!this.getIsDisuse()) { if(!this.getIsDisuse()) {
GameData.getCodexQuestIdMap().put(this.getParentQuestId(), this); GameData.getCodexQuestDataIdMap().put(this.getParentQuestId(), this);
} }
} }
} }
package emu.grasscutter.data.def;
import emu.grasscutter.data.GameData;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
@ResourceType(name = {"ReliquaryCodexExcelConfigData.json"})
public class CodexReliquaryData extends GameResource {
private int Id;
private int SuitId;
private int Level;
private int CupId;
private int LeatherId;
private int CapId;
private int FlowerId;
private int SandId;
private int SortOrder;
public int getSortOrder() {
return SortOrder;
}
public int getId() {
return Id;
}
public int getSuitId() {
return SuitId;
}
public int getLevel() {
return Level;
}
public int getCupId() {
return CupId;
}
public int getLeatherId() {
return LeatherId;
}
public int getCapId() {
return CapId;
}
public int getFlowerId() {
return FlowerId;
}
public int getSandId() {
return SandId;
}
@Override
public void onLoad() {
GameData.getcodexReliquaryArrayList().add(this);
GameData.getcodexReliquaryIdMap().put(getSuitId(), this);
}
}
package emu.grasscutter.data.def;
import emu.grasscutter.data.GameData;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
@ResourceType(name = {"WeaponCodexExcelConfigData.json"})
public class CodexWeaponData extends GameResource {
private int Id;
private int WeaponId;
private int SortOrder;
public int getSortOrder() {
return SortOrder;
}
public int getWeaponId() {
return WeaponId;
}
public int getId() {
return Id;
}
@Override
public void onLoad() {
GameData.getCodexWeaponDataIdMap().put(this.getWeaponId(), this);
}
}
...@@ -240,6 +240,7 @@ public class Inventory implements Iterable<GameItem> { ...@@ -240,6 +240,7 @@ public class Inventory implements Iterable<GameItem> {
} }
private synchronized void putItem(GameItem item, InventoryTab tab) { private synchronized void putItem(GameItem item, InventoryTab tab) {
getPlayer().getCodex().checkAddedItem(item);
// Set owner and guid FIRST! // Set owner and guid FIRST!
item.setOwner(getPlayer()); item.setOwner(getPlayer());
// Put in item store // Put in item store
......
...@@ -2,7 +2,6 @@ package emu.grasscutter.game.player; ...@@ -2,7 +2,6 @@ package emu.grasscutter.game.player;
import dev.morphia.annotations.*; import dev.morphia.annotations.*;
import emu.grasscutter.GameConstants; import emu.grasscutter.GameConstants;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.data.GameData; import emu.grasscutter.data.GameData;
import emu.grasscutter.data.def.PlayerLevelData; import emu.grasscutter.data.def.PlayerLevelData;
import emu.grasscutter.database.DatabaseHelper; import emu.grasscutter.database.DatabaseHelper;
...@@ -30,8 +29,6 @@ import emu.grasscutter.game.props.ActionReason; ...@@ -30,8 +29,6 @@ import emu.grasscutter.game.props.ActionReason;
import emu.grasscutter.game.props.EntityType; import emu.grasscutter.game.props.EntityType;
import emu.grasscutter.game.props.PlayerProperty; import emu.grasscutter.game.props.PlayerProperty;
import emu.grasscutter.game.props.SceneType; import emu.grasscutter.game.props.SceneType;
import emu.grasscutter.game.quest.GameMainQuest;
import emu.grasscutter.game.quest.GameQuest;
import emu.grasscutter.game.quest.QuestManager; import emu.grasscutter.game.quest.QuestManager;
import emu.grasscutter.game.shop.ShopLimit; import emu.grasscutter.game.shop.ShopLimit;
import emu.grasscutter.game.managers.MapMarkManager.*; import emu.grasscutter.game.managers.MapMarkManager.*;
...@@ -80,6 +77,7 @@ public class Player { ...@@ -80,6 +77,7 @@ public class Player {
private Position pos; private Position pos;
private Position rotation; private Position rotation;
private PlayerBirthday birthday; private PlayerBirthday birthday;
private PlayerCodex codex;
private Map<Integer, Integer> properties; private Map<Integer, Integer> properties;
private Set<Integer> nameCardList; private Set<Integer> nameCardList;
...@@ -189,6 +187,7 @@ public class Player { ...@@ -189,6 +187,7 @@ public class Player {
this.birthday = new PlayerBirthday(); this.birthday = new PlayerBirthday();
this.rewardedLevels = new HashSet<>(); this.rewardedLevels = new HashSet<>();
this.moonCardGetTimes = new HashSet<>(); this.moonCardGetTimes = new HashSet<>();
this.codex = new PlayerCodex();
this.shopLimit = new ArrayList<>(); this.shopLimit = new ArrayList<>();
this.expeditionInfo = new HashMap<>(); this.expeditionInfo = new HashMap<>();
...@@ -209,6 +208,7 @@ public class Player { ...@@ -209,6 +208,7 @@ public class Player {
this.signature = ""; this.signature = "";
this.teamManager = new TeamManager(this); this.teamManager = new TeamManager(this);
this.birthday = new PlayerBirthday(); this.birthday = new PlayerBirthday();
this.codex = new PlayerCodex();
this.setProperty(PlayerProperty.PROP_PLAYER_LEVEL, 1); this.setProperty(PlayerProperty.PROP_PLAYER_LEVEL, 1);
this.setProperty(PlayerProperty.PROP_IS_SPRING_AUTO_USE, 1); this.setProperty(PlayerProperty.PROP_IS_SPRING_AUTO_USE, 1);
this.setProperty(PlayerProperty.PROP_SPRING_AUTO_USE_PERCENT, 50); this.setProperty(PlayerProperty.PROP_SPRING_AUTO_USE_PERCENT, 50);
...@@ -758,7 +758,6 @@ public class Player { ...@@ -758,7 +758,6 @@ public class Player {
return expeditionInfo.get(avaterGuid); return expeditionInfo.get(avaterGuid);
} }
public List<ShopLimit> getShopLimit() { public List<ShopLimit> getShopLimit() {
return shopLimit; return shopLimit;
} }
...@@ -984,6 +983,8 @@ public class Player { ...@@ -984,6 +983,8 @@ public class Player {
return this.birthday.getDay() > 0; return this.birthday.getDay() > 0;
} }
public PlayerCodex getCodex(){ return this.codex; }
public Set<Integer> getRewardedLevels() { public Set<Integer> getRewardedLevels() {
return rewardedLevels; return rewardedLevels;
} }
...@@ -1159,6 +1160,7 @@ public class Player { ...@@ -1159,6 +1160,7 @@ public class Player {
@PostLoad @PostLoad
private void onLoad() { private void onLoad() {
this.getCodex().setPlayer(this);
this.getTeamManager().setPlayer(this); this.getTeamManager().setPlayer(this);
this.getTowerManager().setPlayer(this); this.getTowerManager().setPlayer(this);
} }
...@@ -1229,7 +1231,6 @@ public class Player { ...@@ -1229,7 +1231,6 @@ public class Player {
session.send(new PacketFinishedParentQuestNotify(this)); session.send(new PacketFinishedParentQuestNotify(this));
session.send(new PacketQuestListNotify(this)); session.send(new PacketQuestListNotify(this));
session.send(new PacketCodexDataFullNotify(this)); session.send(new PacketCodexDataFullNotify(this));
session.send(new PacketServerCondMeetQuestListUpdateNotify(this));
session.send(new PacketAllWidgetDataNotify(this)); session.send(new PacketAllWidgetDataNotify(this));
session.send(new PacketWidgetGadgetAllDataNotify()); session.send(new PacketWidgetGadgetAllDataNotify());
session.send(new PacketPlayerHomeCompInfoNotify(this)); session.send(new PacketPlayerHomeCompInfoNotify(this));
......
package emu.grasscutter.game.player;
import dev.morphia.annotations.Entity;
import dev.morphia.annotations.Transient;
import emu.grasscutter.data.GameData;
import emu.grasscutter.data.def.CodexAnimalData;
import emu.grasscutter.data.def.CodexReliquaryData;
import emu.grasscutter.game.entity.GameEntity;
import emu.grasscutter.game.inventory.GameItem;
import emu.grasscutter.game.inventory.ItemType;
import emu.grasscutter.game.inventory.MaterialType;
import emu.grasscutter.server.packet.send.PacketCodexDataUpdateNotify;
import java.util.*;
@Entity
public class PlayerCodex {
@Transient private Player player;
//itemId is not codexId!
private Set<Integer> unlockedWeapon;
private Map<Integer, Integer> unlockedAnimal;
private Set<Integer> unlockedMaterial;
private Set<Integer> unlockedBook;
private Set<Integer> unlockedTip;
private Set<Integer> unlockedView;
private Set<Integer> unlockedReliquary;
private Set<Integer> unlockedReliquarySuitCodex;
public PlayerCodex(){
this.unlockedWeapon = new HashSet<>();
this.unlockedAnimal = new HashMap<>();
this.unlockedMaterial = new HashSet<>();
this.unlockedBook = new HashSet<>();
this.unlockedTip = new HashSet<>();
this.unlockedView = new HashSet<>();
this.unlockedReliquary = new HashSet<>();
this.unlockedReliquarySuitCodex = new HashSet<>();
}
public void setPlayer(Player player) {
this.player = player;
}
public void checkAddedItem(GameItem item){
ItemType type = item.getItemData().getItemType();
if (type == ItemType.ITEM_WEAPON){
if(!getUnlockedWeapon().contains(item.getItemId())){
getUnlockedWeapon().add(item.getItemId());
var codexItem = GameData.getCodexWeaponDataIdMap().get(item.getItemId());
if(codexItem != null){
player.save();
this.player.sendPacket(new PacketCodexDataUpdateNotify(2, codexItem.getId()));
}
}
}
else if(type == ItemType.ITEM_MATERIAL){
if( item.getItemData().getMaterialType() == MaterialType.MATERIAL_FOOD ||
item.getItemData().getMaterialType() == MaterialType.MATERIAL_WIDGET||
item.getItemData().getMaterialType() == MaterialType.MATERIAL_EXCHANGE||
item.getItemData().getMaterialType() == MaterialType.MATERIAL_AVATAR_MATERIAL||
item.getItemData().getMaterialType() == MaterialType.MATERIAL_NOTICE_ADD_HP){
if (!getUnlockedMaterial().contains(item.getItemId())) {
var codexMaterial = GameData.getCodexMaterialDataIdMap().get(item.getItemId());
if (codexMaterial != null) {
getUnlockedMaterial().add(item.getItemId());
player.save();
this.player.sendPacket(new PacketCodexDataUpdateNotify(4, codexMaterial.getId()));
}
}
}
}
else if(type == ItemType.ITEM_RELIQUARY) {
if(!getUnlockedReliquary().contains(item.getItemId())){
getUnlockedReliquary().add(item.getItemId());
checkUnlockedSuits(item);
}
}
}
public void checkAnimal(GameEntity target, CodexAnimalData.CodexAnimalUnlockCondition condition){
if(target.getEntityType() == 2){
var monsterId = target.getSpawnEntry().getMonsterId();
var codexAnimal = GameData.getCodexAnimalDataMap().get(monsterId);
if(!getUnlockedAnimal().containsKey(monsterId)) {
if (codexAnimal != null) {
if(codexAnimal.getUnlockCondition() == condition){
getUnlockedAnimal().put(monsterId, 1);
player.save();
this.player.sendPacket(new PacketCodexDataUpdateNotify(3, monsterId));
}
}
}else{
getUnlockedAnimal().put(monsterId, getUnlockedAnimal().get(monsterId) + 1);
player.save();
}
}
}
public void checkUnlockedSuits(GameItem item){
int reliquaryId = item.getItemId();
Optional<CodexReliquaryData> excelReliquarySuitList = GameData.getcodexReliquaryArrayList().stream().filter(
x -> x.getCupId() == reliquaryId
|| x.getLeatherId() == reliquaryId
|| x.getCapId() == reliquaryId
|| x.getFlowerId() == reliquaryId
|| x.getSandId() == reliquaryId
).findFirst();
if(excelReliquarySuitList.isPresent()) {
var excelReliquarySuit = excelReliquarySuitList.get();
if(!getUnlockedReliquarySuitCodex().contains(excelReliquarySuit.getId())){
if(
getUnlockedReliquary().contains(excelReliquarySuit.getCupId()) &&
getUnlockedReliquary().contains(excelReliquarySuit.getLeatherId()) &&
getUnlockedReliquary().contains(excelReliquarySuit.getCapId()) &&
getUnlockedReliquary().contains(excelReliquarySuit.getFlowerId()) &&
getUnlockedReliquary().contains(excelReliquarySuit.getSandId())
){
getUnlockedReliquarySuitCodex().add(excelReliquarySuit.getId());
player.save();
this.player.sendPacket(new PacketCodexDataUpdateNotify(8, excelReliquarySuit.getId()));
}
}
}
}
public Set<Integer> getUnlockedWeapon() {
return unlockedWeapon;
}
public Map<Integer, Integer> getUnlockedAnimal() {
return unlockedAnimal;
}
public Set<Integer> getUnlockedMaterial() {
return unlockedMaterial;
}
public Set<Integer> getUnlockedBook() {
return unlockedBook;
}
public Set<Integer> getUnlockedTip() {
return unlockedTip;
}
public Set<Integer> getUnlockedView() {
return unlockedView;
}
public Set<Integer> getUnlockedReliquary() {
return unlockedReliquary;
}
public Set<Integer> getUnlockedReliquarySuitCodex() {
return unlockedReliquarySuitCodex;
}
}
\ No newline at end of file
...@@ -121,7 +121,6 @@ public class QuestManager { ...@@ -121,7 +121,6 @@ public class QuestManager {
mainQuest.save(); mainQuest.save();
// Send packet // Send packet
getPlayer().sendPacket(new PacketServerCondMeetQuestListUpdateNotify(quest));
getPlayer().sendPacket(new PacketQuestListUpdateNotify(quest)); getPlayer().sendPacket(new PacketQuestListUpdateNotify(quest));
return quest; return quest;
......
...@@ -2,10 +2,7 @@ package emu.grasscutter.game.world; ...@@ -2,10 +2,7 @@ package emu.grasscutter.game.world;
import emu.grasscutter.data.GameData; import emu.grasscutter.data.GameData;
import emu.grasscutter.data.GameDepot; import emu.grasscutter.data.GameDepot;
import emu.grasscutter.data.def.DungeonData; import emu.grasscutter.data.def.*;
import emu.grasscutter.data.def.MonsterData;
import emu.grasscutter.data.def.SceneData;
import emu.grasscutter.data.def.WorldLevelData;
import emu.grasscutter.game.dungeons.DungeonChallenge; import emu.grasscutter.game.dungeons.DungeonChallenge;
import emu.grasscutter.game.dungeons.DungeonSettleListener; import emu.grasscutter.game.dungeons.DungeonSettleListener;
import emu.grasscutter.game.entity.*; import emu.grasscutter.game.entity.*;
...@@ -389,6 +386,9 @@ public class Scene { ...@@ -389,6 +386,9 @@ public class Scene {
} }
public void killEntity(GameEntity target, int attackerId) { public void killEntity(GameEntity target, int attackerId) {
for (Player player : this.getPlayers()) {
player.getCodex().checkAnimal(target, CodexAnimalData.CodexAnimalUnlockCondition.CODEX_COUNT_TYPE_KILL);
}
// Packet // Packet
this.broadcastPacket(new PacketLifeStateChangeNotify(attackerId, target, LifeState.LIFE_DEAD)); this.broadcastPacket(new PacketLifeStateChangeNotify(attackerId, target, LifeState.LIFE_DEAD));
......
package emu.grasscutter.server.packet.recv;
import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.packet.PacketHandler;
import emu.grasscutter.net.proto.QueryCodexMonsterBeKilledNumReqOuterClass;
import emu.grasscutter.net.proto.QueryCodexMonsterBeKilledNumReqOuterClass.QueryCodexMonsterBeKilledNumReq;
import emu.grasscutter.server.game.GameSession;
import emu.grasscutter.server.packet.send.PacketQueryCodexMonsterBeKilledNumRsp;
@Opcodes(PacketOpcodes.QueryCodexMonsterBeKilledNumReq)
public class HandlerQueryCodexMonsterBeKilledNumReq extends PacketHandler {
@Override
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
QueryCodexMonsterBeKilledNumReq req = QueryCodexMonsterBeKilledNumReq.parseFrom(payload);
session.send(new PacketQueryCodexMonsterBeKilledNumRsp(session.getPlayer(), req.getCodexIdListList()));
}
}
package emu.grasscutter.server.packet.send; package emu.grasscutter.server.packet.send;
import java.util.Collections; import java.util.Collections;
import java.util.List;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.data.GameData; import emu.grasscutter.data.GameData;
import emu.grasscutter.game.player.Player; import emu.grasscutter.game.player.Player;
import emu.grasscutter.net.packet.BasePacket; import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.CodexDataFullNotifyOuterClass.CodexDataFullNotify; import emu.grasscutter.net.proto.CodexDataFullNotifyOuterClass.CodexDataFullNotify;
import emu.grasscutter.net.proto.CodexTypeDataOuterClass.CodexTypeData; import emu.grasscutter.net.proto.CodexTypeDataOuterClass.CodexTypeData;
import emu.grasscutter.net.proto.CodexTypeOuterClass;
import emu.grasscutter.server.game.GameSession;
public class PacketCodexDataFullNotify extends BasePacket { public class PacketCodexDataFullNotify extends BasePacket {
public PacketCodexDataFullNotify(Player player) { public PacketCodexDataFullNotify(Player player) {
...@@ -21,6 +17,22 @@ public class PacketCodexDataFullNotify extends BasePacket { ...@@ -21,6 +17,22 @@ public class PacketCodexDataFullNotify extends BasePacket {
CodexTypeData.Builder questTypeData = CodexTypeData.newBuilder() CodexTypeData.Builder questTypeData = CodexTypeData.newBuilder()
.setTypeValue(1); .setTypeValue(1);
//Weapons
CodexTypeData.Builder weaponTypeData = CodexTypeData.newBuilder()
.setTypeValue(2);
//Animals
CodexTypeData.Builder animalTypeData = CodexTypeData.newBuilder()
.setTypeValue(3);
//Materials
CodexTypeData.Builder materialTypeData = CodexTypeData.newBuilder()
.setTypeValue(4);
//Books
CodexTypeData.Builder bookTypeData = CodexTypeData.newBuilder()
.setTypeValue(5);
//Tips //Tips
CodexTypeData.Builder pushTipsTypeData = CodexTypeData.newBuilder() CodexTypeData.Builder pushTipsTypeData = CodexTypeData.newBuilder()
.setTypeValue(6); .setTypeValue(6);
...@@ -29,25 +41,53 @@ public class PacketCodexDataFullNotify extends BasePacket { ...@@ -29,25 +41,53 @@ public class PacketCodexDataFullNotify extends BasePacket {
CodexTypeData.Builder viewTypeData = CodexTypeData.newBuilder() CodexTypeData.Builder viewTypeData = CodexTypeData.newBuilder()
.setTypeValue(7); .setTypeValue(7);
//Weapons //Reliquary
CodexTypeData.Builder weaponTypeData = CodexTypeData.newBuilder() CodexTypeData.Builder reliquaryData = CodexTypeData.newBuilder()
.setTypeValue(2); .setTypeValue(8);
player.getQuestManager().forEachMainQuest(mainQuest -> { player.getQuestManager().forEachMainQuest(mainQuest -> {
if(mainQuest.isFinished()){ if(mainQuest.isFinished()){
var codexQuest = GameData.getCodexQuestIdMap().get(mainQuest.getParentQuestId()); var codexQuest = GameData.getCodexQuestDataIdMap().get(mainQuest.getParentQuestId());
if(codexQuest != null){ if(codexQuest != null){
questTypeData.addCodexIdList(codexQuest.getId()).addAllHaveViewedList(Collections.singleton(true)); questTypeData.addCodexIdList(codexQuest.getId()).addAllHaveViewedList(Collections.singleton(true));
} }
} }
}); });
player.getCodex().getUnlockedWeapon().forEach(weapon -> {
var codexWeapon = GameData.getCodexWeaponDataIdMap().get(weapon);
if(codexWeapon != null){
weaponTypeData.addCodexIdList(codexWeapon.getId()).addAllHaveViewedList(Collections.singleton(true));
}
});
player.getCodex().getUnlockedAnimal().forEach((animal, amount) -> {
var codexAnimal = GameData.getCodexAnimalDataMap().get(animal);
if(codexAnimal != null){
animalTypeData.addCodexIdList(codexAnimal.getId()).addAllHaveViewedList(Collections.singleton(true));
}
});
player.getCodex().getUnlockedMaterial().forEach(material -> {
var codexMaterial = GameData.getCodexMaterialDataIdMap().get(material);
if(codexMaterial != null){
materialTypeData.addCodexIdList(codexMaterial.getId()).addAllHaveViewedList(Collections.singleton(true));
}
});
player.getCodex().getUnlockedReliquarySuitCodex().forEach(reliquarySuit -> {
reliquaryData.addCodexIdList(reliquarySuit).addAllHaveViewedList(Collections.singleton(true));
});
CodexDataFullNotify.Builder proto = CodexDataFullNotify.newBuilder() CodexDataFullNotify.Builder proto = CodexDataFullNotify.newBuilder()
.addTypeDataList(questTypeData.build()) .addTypeDataList(questTypeData.build())
.addTypeDataList(weaponTypeData)
.addTypeDataList(animalTypeData)
.addTypeDataList(materialTypeData)
.addTypeDataList(bookTypeData)
.addTypeDataList(pushTipsTypeData.build()) .addTypeDataList(pushTipsTypeData.build())
.addTypeDataList(viewTypeData.build()) .addTypeDataList(viewTypeData.build())
.addTypeDataList(weaponTypeData); .addTypeDataList(reliquaryData);
this.setData(proto); this.setData(proto);
} }
......
package emu.grasscutter.server.packet.send; package emu.grasscutter.server.packet.send;
import java.util.Collections;
import java.util.List;
import emu.grasscutter.data.GameData; import emu.grasscutter.data.GameData;
import emu.grasscutter.game.player.Player;
import emu.grasscutter.game.quest.GameMainQuest; import emu.grasscutter.game.quest.GameMainQuest;
import emu.grasscutter.game.quest.GameQuest;
import emu.grasscutter.net.packet.BasePacket; import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.CodexDataUpdateNotifyOuterClass.CodexDataUpdateNotify; import emu.grasscutter.net.proto.CodexDataUpdateNotifyOuterClass.CodexDataUpdateNotify;
import emu.grasscutter.server.game.GameSession;
public class PacketCodexDataUpdateNotify extends BasePacket { public class PacketCodexDataUpdateNotify extends BasePacket {
public PacketCodexDataUpdateNotify(GameMainQuest quest) { public PacketCodexDataUpdateNotify(GameMainQuest quest) {
super(PacketOpcodes.CodexDataUpdateNotify, true); super(PacketOpcodes.CodexDataUpdateNotify, true);
var codexQuest = GameData.getCodexQuestIdMap().get(quest.getParentQuestId()); var codexQuest = GameData.getCodexQuestDataIdMap().get(quest.getParentQuestId());
if(codexQuest != null){ if(codexQuest != null){
CodexDataUpdateNotify proto = CodexDataUpdateNotify.newBuilder() CodexDataUpdateNotify proto = CodexDataUpdateNotify.newBuilder()
.setTypeValue(1) .setTypeValue(1)
...@@ -24,4 +18,13 @@ public class PacketCodexDataUpdateNotify extends BasePacket { ...@@ -24,4 +18,13 @@ public class PacketCodexDataUpdateNotify extends BasePacket {
this.setData(proto); this.setData(proto);
} }
} }
public PacketCodexDataUpdateNotify(int typeValue, int codexId){
super(PacketOpcodes.CodexDataUpdateNotify, true);
CodexDataUpdateNotify proto = CodexDataUpdateNotify.newBuilder()
.setTypeValue(typeValue)
.setId(codexId)
.build();
this.setData(proto);
}
} }
package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.player.Player;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.QueryCodexMonsterBeKilledNumRspOuterClass.QueryCodexMonsterBeKilledNumRsp;
import java.util.List;
public class PacketQueryCodexMonsterBeKilledNumRsp extends BasePacket {
public PacketQueryCodexMonsterBeKilledNumRsp(Player player, List<Integer> codexList) {
super(PacketOpcodes.QueryCodexMonsterBeKilledNumRsp);
QueryCodexMonsterBeKilledNumRsp.Builder proto = QueryCodexMonsterBeKilledNumRsp.newBuilder();
codexList.forEach(animal -> {
if(player.getCodex().getUnlockedAnimal().containsKey(animal)){
proto.addCodexIdList(animal)
.addBeKilledNumList(player.getCodex().getUnlockedAnimal().get(animal))
.addBeKilledNumEmptyList(0);
}
});
this.setData(proto);
}
}
...@@ -12,13 +12,15 @@ public class PacketServerCondMeetQuestListUpdateNotify extends BasePacket { ...@@ -12,13 +12,15 @@ public class PacketServerCondMeetQuestListUpdateNotify extends BasePacket {
super(PacketOpcodes.ServerCondMeetQuestListUpdateNotify); super(PacketOpcodes.ServerCondMeetQuestListUpdateNotify);
ServerCondMeetQuestListUpdateNotify.Builder proto = ServerCondMeetQuestListUpdateNotify.newBuilder(); ServerCondMeetQuestListUpdateNotify.Builder proto = ServerCondMeetQuestListUpdateNotify.newBuilder();
/*
player.getQuestManager().forEachQuest(quest -> { player.getQuestManager().forEachQuest(quest -> {
if (quest.getState().getValue() <= 2) { if (quest.getState().getValue() <= 2) {
proto.addAddQuestIdList(quest.getQuestId()); proto.addAddQuestIdList(quest.getQuestId());
} }
}); });
*/
this.setData(proto); this.setData(proto);
} }
...@@ -26,9 +28,9 @@ public class PacketServerCondMeetQuestListUpdateNotify extends BasePacket { ...@@ -26,9 +28,9 @@ public class PacketServerCondMeetQuestListUpdateNotify extends BasePacket {
super(PacketOpcodes.ServerCondMeetQuestListUpdateNotify); super(PacketOpcodes.ServerCondMeetQuestListUpdateNotify);
ServerCondMeetQuestListUpdateNotify proto = ServerCondMeetQuestListUpdateNotify.newBuilder() ServerCondMeetQuestListUpdateNotify proto = ServerCondMeetQuestListUpdateNotify.newBuilder()
.addAddQuestIdList(quest.getQuestId()) //.addAddQuestIdList(quest.getQuestId())
.build(); .build();
this.setData(proto); this.setData(proto);
} }
} }
...@@ -159,7 +159,7 @@ ...@@ -159,7 +159,7 @@
"description": "Gives the player a specified artifact" "description": "Gives the player a specified artifact"
}, },
"giveChar": { "giveChar": {
"usage": "Usage: givechar <player> <itemID|itemName> [amount]", "usage": "Usage: givechar <player> <itemID|itemName> [level]",
"given": "Given %s with level %s to %s.", "given": "Given %s with level %s to %s.",
"invalid_avatar_id": "Invalid avatar ID.", "invalid_avatar_id": "Invalid avatar ID.",
"invalid_avatar_level": "Invalid avatar level.", "invalid_avatar_level": "Invalid avatar level.",
......
...@@ -163,7 +163,7 @@ ...@@ -163,7 +163,7 @@
"description": "给予指定圣遗物" "description": "给予指定圣遗物"
}, },
"giveChar": { "giveChar": {
"usage": "用法:givechar <玩家> <角色ID|角色名> [数量]", "usage": "用法:givechar <玩家> <角色ID|角色名> [等级]",
"given": "已将角色 %s [等级 %s] 给与 %s。", "given": "已将角色 %s [等级 %s] 给与 %s。",
"invalid_avatar_id": "无效的角色ID。", "invalid_avatar_id": "无效的角色ID。",
"invalid_avatar_level": "无效的角色等级。", "invalid_avatar_level": "无效的角色等级。",
......
...@@ -159,7 +159,7 @@ ...@@ -159,7 +159,7 @@
"description": "給予指定聖遺物。" "description": "給予指定聖遺物。"
}, },
"giveChar": { "giveChar": {
"usage": "用法:givechar <player> <itemId|itemName> [amount]", "usage": "用法:givechar <player> <itemId|itemName> [level]",
"given": "已將 %s 等級 %s 給予 %s。", "given": "已將 %s 等級 %s 給予 %s。",
"invalid_avatar_id": "無效的角色ID。", "invalid_avatar_id": "無效的角色ID。",
"invalid_avatar_level": "無效的角色等級。.", "invalid_avatar_level": "無效的角色等級。.",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment