Data_UserGame.php 6.1 KB

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