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_Hero
  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. }
  72. }
  73. // <editor-fold defaultstate="collapsed" desc="实例方法">
  74. /**
  75. * 关卡数据
  76. * @param bool $save 是否需要回存
  77. * @return Info_UserGateDifficulty
  78. */
  79. public function gates($save = true) {
  80. $this->gates = new Info_Gates($this->gates);
  81. if ($save) {
  82. self::save_tag("gates");
  83. }
  84. return $this->gates;
  85. }
  86. /**
  87. * 基础信息
  88. * @param bool $save 是否需要回存
  89. * @return Info_UserBase
  90. */
  91. public function base($save = true) {
  92. $this->baseInfo = new Info_UserBase($this->baseInfo);
  93. if ($save) {
  94. self::save_tag("baseInfo");
  95. }
  96. return $this->baseInfo;
  97. }
  98. /**
  99. * 玩家仓库
  100. * @param bool $save 是否需要回存
  101. * @return Info_Store
  102. */
  103. public function store($save = true) {
  104. $this->store = new Info_Store($this->store);
  105. if ($save) {
  106. self::save_tag("store");
  107. }
  108. return $this->store;
  109. }
  110. /**
  111. * 商店数据
  112. * @param bool $save 是否需要回存
  113. * @return Info_UserShop
  114. */
  115. public function shop($save = true) {
  116. $this->shopdata = new Info_UserShop($this->shopdata);
  117. if ($save) {
  118. self::save_tag("shopdata");
  119. }
  120. return $this->shopdata;
  121. }
  122. /**
  123. * 神秘商店
  124. * @param bool $save 是否需要回存
  125. * @return Info_UserSecretshop
  126. */
  127. public function secretshop($save = true) {
  128. $this->userSecretshop = new Info_UserSecretshop($this->userSecretshop);
  129. if ($save) {
  130. self::save_tag("userSecretshop");
  131. }
  132. return $this->userSecretshop;
  133. }
  134. /**
  135. * 英雄数据
  136. * @param bool $save 是否需要回存
  137. * @return Info_UserGameHero
  138. */
  139. public function heros($save = true) {
  140. $this->heros = new Info_Heros($this->heros);
  141. if ($save) {
  142. self::save_tag("heros");
  143. }
  144. return $this->heros;
  145. }
  146. /**
  147. * 私有数据
  148. * @param bool $save 是否需要回存
  149. * @return Info_PrivateState
  150. */
  151. public function privateData($save = true) {
  152. $this->privateState = new Info_PrivateState($this->privateState);
  153. if ($save) {
  154. self::save_tag("privateState");
  155. }
  156. return $this->privateState;
  157. }
  158. /**
  159. * 新地图数据
  160. * @param bool $save 是否需要回存
  161. * @return Info_NewMap
  162. */
  163. public function newMap($save = true) {
  164. $this->newMap = new Info_NewMap($this->newMap);
  165. if ($save) {
  166. self::save_tag(__FUNCTION__);
  167. }
  168. return $this->newMap;
  169. }
  170. /**
  171. * 任务卡商店
  172. * @param bool $save 是否需要回存
  173. * @return Info_TaskCard_Shop
  174. */
  175. public function taskCardShop($save = true) {
  176. $this->taskCardShop = new Info_TaskCard_Shop($this->taskCardShop);
  177. if ($save) {
  178. self::save_tag("taskCardShop");
  179. }
  180. return $this->taskCardShop;
  181. }
  182. /**
  183. * pvp数据
  184. * @param bool $save 是否需要回存
  185. * @return Info_UserPVP
  186. */
  187. public function pvp($save = true) {
  188. $this->pvp = new Info_UserPVP($this->pvp);
  189. if ($save) {
  190. self::save_tag("pvp");
  191. }
  192. return $this->pvp;
  193. }
  194. /**
  195. * 角色画像数据
  196. * @param bool $save 是否需要回存
  197. * @return Data_UserProfile
  198. */
  199. public function profile($save = true) {
  200. $this->profile = new Data_UserProfile($this->profile);
  201. if ($save) {
  202. self::save_tag("profile");
  203. }
  204. return $this->profile;
  205. }
  206. /**
  207. * 圣哲学院
  208. * @param bool $save 是否需要回存
  209. * @return Info_College
  210. */
  211. public function college($save = true) {
  212. $this->college = new Info_College($this->college);
  213. if ($save) {
  214. self::save_tag("college");
  215. }
  216. return $this->college;
  217. }
  218. /**
  219. * 新手引导
  220. * @param bool $save 是否需要回存
  221. * @return Info_NewbieGuide
  222. */
  223. public function newbieGuide($save = true) {
  224. $this->NewbieGuide = new Info_NewbieGuide($this->NewbieGuide);
  225. if ($save) {
  226. self::save_tag("NewbieGuide");
  227. }
  228. return $this->NewbieGuide;
  229. }
  230. /**
  231. * 战队配置
  232. * @param bool $save 是否需要回存
  233. * @return Info_NewbieGuide
  234. */
  235. public function &teamConfig($save = true) {
  236. // $this->NewbieGuide = new Info_NewbieGuide($this->NewbieGuide);
  237. if ($save) {
  238. self::save_tag("heroTeamConfig");
  239. }
  240. return $this->heroTeamConfig;
  241. }
  242. //
  243. // </editor-fold>
  244. }