Data_UserGame.php 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  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_Gates
  21. */
  22. public $gates;
  23. /**
  24. * 关卡
  25. * @var Info_Heros
  26. */
  27. public $heros;
  28. /**
  29. * 私有信息
  30. * @var Info_PrivateState
  31. */
  32. public $privateState;
  33. /**
  34. * @var string token
  35. */
  36. public $TK = "";
  37. public function RegenNewToken() {
  38. $arr = str_split(GameConstants::GetCipherString());
  39. shuffle($arr);
  40. $ntk = join('', array_slice($arr, 3, 8));
  41. $this->TK = $ntk;
  42. }
  43. /**
  44. * 用于给各个字段赋默认初始值
  45. * @return \UserGameModel
  46. */
  47. public function initialize() {
  48. //my_Assert(GameConfig::primordial_data(), "找不到账号初始化数据"); # 防御
  49. //$this->baseInfo = new Info_UserBase();
  50. $this->baseInfo->initialize();
  51. $this->store->initialize();
  52. $this->gates->initialize();
  53. $this->heros->initialize();
  54. $this->privateState->initialize();
  55. }
  56. /**
  57. * 构造函数
  58. * @param type $arg
  59. */
  60. public function __construct($arg = null) {
  61. if (null === $arg) { # 未传参数的情况下
  62. $this->baseInfo = new Info_UserBase();
  63. $this->store = new Info_Store();
  64. $this->gates = new Info_Gates();
  65. $this->heros = new Info_Heros();
  66. $this->privateState = new Info_PrivateState();
  67. } else { # 实参
  68. parent::__construct($arg); # 调用Object的构造函数
  69. $this->base()->fixArray();
  70. $this->privateData()->fixArray();
  71. $this->gates()->fixArray();
  72. }
  73. }
  74. // <editor-fold defaultstate="collapsed" desc="实例方法">
  75. /**
  76. * 关卡数据
  77. * @param bool $save 是否需要回存
  78. * @return Info_UserGateDifficulty
  79. */
  80. public function gates($save = true) {
  81. $this->gates = new Info_Gates($this->gates);
  82. if ($save) {
  83. $this->save_tag("gates");
  84. }
  85. return $this->gates;
  86. }
  87. /**
  88. * 基础信息
  89. * @param bool $save 是否需要回存
  90. * @return Info_UserBase
  91. */
  92. public function base($save = true) {
  93. $this->baseInfo = new Info_UserBase($this->baseInfo);
  94. if ($save) {
  95. $this->save_tag("baseInfo");
  96. }
  97. return $this->baseInfo;
  98. }
  99. /**
  100. * 玩家仓库
  101. * @param bool $save 是否需要回存
  102. * @return Info_Store
  103. */
  104. public function store($save = true) {
  105. $this->store = new Info_Store($this->store);
  106. if ($save) {
  107. $this->save_tag("store");
  108. }
  109. return $this->store;
  110. }
  111. /**
  112. * 商店数据
  113. * @param bool $save 是否需要回存
  114. * @return Info_UserShop
  115. */
  116. public function shop($save = true) {
  117. $this->shopdata = new Info_UserShop($this->shopdata);
  118. if ($save) {
  119. $this->save_tag("shopdata");
  120. }
  121. return $this->shopdata;
  122. }
  123. /**
  124. * 神秘商店
  125. * @param bool $save 是否需要回存
  126. * @return Info_UserSecretshop
  127. */
  128. public function secretshop($save = true) {
  129. $this->userSecretshop = new Info_UserSecretshop($this->userSecretshop);
  130. if ($save) {
  131. $this->save_tag("userSecretshop");
  132. }
  133. return $this->userSecretshop;
  134. }
  135. /**
  136. * 英雄数据
  137. * @param bool $save 是否需要回存
  138. * @return Info_UserGameHero
  139. */
  140. public function heros($save = true) {
  141. $this->heros = new Info_Heros($this->heros);
  142. if ($save) {
  143. $this->save_tag("heros");
  144. }
  145. return $this->heros;
  146. }
  147. /**
  148. * 私有数据
  149. * @param bool $save 是否需要回存
  150. * @return Info_PrivateState
  151. */
  152. public function privateData($save = true) {
  153. $this->privateState = new Info_PrivateState($this->privateState);
  154. if ($save) {
  155. $this->save_tag("privateState");
  156. }
  157. return $this->privateState;
  158. }
  159. /**
  160. * 新地图数据
  161. * @param bool $save 是否需要回存
  162. * @return Info_NewMap
  163. */
  164. public function newMap($save = true) {
  165. $this->newMap = new Info_NewMap($this->newMap);
  166. if ($save) {
  167. $this->save_tag(__FUNCTION__);
  168. }
  169. return $this->newMap;
  170. }
  171. /**
  172. * 任务卡商店
  173. * @param bool $save 是否需要回存
  174. * @return Info_TaskCard_Shop
  175. */
  176. public function taskCardShop($save = true) {
  177. $this->taskCardShop = new Info_TaskCard_Shop($this->taskCardShop);
  178. if ($save) {
  179. $this->save_tag("taskCardShop");
  180. }
  181. return $this->taskCardShop;
  182. }
  183. /**
  184. * pvp数据
  185. * @param bool $save 是否需要回存
  186. * @return Info_UserPVP
  187. */
  188. public function pvp($save = true) {
  189. $this->pvp = new Info_UserPVP($this->pvp);
  190. if ($save) {
  191. $this->save_tag("pvp");
  192. }
  193. return $this->pvp;
  194. }
  195. /**
  196. * 角色画像数据
  197. * @param bool $save 是否需要回存
  198. * @return Data_UserProfile
  199. */
  200. public function profile($save = true) {
  201. $this->profile = new Data_UserProfile($this->profile);
  202. if ($save) {
  203. $this->save_tag("profile");
  204. }
  205. return $this->profile;
  206. }
  207. /**
  208. * 圣哲学院
  209. * @param bool $save 是否需要回存
  210. * @return Info_College
  211. */
  212. public function college($save = true) {
  213. $this->college = new Info_College($this->college);
  214. if ($save) {
  215. $this->save_tag("college");
  216. }
  217. return $this->college;
  218. }
  219. /**
  220. * 新手引导
  221. * @param bool $save 是否需要回存
  222. * @return Info_NewbieGuide
  223. */
  224. public function newbieGuide($save = true) {
  225. $this->NewbieGuide = new Info_NewbieGuide($this->NewbieGuide);
  226. if ($save) {
  227. $this->save_tag("NewbieGuide");
  228. }
  229. return $this->NewbieGuide;
  230. }
  231. /**
  232. * 战队配置
  233. * @param bool $save 是否需要回存
  234. * @return Info_NewbieGuide
  235. */
  236. public function &teamConfig($save = true) {
  237. // $this->NewbieGuide = new Info_NewbieGuide($this->NewbieGuide);
  238. if ($save) {
  239. $this->save_tag("heroTeamConfig");
  240. }
  241. return $this->heroTeamConfig;
  242. }
  243. //
  244. // </editor-fold>
  245. }