Data_UserGame.php 6.1 KB

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