Data_UserGame.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. <?php
  2. namespace loyalsoft;
  3. /**
  4. * Description of UserGameModel
  5. * 游戏数据
  6. * @author gwang (mail@wanggangzero.cn)
  7. */
  8. class Data_UserGame extends HashSaver {
  9. /**
  10. * @var Info_UserBase 基础数据
  11. */
  12. public $baseInfo;
  13. /**
  14. * 玩家仓库
  15. * @var Info_Store
  16. */
  17. public $store;
  18. /**
  19. * 商城
  20. * @var Info_UserShop
  21. */
  22. public $shopdata;
  23. /**
  24. * @var Info_UserSecretshop 玩家神秘商城数据
  25. */
  26. public $userSecretshop;
  27. /**
  28. * 英雄
  29. * @var Info_UserGameHero
  30. */
  31. public $heros;
  32. /**
  33. * 私有字段
  34. * @var Info_PrivateState
  35. */
  36. public $privateState;
  37. /**
  38. * 关卡
  39. * @var Info_UserGateDifficulty
  40. */
  41. public $gates;
  42. // /**
  43. // * 地图解锁信息
  44. // * @var Info_Map
  45. // */
  46. // public $map;
  47. /**
  48. * 新版地图信息v2022.3
  49. * @var Info_NewMap
  50. */
  51. public $newMap;
  52. // /**
  53. // * @var Info_UserTask 玩家任务数据
  54. // */
  55. // public $task;
  56. /**
  57. * 玩家任务卡商店数据
  58. * @var Info_TaskCard_Shop
  59. */
  60. public $taskCardShop;
  61. /**
  62. *
  63. * @var Info_UserPVP pvp信息
  64. */
  65. public $pvp;
  66. /**
  67. * 战斗队伍配置信息(使用时必须先json_decode)
  68. * @var dictionary
  69. */
  70. public $heroTeamConfig;
  71. /**
  72. * 新手引导
  73. * @var object
  74. */
  75. public $NewbieGuide;
  76. // /**
  77. // * 新手引导是否已经结束
  78. // * @var type
  79. // */
  80. // public $NewbieGuideOver = 1;
  81. /**
  82. * @var Data_UserProfile 角色画像
  83. */
  84. public $profile;
  85. /**
  86. * 圣哲学院
  87. * @var Info_College
  88. */
  89. public $college;
  90. /**
  91. * 神庙
  92. * @var Info_ShenMiao
  93. */
  94. public $shenmiao;
  95. /**
  96. * 宝石系统
  97. * @var Info_Gem
  98. */
  99. public $Gem;
  100. /**
  101. *
  102. * @var Info_Pay
  103. */
  104. public $pay;
  105. /**
  106. * 用于给各个字段赋默认初始值
  107. * @return \UserGameModel
  108. */
  109. public function initialize() {
  110. my_Assert(GameConfig::primordial_data(), "找不到账号初始化数据"); # 防御
  111. $this->baseInfo = new Info_UserBase();
  112. $this->baseInfo->initialize();
  113. # 添加默认战队设置
  114. $this->heroTeamConfig = GameConfig::primordial_data()->User_HeroTeamConfig;
  115. $this->store->initialize(); # 添加默认物品
  116. $this->privateState->currentId = count((array) $this->store->equipment) + 1;
  117. $this->heros->InitializeHero(); # 添加初始英雄
  118. $this->pvp = new Info_UserPVP();
  119. // $this->task->initialize(); # 任务初始化
  120. $this->taskCardShop = new Info_TaskCard_Shop();
  121. //$this->college->initialize();//改为按天解锁了
  122. $this->shenmiao->initialize();
  123. }
  124. /**
  125. * 构造函数
  126. * @param type $arg
  127. */
  128. public function __construct($arg = null) {
  129. if (null === $arg) { # 未传参数的情况下
  130. $this->shopdata = ObjectInit(); # 商城数据
  131. $this->privateState = new Info_PrivateState(); # 私有字段
  132. $this->privateState->initialize(); # 初始化默认数据
  133. $this->store = new Info_Store(); # 背包数据
  134. // $this->store->initialize(); # 添加默认物品
  135. $this->heros = new Info_UserGameHero(); # 英雄数据
  136. // $this->heros->InitializeHero(); # 添加初始英雄
  137. $this->gates = new Info_UserGateDifficulty(); # 初始化关卡默认数据
  138. // $this->map = new Info_Map(); # 初始化地图解锁数据
  139. $this->newMap = new Info_NewMap(); # 初始化改版地图2022.3
  140. // $this->heroManual = new HeroManualModel(); # 初始化图鉴数据结构
  141. $this->NewbieGuide = new Info_NewbieGuide(); # 初始化新手引导结构
  142. // $this->pvp = new UserPVPModel(); # 初始化pvp模块
  143. $this->userSecretshop = new Info_UserSecretshop(); # 神秘商店
  144. // $this->task = new Info_UserTask(); # 任务数据
  145. $this->taskCardShop = new Info_TaskCard_Shop(); # 任务卡商店
  146. $this->college = new Info_College();
  147. $this->Gem = new Info_Gem();
  148. $this->shenmiao = new Info_ShenMiao();
  149. $this->pay = new Info_Pay();
  150. } else { # 实参
  151. parent::__construct($arg); # 调用Object的构造函数
  152. }
  153. $this->profile = new Data_UserProfile(); # 初始化用户画像模块
  154. }
  155. // <editor-fold defaultstate="collapsed" desc="实例方法">
  156. /**
  157. * 基础信息
  158. * @param bool $save 是否需要回存
  159. * @return Info_UserBase
  160. */
  161. public function base($save = true) {
  162. $this->baseInfo = new Info_UserBase($this->baseInfo);
  163. if ($save) {
  164. self::save_tag("baseInfo");
  165. }
  166. return $this->baseInfo;
  167. }
  168. /**
  169. * 玩家仓库
  170. * @param bool $save 是否需要回存
  171. * @return Info_Store
  172. */
  173. public function store($save = true) {
  174. $this->store = new Info_Store($this->store);
  175. if ($save) {
  176. self::save_tag("store");
  177. }
  178. return $this->store;
  179. }
  180. /**
  181. * 商店数据
  182. * @param bool $save 是否需要回存
  183. * @return Info_UserShop
  184. */
  185. public function shop($save = true) {
  186. $this->shopdata = new Info_UserShop($this->shopdata);
  187. if ($save) {
  188. self::save_tag("shopdata");
  189. }
  190. return $this->shopdata;
  191. }
  192. /**
  193. * 神秘商店
  194. * @param bool $save 是否需要回存
  195. * @return Info_UserSecretshop
  196. */
  197. public function secretshop($save = true) {
  198. $this->userSecretshop = new Info_UserSecretshop($this->userSecretshop);
  199. if ($save) {
  200. self::save_tag("userSecretshop");
  201. }
  202. return $this->userSecretshop;
  203. }
  204. /**
  205. * 英雄数据
  206. * @param bool $save 是否需要回存
  207. * @return Info_UserGameHero
  208. */
  209. public function heros($save = true) {
  210. $this->heros = new Info_UserGameHero($this->heros);
  211. if ($save) {
  212. self::save_tag("heros");
  213. }
  214. return $this->heros;
  215. }
  216. /**
  217. * 私有数据
  218. * @param bool $save 是否需要回存
  219. * @return Info_PrivateState
  220. */
  221. public function privateData($save = true) {
  222. $this->privateState = new Info_PrivateState($this->privateState);
  223. if ($save) {
  224. self::save_tag("privateState");
  225. }
  226. return $this->privateState;
  227. }
  228. /**
  229. * 关卡数据
  230. * @param bool $save 是否需要回存
  231. * @return Info_UserGateDifficulty
  232. */
  233. public function gates($save = true) {
  234. $this->gates = new Info_UserGateDifficulty($this->gates);
  235. if ($save) {
  236. self::save_tag("gates");
  237. }
  238. return $this->gates;
  239. }
  240. // /**
  241. // * 地图数据
  242. // * @param bool $save 是否需要回存
  243. // * @return Info_Map
  244. // */
  245. // public function map($save = true) {
  246. // $this->map = new Info_Map($this->map);
  247. // if ($save) {
  248. // self::save_tag("map");
  249. // }
  250. // return $this->map;
  251. // }
  252. /**
  253. * 新地图数据
  254. * @param bool $save 是否需要回存
  255. * @return Info_NewMap
  256. */
  257. public function newMap($save = true) {
  258. $this->newMap = new Info_NewMap($this->newMap);
  259. if ($save) {
  260. self::save_tag(__FUNCTION__);
  261. }
  262. return $this->newMap;
  263. }
  264. /**
  265. * 任务卡商店
  266. * @param bool $save 是否需要回存
  267. * @return Info_TaskCard_Shop
  268. */
  269. public function taskCardShop($save = true) {
  270. $this->taskCardShop = new Info_TaskCard_Shop($this->taskCardShop);
  271. if ($save) {
  272. self::save_tag("taskCardShop");
  273. }
  274. return $this->taskCardShop;
  275. }
  276. /**
  277. * pvp数据
  278. * @param bool $save 是否需要回存
  279. * @return Info_UserPVP
  280. */
  281. public function pvp($save = true) {
  282. $this->pvp = new Info_UserPVP($this->pvp);
  283. if ($save) {
  284. self::save_tag("pvp");
  285. }
  286. return $this->pvp;
  287. }
  288. /**
  289. * 角色画像数据
  290. * @param bool $save 是否需要回存
  291. * @return Data_UserProfile
  292. */
  293. public function profile($save = true) {
  294. $this->profile = new Data_UserProfile($this->profile);
  295. if ($save) {
  296. self::save_tag("profile");
  297. }
  298. return $this->profile;
  299. }
  300. /**
  301. * 圣哲学院
  302. * @param bool $save 是否需要回存
  303. * @return Info_College
  304. */
  305. public function college($save = true) {
  306. $this->college = new Info_College($this->college);
  307. if ($save) {
  308. self::save_tag("college");
  309. }
  310. return $this->college;
  311. }
  312. /**
  313. * 新手引导
  314. * @param bool $save 是否需要回存
  315. * @return Info_NewbieGuide
  316. */
  317. public function newbieGuide($save = true) {
  318. $this->NewbieGuide = new Info_NewbieGuide($this->NewbieGuide);
  319. if ($save) {
  320. self::save_tag("NewbieGuide");
  321. }
  322. return $this->NewbieGuide;
  323. }
  324. /**
  325. * 战队配置
  326. * @param bool $save 是否需要回存
  327. * @return Info_NewbieGuide
  328. */
  329. public function &teamConfig($save = true) {
  330. // $this->NewbieGuide = new Info_NewbieGuide($this->NewbieGuide);
  331. if ($save) {
  332. self::save_tag("heroTeamConfig");
  333. }
  334. return $this->heroTeamConfig;
  335. }
  336. //
  337. // </editor-fold>
  338. }