Data_UserGame.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  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_UserShop
  21. */
  22. public $shopdata;
  23. /**
  24. * @var Info_UserSecretshop 玩家神秘商城数据
  25. */
  26. public $userSecretshop;
  27. /**
  28. * 英雄
  29. * @var Info_UserGameHero
  30. */
  31. public $heros;
  32. /**
  33. * 私有字段
  34. * @var Info_PrivateState
  35. */
  36. public $privateState;
  37. /**
  38. * 关卡
  39. * @var Info_UserGateDifficulty
  40. */
  41. public $gates;
  42. /**
  43. * 地图解锁信息
  44. * @var Info_Map
  45. */
  46. public $map;
  47. // /**
  48. // * @var Info_UserTask 玩家任务数据
  49. // */
  50. // public $task;
  51. /**
  52. * 玩家任务卡商店数据
  53. * @var Info_TaskCard_Shop
  54. */
  55. public $taskCardShop;
  56. /**
  57. *
  58. * @var Info_UserPVP pvp信息
  59. */
  60. public $pvp;
  61. /**
  62. * 战斗队伍配置信息(使用时必须先json_decode)
  63. * @var dictionary
  64. */
  65. public $heroTeamConfig;
  66. /**
  67. * 新手引导
  68. * @var object
  69. */
  70. public $NewbieGuide;
  71. // /**
  72. // * 新手引导是否已经结束
  73. // * @var type
  74. // */
  75. // public $NewbieGuideOver = 1;
  76. /**
  77. * @var Data_UserProfile 角色画像
  78. */
  79. public $profile;
  80. /**
  81. * 圣哲学院
  82. * @var Info_College
  83. */
  84. public $college;
  85. /**
  86. * 神庙
  87. * @var Info_ShenMiao
  88. */
  89. public $shenmiao;
  90. /**
  91. * 宝石系统
  92. * @var Info_Gem
  93. */
  94. public $Gem;
  95. /**
  96. * 用于给各个字段赋默认初始值
  97. * @return \UserGameModel
  98. */
  99. public function initialize() {
  100. my_Assert(GameConfig::primordial_data(), "找不到账号初始化数据"); # 防御
  101. $this->baseInfo = new Info_UserBase();
  102. $this->baseInfo->initialize();
  103. # 添加默认战队设置
  104. $this->heroTeamConfig = JsonUtil::encode(GameConfig::primordial_data()->User_HeroTeamConfig);
  105. $this->store->initialize(); # 添加默认物品
  106. $this->privateState->currentId = count((array) $this->store->equipment) + 1;
  107. $this->heros->InitializeHero(); # 添加初始英雄
  108. $this->pvp = new Info_UserPVP();
  109. // $this->task->initialize(); # 任务初始化
  110. $this->taskCardShop = new Info_TaskCard_Shop();
  111. //$this->college->initialize();//改为按天解锁了
  112. $this->shenmiao->initialize();
  113. }
  114. /**
  115. * 构造函数
  116. * @param type $arg
  117. */
  118. public function __construct($arg = null) {
  119. if (null === $arg) { # 未传参数的情况下
  120. $this->shopdata = ObjectInit(); # 商城数据
  121. $this->privateState = new Info_PrivateState(); # 私有字段
  122. $this->privateState->initialize(); # 初始化默认数据
  123. $this->store = new Info_Store(); # 背包数据
  124. // $this->store->initialize(); # 添加默认物品
  125. $this->heros = new Info_UserGameHero(); # 英雄数据
  126. // $this->heros->InitializeHero(); # 添加初始英雄
  127. $this->gates = new Info_UserGateDifficulty(); # 初始化关卡默认数据
  128. $this->map = new Info_Map(); # 初始化地图解锁数据
  129. // $this->heroManual = new HeroManualModel(); # 初始化图鉴数据结构
  130. $this->NewbieGuide = new Info_NewbieGuide(); # 初始化新手引导结构
  131. // $this->pvp = new UserPVPModel(); # 初始化pvp模块
  132. $this->userSecretshop = new Info_UserSecretshop(); # 神秘商店
  133. // $this->task = new Info_UserTask(); # 任务数据
  134. $this->taskCardShop = new Info_TaskCard_Shop(); # 任务卡商店
  135. $this->college = new Info_College();
  136. $this->Gem = new Info_Gem();
  137. $this->shenmiao = new Info_ShenMiao();
  138. } else { # 实参
  139. parent::__construct($arg); # 调用Object的构造函数
  140. // $this->shopdata = new Info_UserShop($this->shopdata);
  141. //// $this->NewbieGuide= new info_us
  142. // $this->baseInfo = new Info_UserBase($this->baseInfo);
  143. // $this->gates = new Info_UserGateDifficulty($this->gates);
  144. // $this->heros = new Info_UserGameHero($this->heros);
  145. // $this->privateState = new Info_PrivateState($this->privateState);
  146. //// $this->profile = n
  147. // $this->pvp = new Info_UserPVP($this->pvp);
  148. // $this->store = new Info_Store($this->store);
  149. // $this->taskCardShop = new Info_TaskCard_Shop($this->taskCardShop);
  150. // $this->userSecretshop = new Info_UserSecretshop($this->userSecretshop);
  151. }
  152. $this->profile = new Data_UserProfile(); # 初始化用户画像模块
  153. }
  154. // <editor-fold defaultstate="collapsed" desc="实例方法">
  155. /**
  156. * 基础信息
  157. * @param bool $save 是否需要回存
  158. * @return Info_UserBase
  159. */
  160. public function base($save = true) {
  161. $this->baseInfo = new Info_UserBase($this->baseInfo);
  162. if ($save) {
  163. self::save_tag("baseInfo");
  164. }
  165. return $this->baseInfo;
  166. }
  167. /**
  168. * 玩家仓库
  169. * @param bool $save 是否需要回存
  170. * @return Info_Store
  171. */
  172. public function store($save = true) {
  173. $this->store = new Info_Store($this->store);
  174. if ($save) {
  175. self::save_tag("store");
  176. }
  177. return $this->store;
  178. }
  179. /**
  180. * 商店数据
  181. * @param bool $save 是否需要回存
  182. * @return Info_UserShop
  183. */
  184. public function shop($save = true) {
  185. $this->shopdata = new Info_UserShop($this->shopdata);
  186. if ($save) {
  187. self::save_tag("shopdata");
  188. }
  189. return $this->shopdata;
  190. }
  191. /**
  192. * 神秘商店
  193. * @param bool $save 是否需要回存
  194. * @return Info_UserSecretshop
  195. */
  196. public function secretshop($save = true) {
  197. $this->userSecretshop = new Info_UserSecretshop($this->userSecretshop);
  198. if ($save) {
  199. self::save_tag("userSecretshop");
  200. }
  201. return $this->userSecretshop;
  202. }
  203. /**
  204. * 英雄数据
  205. * @param bool $save 是否需要回存
  206. * @return Info_UserGameHero
  207. */
  208. public function heros($save = true) {
  209. $this->heros = new Info_UserGameHero($this->heros);
  210. if ($save) {
  211. self::save_tag("heros");
  212. }
  213. return $this->heros;
  214. }
  215. /**
  216. * 私有数据
  217. * @param bool $save 是否需要回存
  218. * @return Info_PrivateState
  219. */
  220. public function privateData($save = true) {
  221. $this->privateState = new Info_PrivateState($this->privateState);
  222. if ($save) {
  223. self::save_tag("privateState");
  224. }
  225. return $this->privateState;
  226. }
  227. /**
  228. * 关卡数据
  229. * @param bool $save 是否需要回存
  230. * @return Info_UserGateDifficulty
  231. */
  232. public function gates($save = true) {
  233. $this->gates = new Info_UserGateDifficulty($this->gates);
  234. if ($save) {
  235. self::save_tag("gates");
  236. }
  237. return $this->gates;
  238. }
  239. /**
  240. * 地图数据
  241. * @param bool $save 是否需要回存
  242. * @return Info_Map
  243. */
  244. public function map($save = true) {
  245. $this->map = new Info_Map($this->map);
  246. if ($save) {
  247. self::save_tag("map");
  248. }
  249. return $this->map;
  250. }
  251. /**
  252. * 任务卡商店
  253. * @param bool $save 是否需要回存
  254. * @return Info_TaskCard_Shop
  255. */
  256. public function taskCardShop($save = true) {
  257. $this->taskCardShop = new Info_TaskCard_Shop($this->taskCardShop);
  258. if ($save) {
  259. self::save_tag("taskCardShop");
  260. }
  261. return $this->taskCardShop;
  262. }
  263. /**
  264. * pvp数据
  265. * @param bool $save 是否需要回存
  266. * @return Info_UserPVP
  267. */
  268. public function pvp($save = true) {
  269. $this->pvp = new Info_UserPVP($this->pvp);
  270. if ($save) {
  271. self::save_tag("pvp");
  272. }
  273. return $this->pvp;
  274. }
  275. /**
  276. * 角色画像数据
  277. * @param bool $save 是否需要回存
  278. * @return Data_UserProfile
  279. */
  280. public function profile($save = true) {
  281. $this->profile = new Data_UserProfile($this->profile);
  282. if ($save) {
  283. self::save_tag("profile");
  284. }
  285. return $this->profile;
  286. }
  287. /**
  288. * 圣哲学院
  289. * @param bool $save 是否需要回存
  290. * @return Info_College
  291. */
  292. public function college($save = true) {
  293. $this->college = new Info_College($this->college);
  294. if ($save) {
  295. self::save_tag("college");
  296. }
  297. return $this->college;
  298. }
  299. /**
  300. * 新手引导
  301. * @param bool $save 是否需要回存
  302. * @return Info_NewbieGuide
  303. */
  304. public function newbieGuide($save = true) {
  305. $this->NewbieGuide = new Info_NewbieGuide($this->NewbieGuide);
  306. if ($save) {
  307. self::save_tag("NewbieGuide");
  308. }
  309. return $this->NewbieGuide;
  310. }
  311. /**
  312. * 战队配置
  313. * @param bool $save 是否需要回存
  314. * @return Info_NewbieGuide
  315. */
  316. public function &teamConfig($save = true) {
  317. // $this->NewbieGuide = new Info_NewbieGuide($this->NewbieGuide);
  318. if ($save) {
  319. self::save_tag("heroTeamConfig");
  320. }
  321. return $this->heroTeamConfig;
  322. }
  323. //
  324. // </editor-fold>
  325. }