CommonClient.java 2.8 KB

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