Data_UserGame.php 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  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. * @return \UserGameModel
  88. */
  89. public function initialize() {
  90. my_Assert(GameConfig::primordial_data(), "找不到账号初始化数据"); # 防御
  91. $this->baseInfo = new Info_UserBase();
  92. $this->baseInfo->initialize();
  93. # 添加默认战队设置
  94. $this->heroTeamConfig = JsonUtil::encode(GameConfig::primordial_data()->User_HeroTeamConfig);
  95. $this->store->initialize(); # 添加默认物品
  96. $this->privateState->currentId = count((array) $this->store->equipment) + 1;
  97. $this->heros->InitializeHero(); # 添加初始英雄
  98. $this->pvp = new Info_UserPVP();
  99. // $this->task->initialize(); # 任务初始化
  100. $this->taskCardShop = new Info_TaskCard_Shop();
  101. $this->college->initialize();
  102. }
  103. /**
  104. * 构造函数
  105. * @param type $arg
  106. */
  107. public function __construct($arg = null) {
  108. if (null === $arg) { # 未传参数的情况下
  109. $this->shopdata = ObjectInit(); # 商城数据
  110. $this->privateState = new Info_PrivateState(); # 私有字段
  111. $this->privateState->initialize(); # 初始化默认数据
  112. $this->store = new Info_Store(); # 背包数据
  113. // $this->store->initialize(); # 添加默认物品
  114. $this->heros = new Info_UserGameHero(); # 英雄数据
  115. // $this->heros->InitializeHero(); # 添加初始英雄
  116. $this->gates = new Info_UserGateDifficulty(); # 初始化关卡默认数据
  117. $this->map = new Info_Map(); # 初始化地图解锁数据
  118. // $this->heroManual = new HeroManualModel(); # 初始化图鉴数据结构
  119. $this->NewbieGuide = new Info_NewbieGuide(); # 初始化新手引导结构
  120. // $this->pvp = new UserPVPModel(); # 初始化pvp模块
  121. $this->userSecretshop = new Info_UserSecretshop(); # 神秘商店
  122. // $this->task = new Info_UserTask(); # 任务数据
  123. $this->taskCardShop = new Info_TaskCard_Shop(); # 任务卡商店
  124. $this->college = new Info_College();
  125. } else { # 实参
  126. parent::__construct($arg); # 调用Object的构造函数
  127. // $this->shopdata = new Info_UserShop($this->shopdata);
  128. //// $this->NewbieGuide= new info_us
  129. // $this->baseInfo = new Info_UserBase($this->baseInfo);
  130. // $this->gates = new Info_UserGateDifficulty($this->gates);
  131. // $this->heros = new Info_UserGameHero($this->heros);
  132. // $this->privateState = new Info_PrivateState($this->privateState);
  133. //// $this->profile = n
  134. // $this->pvp = new Info_UserPVP($this->pvp);
  135. // $this->store = new Info_Store($this->store);
  136. // $this->taskCardShop = new Info_TaskCard_Shop($this->taskCardShop);
  137. // $this->userSecretshop = new Info_UserSecretshop($this->userSecretshop);
  138. }
  139. $this->profile = new Data_UserProfile(); # 初始化用户画像模块
  140. }
  141. // <editor-fold defaultstate="collapsed" desc="实例方法">
  142. /**
  143. * 基础信息
  144. * @param bool $save 是否需要回存
  145. * @return Info_UserBase
  146. */
  147. public function base($save = true) {
  148. $this->baseInfo = new Info_UserBase($this->baseInfo);
  149. if ($save) {
  150. self::save_tag("baseInfo");
  151. }
  152. return $this->baseInfo;
  153. }
  154. /**
  155. * 玩家仓库
  156. * @param bool $save 是否需要回存
  157. * @return Info_Store
  158. */
  159. public function store($save = true) {
  160. $this->store = new Info_Store($this->store);
  161. if ($save) {
  162. self::save_tag("store");
  163. }
  164. return $this->store;
  165. }
  166. /**
  167. * 商店数据
  168. * @param bool $save 是否需要回存
  169. * @return Info_UserShop
  170. */
  171. public function shop($save = true) {
  172. $this->shopdata = new Info_UserShop($this->shopdata);
  173. if ($save) {
  174. self::save_tag("shopdata");
  175. }
  176. return $this->shopdata;
  177. }
  178. /**
  179. * 神秘商店
  180. * @param bool $save 是否需要回存
  181. * @return Info_UserSecretshop
  182. */
  183. public function secretshop($save = true) {
  184. $this->userSecretshop = new Info_UserSecretshop($this->userSecretshop);
  185. if ($save) {
  186. self::save_tag("userSecretshop");
  187. }
  188. return $this->userSecretshop;
  189. }
  190. /**
  191. * 英雄数据
  192. * @param bool $save 是否需要回存
  193. * @return Info_UserGameHero
  194. */
  195. public function heros($save = true) {
  196. $this->heros = new Info_UserGameHero($this->heros);
  197. if ($save) {
  198. self::save_tag("heros");
  199. }
  200. return $this->heros;
  201. }
  202. /**
  203. * 私有数据
  204. * @param bool $save 是否需要回存
  205. * @return Info_PrivateState
  206. */
  207. public function private($save = true) {
  208. $this->privateState = new Info_PrivateState($this->privateState);
  209. if ($save) {
  210. self::save_tag("privateState");
  211. }
  212. return $this->privateState;
  213. }
  214. /**
  215. * 关卡数据
  216. * @param bool $save 是否需要回存
  217. * @return Info_UserGateDifficulty
  218. */
  219. public function gates($save = true) {
  220. $this->gates = new Info_UserGateDifficulty($this->gates);
  221. if ($save) {
  222. self::save_tag("gates");
  223. }
  224. return $this->gates;
  225. }
  226. /**
  227. * 地图数据
  228. * @param bool $save 是否需要回存
  229. * @return Info_Map
  230. */
  231. public function map($save = true) {
  232. $this->map = new Info_Map($this->map);
  233. if ($save) {
  234. self::save_tag("map");
  235. }
  236. return $this->map;
  237. }
  238. /**
  239. * 任务卡商店
  240. * @param bool $save 是否需要回存
  241. * @return Info_TaskCard_Shop
  242. */
  243. public function taskCardShop($save = true) {
  244. $this->taskCardShop = new Info_TaskCard_Shop($this->taskCardShop);
  245. if ($save) {
  246. self::save_tag("taskCardShop");
  247. }
  248. return $this->taskCardShop;
  249. }
  250. /**
  251. * pvp数据
  252. * @param bool $save 是否需要回存
  253. * @return Info_UserPVP
  254. */
  255. public function pvp($save = true) {
  256. $this->pvp = new Info_UserPVP($this->pvp);
  257. if ($save) {
  258. self::save_tag("pvp");
  259. }
  260. return $this->pvp;
  261. }
  262. /**
  263. * 角色画像数据
  264. * @param bool $save 是否需要回存
  265. * @return Data_UserProfile
  266. */
  267. public function profile($save = true) {
  268. $this->profile = new Data_UserProfile($this->profile);
  269. if ($save) {
  270. self::save_tag("profile");
  271. }
  272. return $this->profile;
  273. }
  274. /**
  275. * 圣哲学院
  276. * @param bool $save 是否需要回存
  277. * @return Info_College
  278. */
  279. public function college($save = true) {
  280. $this->college = new Info_College($this->college);
  281. if ($save) {
  282. self::save_tag("college");
  283. }
  284. return $this->college;
  285. }
  286. /**
  287. * 新手引导
  288. * @param bool $save 是否需要回存
  289. * @return Info_NewbieGuide
  290. */
  291. public function newbieGuide($save = true) {
  292. $this->NewbieGuide = new Info_NewbieGuide($this->NewbieGuide);
  293. if ($save) {
  294. self::save_tag("NewbieGuide");
  295. }
  296. return $this->NewbieGuide;
  297. }
  298. /**
  299. * 战队配置
  300. * @param bool $save 是否需要回存
  301. * @return Info_NewbieGuide
  302. */
  303. public function &teamConfig($save = true) {
  304. // $this->NewbieGuide = new Info_NewbieGuide($this->NewbieGuide);
  305. if ($save) {
  306. self::save_tag("heroTeamConfig");
  307. }
  308. return $this->heroTeamConfig;
  309. }
  310. //
  311. // </editor-fold>
  312. }