Data_UserGame.php 6.0 KB

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