mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-27 02:43:15 +00:00
Add missing forging protos, add data for ongoing forges to player, handler for ForgeStartReq.
This commit is contained in:
parent
0c0719bd2a
commit
47bcfe96f6
14
proto/ForgeQueueManipulateReq.proto
Normal file
14
proto/ForgeQueueManipulateReq.proto
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
option java_package = "emu.grasscutter.net.proto";
|
||||||
|
|
||||||
|
import "ForgeQueueManipulateType.proto";
|
||||||
|
|
||||||
|
// CmdId: 659
|
||||||
|
// EnetChannelId: 0
|
||||||
|
// EnetIsReliable: true
|
||||||
|
// IsAllowClient: true
|
||||||
|
message ForgeQueueManipulateReq {
|
||||||
|
uint32 forge_queue_id = 11;
|
||||||
|
ForgeQueueManipulateType manipulate_type = 7;
|
||||||
|
}
|
17
proto/ForgeQueueManipulateRsp.proto
Normal file
17
proto/ForgeQueueManipulateRsp.proto
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
option java_package = "emu.grasscutter.net.proto";
|
||||||
|
|
||||||
|
import "ForgeQueueManipulateType.proto";
|
||||||
|
import "ItemParam.proto";
|
||||||
|
|
||||||
|
// CmdId: 684
|
||||||
|
// EnetChannelId: 0
|
||||||
|
// EnetIsReliable: true
|
||||||
|
message ForgeQueueManipulateRsp {
|
||||||
|
int32 retcode = 13;
|
||||||
|
ForgeQueueManipulateType manipulate_type = 8;
|
||||||
|
repeated ItemParam output_item_list = 6;
|
||||||
|
repeated ItemParam return_item_list = 10;
|
||||||
|
repeated ItemParam extra_output_item_list = 3;
|
||||||
|
}
|
8
proto/ForgeQueueManipulateType.proto
Normal file
8
proto/ForgeQueueManipulateType.proto
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
option java_package = "emu.grasscutter.net.proto";
|
||||||
|
|
||||||
|
enum ForgeQueueManipulateType {
|
||||||
|
FORGE_QUEUE_MANIPULATE_TYPE_RECEIVE_OUTPUT = 0;
|
||||||
|
FORGE_QUEUE_MANIPULATE_TYPE_STOP_FORGE = 1;
|
||||||
|
}
|
13
proto/ForgeStartReq.proto
Normal file
13
proto/ForgeStartReq.proto
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
option java_package = "emu.grasscutter.net.proto";
|
||||||
|
|
||||||
|
// CmdId: 676
|
||||||
|
// EnetChannelId: 0
|
||||||
|
// EnetIsReliable: true
|
||||||
|
// IsAllowClient: true
|
||||||
|
message ForgeStartReq {
|
||||||
|
uint32 forge_id = 9;
|
||||||
|
uint32 forge_count = 11;
|
||||||
|
uint32 avatar_id = 13;
|
||||||
|
}
|
10
proto/ForgeStartRsp.proto
Normal file
10
proto/ForgeStartRsp.proto
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
option java_package = "emu.grasscutter.net.proto";
|
||||||
|
|
||||||
|
// CmdId: 672
|
||||||
|
// EnetChannelId: 0
|
||||||
|
// EnetIsReliable: true
|
||||||
|
message ForgeStartRsp {
|
||||||
|
int32 retcode = 11;
|
||||||
|
}
|
@ -0,0 +1,52 @@
|
|||||||
|
package emu.grasscutter.game.managers.ForgingManager;
|
||||||
|
|
||||||
|
import dev.morphia.annotations.Entity;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
public class ActiveForgeData {
|
||||||
|
private int queueId;
|
||||||
|
private int forgeId;
|
||||||
|
private int avatarId;
|
||||||
|
|
||||||
|
private int startTime;
|
||||||
|
private int forgeTime;
|
||||||
|
// private int finishedCount;
|
||||||
|
// private int unfinishedCount;
|
||||||
|
// private int nextFinishTimestamp;
|
||||||
|
// private int totalFinishTimestamp;
|
||||||
|
|
||||||
|
public int getQueueId() {
|
||||||
|
return this.queueId;
|
||||||
|
}
|
||||||
|
public void setQueueId(int value) {
|
||||||
|
this.queueId = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getForgeId() {
|
||||||
|
return this.forgeId;
|
||||||
|
}
|
||||||
|
public void setForgeId(int value) {
|
||||||
|
this.forgeId = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAvatarId() {
|
||||||
|
return this.avatarId;
|
||||||
|
}
|
||||||
|
public void setAvatarId(int value) {
|
||||||
|
this.avatarId = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getStartTime() {
|
||||||
|
return this.startTime;
|
||||||
|
}
|
||||||
|
public void setStartTime(int value) {
|
||||||
|
this.startTime = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getForgeTime() {
|
||||||
|
return this.forgeTime;
|
||||||
|
}
|
||||||
|
public void setForgeTime(int value) {
|
||||||
|
this.forgeTime = value;
|
||||||
|
}
|
||||||
|
}
|
@ -1,11 +1,17 @@
|
|||||||
package emu.grasscutter.game.managers.ForgingManager;
|
package emu.grasscutter.game.managers.ForgingManager;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import emu.grasscutter.game.inventory.GameItem;
|
import emu.grasscutter.game.inventory.GameItem;
|
||||||
import emu.grasscutter.game.player.Player;
|
import emu.grasscutter.game.player.Player;
|
||||||
|
import emu.grasscutter.net.proto.ForgeStartReqOuterClass;
|
||||||
|
import emu.grasscutter.net.proto.ForgeQueueDataOuterClass.ForgeQueueData;
|
||||||
import emu.grasscutter.net.proto.RetcodeOuterClass.Retcode;
|
import emu.grasscutter.net.proto.RetcodeOuterClass.Retcode;
|
||||||
import emu.grasscutter.server.packet.send.PacketForgeDataNotify;
|
import emu.grasscutter.server.packet.send.PacketForgeDataNotify;
|
||||||
import emu.grasscutter.server.packet.send.PacketForgeFormulaDataNotify;
|
import emu.grasscutter.server.packet.send.PacketForgeFormulaDataNotify;
|
||||||
import emu.grasscutter.server.packet.send.PacketForgeGetQueueDataRsp;
|
import emu.grasscutter.server.packet.send.PacketForgeGetQueueDataRsp;
|
||||||
|
import emu.grasscutter.server.packet.send.PacketForgeStartRsp;
|
||||||
|
|
||||||
public class ForgingManager {
|
public class ForgingManager {
|
||||||
private final Player player;
|
private final Player player;
|
||||||
@ -46,20 +52,49 @@ public class ForgingManager {
|
|||||||
: 1;
|
: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Map<Integer, ForgeQueueData> determineCurrentForgeQueueData() {
|
||||||
|
// Dummy for now.
|
||||||
|
ForgeQueueData data = ForgeQueueData.newBuilder()
|
||||||
|
.setQueueId(1)
|
||||||
|
.setForgeId(11001)
|
||||||
|
.setFinishCount(2)
|
||||||
|
.setUnfinishCount(3)
|
||||||
|
.setNextFinishTimestamp(0)
|
||||||
|
.setNextFinishTimestamp(0)
|
||||||
|
.setAvatarId(0)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Map<Integer, ForgeQueueData> res = new HashMap<>();
|
||||||
|
res.put(1, data);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
public void sendForgeDataNotify() {
|
public void sendForgeDataNotify() {
|
||||||
// Determine the number of queues and unlocked items.
|
// Determine the number of queues and unlocked items.
|
||||||
int numQueues = this.determineNumberOfQueues();
|
int numQueues = this.determineNumberOfQueues();
|
||||||
var unlockedItems = this.player.getUnlockedForgingBlueprints();
|
var unlockedItems = this.player.getUnlockedForgingBlueprints();
|
||||||
|
var queueData = this.determineCurrentForgeQueueData();
|
||||||
|
|
||||||
// Send notification.
|
// Send notification.
|
||||||
this.player.sendPacket(new PacketForgeDataNotify(unlockedItems, numQueues));
|
this.player.sendPacket(new PacketForgeDataNotify(unlockedItems, numQueues, queueData));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleForgeGetQueueDataReq() {
|
public void handleForgeGetQueueDataReq() {
|
||||||
// Determine the number of queues.
|
// Determine the number of queues.
|
||||||
int numQueues = this.determineNumberOfQueues();
|
int numQueues = this.determineNumberOfQueues();
|
||||||
|
var queueData = this.determineCurrentForgeQueueData();
|
||||||
|
|
||||||
// Reply.
|
// Reply.
|
||||||
this.player.sendPacket(new PacketForgeGetQueueDataRsp(Retcode.RET_SUCC, numQueues));
|
this.player.sendPacket(new PacketForgeGetQueueDataRsp(Retcode.RET_SUCC, numQueues, queueData));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**********
|
||||||
|
Initiate forging process.
|
||||||
|
**********/
|
||||||
|
public void startForging(ForgeStartReqOuterClass.ForgeStartReq req) {
|
||||||
|
// Dummy for now.
|
||||||
|
this.player.sendPacket(new PacketForgeStartRsp(Retcode.RET_SUCC));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ import emu.grasscutter.game.managers.InsectCaptureManager;
|
|||||||
import emu.grasscutter.game.managers.StaminaManager.StaminaManager;
|
import emu.grasscutter.game.managers.StaminaManager.StaminaManager;
|
||||||
import emu.grasscutter.game.managers.SotSManager;
|
import emu.grasscutter.game.managers.SotSManager;
|
||||||
import emu.grasscutter.game.managers.EnergyManager.EnergyManager;
|
import emu.grasscutter.game.managers.EnergyManager.EnergyManager;
|
||||||
|
import emu.grasscutter.game.managers.ForgingManager.ActiveForgeData;
|
||||||
import emu.grasscutter.game.managers.ForgingManager.ForgingManager;
|
import emu.grasscutter.game.managers.ForgingManager.ForgingManager;
|
||||||
import emu.grasscutter.game.props.ActionReason;
|
import emu.grasscutter.game.props.ActionReason;
|
||||||
import emu.grasscutter.game.props.EntityType;
|
import emu.grasscutter.game.props.EntityType;
|
||||||
@ -92,6 +93,7 @@ public class Player {
|
|||||||
private Set<Integer> flyCloakList;
|
private Set<Integer> flyCloakList;
|
||||||
private Set<Integer> costumeList;
|
private Set<Integer> costumeList;
|
||||||
private Set<Integer> unlockedForgingBlueprints;
|
private Set<Integer> unlockedForgingBlueprints;
|
||||||
|
private Map<Integer, ActiveForgeData> activeForges;
|
||||||
|
|
||||||
private Integer widgetId;
|
private Integer widgetId;
|
||||||
|
|
||||||
@ -188,6 +190,7 @@ public class Player {
|
|||||||
this.flyCloakList = new HashSet<>();
|
this.flyCloakList = new HashSet<>();
|
||||||
this.costumeList = new HashSet<>();
|
this.costumeList = new HashSet<>();
|
||||||
this.unlockedForgingBlueprints = new HashSet<>();
|
this.unlockedForgingBlueprints = new HashSet<>();
|
||||||
|
this.activeForges = new HashMap<>();
|
||||||
|
|
||||||
this.setSceneId(3);
|
this.setSceneId(3);
|
||||||
this.setRegionId(1);
|
this.setRegionId(1);
|
||||||
@ -523,7 +526,11 @@ public class Player {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Set<Integer> getUnlockedForgingBlueprints() {
|
public Set<Integer> getUnlockedForgingBlueprints() {
|
||||||
return unlockedForgingBlueprints;
|
return this.unlockedForgingBlueprints;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<Integer, ActiveForgeData> getActiveForges() {
|
||||||
|
return this.activeForges;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MpSettingType getMpSetting() {
|
public MpSettingType getMpSetting() {
|
||||||
|
@ -0,0 +1,23 @@
|
|||||||
|
package emu.grasscutter.server.packet.recv;
|
||||||
|
|
||||||
|
import java.lang.invoke.StringConcatFactory;
|
||||||
|
|
||||||
|
import emu.grasscutter.Grasscutter;
|
||||||
|
import emu.grasscutter.net.packet.Opcodes;
|
||||||
|
import emu.grasscutter.net.packet.PacketHandler;
|
||||||
|
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||||
|
import emu.grasscutter.net.proto.ForgeStartReqOuterClass;
|
||||||
|
import emu.grasscutter.net.proto.DeleteFriendReqOuterClass;
|
||||||
|
import emu.grasscutter.server.game.GameSession;
|
||||||
|
import emu.grasscutter.server.packet.send.PacketDelMailRsp;
|
||||||
|
|
||||||
|
@Opcodes(PacketOpcodes.ForgeStartReq)
|
||||||
|
public class HandlerForgeStartReq extends PacketHandler {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
|
||||||
|
ForgeStartReqOuterClass.ForgeStartReq req = ForgeStartReqOuterClass.ForgeStartReq.parseFrom(payload);
|
||||||
|
session.getPlayer().getForgingManager().startForging(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,30 +1,27 @@
|
|||||||
package emu.grasscutter.server.packet.send;
|
package emu.grasscutter.server.packet.send;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
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.ForgeDataNotifyOuterClass.ForgeDataNotify;
|
import emu.grasscutter.net.proto.ForgeDataNotifyOuterClass.ForgeDataNotify;
|
||||||
|
import emu.grasscutter.net.proto.ForgeQueueDataOuterClass.ForgeQueueData;
|
||||||
|
|
||||||
public class PacketForgeDataNotify extends BasePacket {
|
public class PacketForgeDataNotify extends BasePacket {
|
||||||
|
|
||||||
public PacketForgeDataNotify(Iterable<Integer> unlockedItem, int numQueues) {
|
public PacketForgeDataNotify(Iterable<Integer> unlockedItem, int numQueues, Map<Integer, ForgeQueueData> queueData) {
|
||||||
super(PacketOpcodes.ForgeDataNotify);
|
super(PacketOpcodes.ForgeDataNotify);
|
||||||
|
|
||||||
/*int adventureRank = player.getLevel();
|
ForgeDataNotify.Builder builder = ForgeDataNotify.newBuilder()
|
||||||
int numQueues =
|
|
||||||
(adventureRank >= 15) ? 4
|
|
||||||
: (adventureRank >= 10) ? 3
|
|
||||||
: (adventureRank >= 5) ? 2
|
|
||||||
: 1;*/
|
|
||||||
|
|
||||||
ForgeDataNotify proto = ForgeDataNotify.newBuilder()
|
|
||||||
.addAllForgeIdList(unlockedItem)
|
.addAllForgeIdList(unlockedItem)
|
||||||
.setMaxQueueNum(numQueues)
|
.setMaxQueueNum(numQueues);
|
||||||
.build();
|
|
||||||
|
|
||||||
// ToDo: Add the information for the actual forging queues
|
for (int queueId : queueData.keySet()) {
|
||||||
// and ongoing forges.
|
var data = queueData.get(queueId);
|
||||||
|
builder.putForgeQueueMap(queueId, data);
|
||||||
|
}
|
||||||
|
|
||||||
this.setData(proto);
|
this.setData(builder.build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,23 +1,27 @@
|
|||||||
package emu.grasscutter.server.packet.send;
|
package emu.grasscutter.server.packet.send;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
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.ForgeGetQueueDataRspOuterClass.ForgeGetQueueDataRsp;
|
import emu.grasscutter.net.proto.ForgeGetQueueDataRspOuterClass.ForgeGetQueueDataRsp;
|
||||||
|
import emu.grasscutter.net.proto.ForgeQueueDataOuterClass.ForgeQueueData;
|
||||||
import emu.grasscutter.net.proto.RetcodeOuterClass.Retcode;
|
import emu.grasscutter.net.proto.RetcodeOuterClass.Retcode;
|
||||||
|
|
||||||
public class PacketForgeGetQueueDataRsp extends BasePacket {
|
public class PacketForgeGetQueueDataRsp extends BasePacket {
|
||||||
|
|
||||||
public PacketForgeGetQueueDataRsp(Retcode retcode, int numQueues) {
|
public PacketForgeGetQueueDataRsp(Retcode retcode, int numQueues, Map<Integer, ForgeQueueData> queueData) {
|
||||||
super(PacketOpcodes.ForgeGetQueueDataRsp);
|
super(PacketOpcodes.ForgeGetQueueDataRsp);
|
||||||
|
|
||||||
ForgeGetQueueDataRsp proto = ForgeGetQueueDataRsp.newBuilder()
|
ForgeGetQueueDataRsp.Builder builder = ForgeGetQueueDataRsp.newBuilder()
|
||||||
.setRetcode(retcode.getNumber())
|
.setRetcode(retcode.getNumber())
|
||||||
.setMaxQueueNum(numQueues)
|
.setMaxQueueNum(numQueues);
|
||||||
.build();
|
|
||||||
|
|
||||||
// ToDo: Add the information for the actual forging queues
|
for (int queueId : queueData.keySet()) {
|
||||||
// and ongoing forges.
|
var data = queueData.get(queueId);
|
||||||
|
builder.putForgeQueueMap(queueId, data);
|
||||||
|
}
|
||||||
|
|
||||||
this.setData(proto);
|
this.setData(builder.build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,23 @@
|
|||||||
|
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.ForgeStartRspOuterClass.ForgeStartRsp;
|
||||||
|
import emu.grasscutter.net.proto.RetcodeOuterClass.Retcode;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class PacketForgeStartRsp extends BasePacket {
|
||||||
|
|
||||||
|
public PacketForgeStartRsp(Retcode retcode) {
|
||||||
|
super(PacketOpcodes.ForgeStartRsp);
|
||||||
|
|
||||||
|
ForgeStartRsp proto = ForgeStartRsp.newBuilder()
|
||||||
|
.setRetcode(retcode.getNumber())
|
||||||
|
.build();
|
||||||
|
|
||||||
|
this.setData(proto);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user