CommonClient.java 2.6 KB

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