Data_UserGame.php 6.4 KB

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