CommonClient.java 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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;
  20. import com.iohao.game.external.client.InputCommandRegion;
  21. import com.iohao.game.external.client.join.ClientRunOne;
  22. import com.iohao.game.external.client.user.ClientUser;
  23. import com.iohao.game.external.client.user.DefaultClientUser;
  24. import com.iohao.mmo.bag.client.BagInputCommandRegion;
  25. import com.iohao.mmo.bag.client.ItemInputCommandRegion;
  26. import com.iohao.mmo.equip.client.EquipInputCommandRegion;
  27. import com.iohao.mmo.level.client.LevelInputCommandRegion;
  28. import com.iohao.mmo.login.client.LoginInputCommandRegion;
  29. import com.iohao.mmo.map.client.MapInputCommandRegion;
  30. import com.iohao.mmo.person.client.PersonInputCommandRegion;
  31. import java.util.List;
  32. /**
  33. * @author 渔民小镇
  34. * @date 2023-07-21
  35. */
  36. public class CommonClient {
  37. static void start(long userId) {
  38. // 客户端的用户(玩家)
  39. ClientUser clientUser = new DefaultClientUser();
  40. clientUser.setJwt(String.valueOf(userId));
  41. List<InputCommandRegion> inputCommandRegions = listInputCommandRegion();
  42. // 启动模拟客户端
  43. new ClientRunOne()
  44. .setClientUser(clientUser)
  45. .setInputCommandRegions(inputCommandRegions)
  46. .startup();
  47. }
  48. private static List<InputCommandRegion> listInputCommandRegion() {
  49. LoginInputCommandRegion loginInputCommandRegion = new LoginInputCommandRegion();
  50. MapInputCommandRegion mapInputCommandRegion = new MapInputCommandRegion();
  51. PersonInputCommandRegion personInputCommandRegion = new PersonInputCommandRegion();
  52. LevelInputCommandRegion levelInputCommandRegion = new LevelInputCommandRegion();
  53. BagInputCommandRegion bagInputCommandRegion = new BagInputCommandRegion();
  54. ItemInputCommandRegion itemInputCommandRegion = new ItemInputCommandRegion();
  55. EquipInputCommandRegion equipInputCommandRegion = new EquipInputCommandRegion();
  56. // 模拟请求数据
  57. return List.of(
  58. // 登录
  59. loginInputCommandRegion
  60. // 地图
  61. // , mapInputCommandRegion
  62. // 人物、英雄
  63. // , personInputCommandRegion
  64. // 等级相关
  65. , levelInputCommandRegion
  66. // 物品
  67. , itemInputCommandRegion
  68. // 背包
  69. , bagInputCommandRegion
  70. // 装备相关
  71. , equipInputCommandRegion
  72. );
  73. }
  74. }