EquipInputCommandRegion.java 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /*
  2. * ioGame
  3. * Copyright (C) 2021 - 2023 渔民小镇 (262610965@qq.com、luoyizhu@gmail.com) . All Rights Reserved.
  4. * # iohao.com . 渔民小镇
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Affero General Public License as
  8. * published by the Free Software Foundation, either version 3 of the
  9. * License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Affero General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Affero General Public License
  17. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  18. */
  19. package com.iohao.mmo.client.input;
  20. import com.iohao.game.action.skeleton.protocol.wrapper.ByteValueList;
  21. import com.iohao.game.action.skeleton.protocol.wrapper.StringValue;
  22. import com.iohao.game.action.skeleton.protocol.wrapper.StringValueList;
  23. import com.iohao.game.action.skeleton.protocol.wrapper.WrapperKit;
  24. import com.iohao.game.external.client.AbstractInputCommandRegion;
  25. import com.iohao.game.external.client.command.InputRequestData;
  26. import com.iohao.game.external.client.kit.ScannerKit;
  27. import com.iohao.game.external.client.kit.SplitParam;
  28. import com.iohao.mmo.common.provide.kit.JsonKit;
  29. import com.iohao.mmo.equip.cmd.EquipCmd;
  30. import com.iohao.mmo.equip.proto.*;
  31. import lombok.extern.slf4j.Slf4j;
  32. import java.util.Arrays;
  33. import java.util.List;
  34. /**
  35. * @author 唐斌
  36. * @date 2023-07-30
  37. */
  38. @Slf4j
  39. public class EquipInputCommandRegion extends AbstractInputCommandRegion {
  40. @Override
  41. public void initInputCommand() {
  42. this.inputCommandCreate.cmd = EquipCmd.cmd;
  43. this.inputCommandCreate.cmdName = "装备模块";
  44. request();
  45. listen();
  46. }
  47. private void listen() {
  48. }
  49. private void request() {
  50. InputRequestData inputRequestData;
  51. // 10-1 获取装备列表信息
  52. ofCommand(EquipCmd.getEquipList).callback(ByteValueList.class, result -> {
  53. List<EquipMessage> value = result.toList(EquipMessage.class);
  54. log.info("装备列表信息 : {}", JsonKit.toJsonString(value));
  55. }).setDescription("获取装备列表信息");
  56. // 10-2 查询装备信息
  57. inputRequestData = () -> {
  58. ScannerKit.log(() -> log.info("请输入要查询的装备id"));
  59. String id = ScannerKit.nextLine();
  60. // 请求参数
  61. StringValue stringValue = StringValue.of(id);
  62. return stringValue;
  63. };
  64. ofCommand(EquipCmd.getEquip).callback(EquipMessage.class, result -> {
  65. EquipMessage value = result.getValue();
  66. log.info("装备属性信息 : {}", JsonKit.toJsonString(value));
  67. }).setDescription("查询装备信息").setInputRequestData(inputRequestData);
  68. // 10-3 重新随机基础属性
  69. inputRequestData = () -> {
  70. ScannerKit.log(() -> log.info("请输入装备id"));
  71. String id = ScannerKit.nextLine();
  72. // 请求参数
  73. StringValue stringValue = StringValue.of(id);
  74. return stringValue;
  75. };
  76. ofCommand(EquipCmd.resetEquipBasic).callback(EquipShowMessage.class, result -> {
  77. EquipShowMessage value = result.getValue();
  78. log.info("装备信息 : {}", JsonKit.toJsonString(value));
  79. }).setDescription("重新随机装备基础属性").setInputRequestData(inputRequestData);
  80. // 10-4 重新随机词条
  81. inputRequestData = () -> {
  82. ScannerKit.log(() -> log.info("请输入装备id和极品概率增益百分比,格式 [装备id-增益百分比]"));
  83. String inputValue = ScannerKit.nextLine("1-0.3");
  84. SplitParam param = new SplitParam(inputValue);
  85. String id = param.getString(0);
  86. String excellentRateString = param.getString(1);
  87. EquipResetMessage equipResetMessage = new EquipResetMessage();
  88. equipResetMessage.id = id;
  89. equipResetMessage.excellentRateString = excellentRateString;
  90. return equipResetMessage;
  91. };
  92. ofCommand(EquipCmd.resetEquip).callback(EquipShowMessage.class, result -> {
  93. EquipShowMessage value = result.getValue();
  94. log.info("装备属性信息 : {}", JsonKit.toJsonString(value));
  95. }).setDescription("重新随机词条").setInputRequestData(inputRequestData);
  96. // 10-5 批量删除装备
  97. inputRequestData = () -> {
  98. ScannerKit.log(() -> log.info("请输入要删除的装备id,格式 [装备1id-装备2id]"));
  99. String ids = ScannerKit.nextLine("1-1");
  100. List<String> idList = Arrays.asList(ids.split("-"));
  101. // 请求参数
  102. StringValueList listValue = WrapperKit.ofListStringValue(idList);
  103. return listValue;
  104. };
  105. ofCommand(EquipCmd.delEquipBatch).callback(EquipMessage.class, result -> {
  106. EquipMessage value = result.getValue();
  107. log.info("装备属性信息 : {}", JsonKit.toJsonString(value));
  108. }).setDescription("批量删除装备").setInputRequestData(inputRequestData);
  109. // 10-13 根据装备库列表批量随机新的装备
  110. inputRequestData = () -> {
  111. ScannerKit.log(() -> log.info(
  112. "请输入装备库itemTypeId列表,格式 [装备库itemTypeId1-装备库itemTypeId2-装备库itemTypeId3...]"));
  113. String itemTypeIds = ScannerKit.nextLine("1-1");
  114. List<String> itemTypeIdList = Arrays.asList(itemTypeIds.split("-"));
  115. // 请求参数
  116. StringValueList listValue = WrapperKit.ofListStringValue(itemTypeIdList);
  117. return listValue;
  118. };
  119. ofCommand(EquipCmd.randomEquip).callback(ByteValueList.class, result -> {
  120. List<EquipShowMessage> value = result.toList(EquipShowMessage.class);
  121. log.info("装备列表信息 : {}", JsonKit.toJsonString(value));
  122. }).setDescription("根据装备库列表批量随机新的装备").setInputRequestData(inputRequestData);
  123. }
  124. }