Data_UserGame.php 6.0 KB

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