|
@@ -18,16 +18,22 @@
|
|
|
*/
|
|
|
package com.iohao.mmo.bag.client;
|
|
|
|
|
|
+import com.iohao.game.action.skeleton.protocol.wrapper.BoolValue;
|
|
|
import com.iohao.game.external.client.AbstractInputCommandRegion;
|
|
|
import com.iohao.game.external.client.command.InputRequestData;
|
|
|
import com.iohao.game.external.client.kit.ScannerKit;
|
|
|
+import com.iohao.game.external.client.kit.SplitParam;
|
|
|
+import com.iohao.mmo.bag.ItemIdConst;
|
|
|
import com.iohao.mmo.bag.cmd.BagCmd;
|
|
|
import com.iohao.mmo.bag.proto.BagItemMessage;
|
|
|
import com.iohao.mmo.bag.proto.BagMessage;
|
|
|
+import com.iohao.mmo.bag.proto.UseMessage;
|
|
|
import com.iohao.mmo.common.provide.kit.JsonKit;
|
|
|
import com.iohao.mmo.common.snow.SnowKit;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
/**
|
|
|
* @author 渔民小镇
|
|
|
* @date 2023-08-04
|
|
@@ -38,6 +44,16 @@ public class BagInputCommandRegion extends AbstractInputCommandRegion {
|
|
|
public void initInputCommand() {
|
|
|
this.inputCommandCreate.cmd = BagCmd.cmd;
|
|
|
request();
|
|
|
+ useRequest();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void loginSuccessCallback() {
|
|
|
+ // 添加一些经验值道具
|
|
|
+ var bagItemMessage = BagInternalHelper.ofBagItemMessage(ItemIdConst.expId);
|
|
|
+ bagItemMessage.quantity = 10;
|
|
|
+ log.info("添加 {} 个经验值道具 {}", bagItemMessage.quantity, bagItemMessage);
|
|
|
+ ofRequestCommand(BagCmd.incrementItem).request(bagItemMessage);
|
|
|
}
|
|
|
|
|
|
private void request() {
|
|
@@ -78,10 +94,9 @@ public class BagInputCommandRegion extends AbstractInputCommandRegion {
|
|
|
ScannerKit.log(() -> log.info("输入需要减少的物品信息,格式 [背包物品id-数量]"));
|
|
|
String inputType = ScannerKit.nextLine("1-1");
|
|
|
|
|
|
- String[] split = inputType.split("-");
|
|
|
-
|
|
|
- String id = split[0];
|
|
|
- int quantity = Integer.parseInt(split[1]);
|
|
|
+ SplitParam param = new SplitParam(inputType);
|
|
|
+ String id = param.getString(0);
|
|
|
+ int quantity = param.getInt(1, 1);
|
|
|
|
|
|
BagItemMessage bagItemMessage = new BagItemMessage();
|
|
|
bagItemMessage.id = id;
|
|
@@ -99,5 +114,30 @@ public class BagInputCommandRegion extends AbstractInputCommandRegion {
|
|
|
// 重新查询一次背包
|
|
|
ofRequestCommand(BagCmd.bag).request();
|
|
|
}).setDescription("从背包减少物品").setInputRequestData(inputRequestData);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void useRequest() {
|
|
|
+ InputRequestData inputRequestData = () -> {
|
|
|
+ ScannerKit.log(() -> log.info("输入需要使用的背包物品,格式 [背包物品id-数量]"));
|
|
|
+ String inputType = ScannerKit.nextLine("1-1");
|
|
|
+
|
|
|
+ SplitParam param = new SplitParam(inputType);
|
|
|
+ String id = param.getString(0);
|
|
|
+ int quantity = param.getInt(1, 1);
|
|
|
+
|
|
|
+ var useItemMessage = BagInternalHelper.ofUseItemMessage(id);
|
|
|
+ useItemMessage.quantity = quantity;
|
|
|
+
|
|
|
+ UseMessage useMessage = new UseMessage();
|
|
|
+ useMessage.useItems = List.of(useItemMessage);
|
|
|
+ return useMessage;
|
|
|
+ };
|
|
|
+
|
|
|
+ ofCommand(BagCmd.use).callback(BoolValue.class, result -> {
|
|
|
+ var value = result.getValue();
|
|
|
+ log.info("value : {}", value);
|
|
|
+ }).setDescription("使用背包物品").setInputRequestData(inputRequestData);
|
|
|
}
|
|
|
}
|