123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246 |
- <?php
- namespace loyalsoft;
- /**
- * Description of UserGameModel
- * 游戏数据
- * @author gwang (mail@wanggangzero.cn)
- */
- class Data_UserGame extends HashSaver {
- /**
- * @var Info_UserBase 基础数据
- */
- public $baseInfo;
- /**
- *
- * @var Info_Pay
- */
- public $pay;
- /**
- * @var string token
- */
- public $TK = "";
- public function RegenNewToken() {
- $arr = str_split(GameConstants::GetCipherString());
- shuffle($arr);
- $ntk = join('', array_slice($arr, 3, 8));
- $this->TK = $ntk;
- }
- /**
- * 用于给各个字段赋默认初始值
- * @return \UserGameModel
- */
- public function initialize() {
- my_Assert(GameConfig::primordial_data(), "找不到账号初始化数据"); # 防御
- $this->baseInfo->initialize();
-
- }
- /**
- * 构造函数
- * @param type $arg
- */
- public function __construct($arg = null) {
- if (null === $arg) { # 未传参数的情况下
- $this->baseInfo = new Info_UserBase();
- } else { # 实参
- parent::__construct($arg); # 调用Object的构造函数
- $this->base()->fixArray();
- }
- }
- // <editor-fold defaultstate="collapsed" desc="实例方法">
- /**
- * 基础信息
- * @param bool $save 是否需要回存
- * @return Info_UserBase
- */
- public function base($save = true) {
- $this->baseInfo = new Info_UserBase($this->baseInfo);
- if ($save) {
- self::save_tag("baseInfo");
- }
- return $this->baseInfo;
- }
- /**
- * 玩家仓库
- * @param bool $save 是否需要回存
- * @return Info_Store
- */
- public function store($save = true) {
- $this->store = new Info_Store($this->store);
- if ($save) {
- self::save_tag("store");
- }
- return $this->store;
- }
- /**
- * 商店数据
- * @param bool $save 是否需要回存
- * @return Info_UserShop
- */
- public function shop($save = true) {
- $this->shopdata = new Info_UserShop($this->shopdata);
- if ($save) {
- self::save_tag("shopdata");
- }
- return $this->shopdata;
- }
- /**
- * 神秘商店
- * @param bool $save 是否需要回存
- * @return Info_UserSecretshop
- */
- public function secretshop($save = true) {
- $this->userSecretshop = new Info_UserSecretshop($this->userSecretshop);
- if ($save) {
- self::save_tag("userSecretshop");
- }
- return $this->userSecretshop;
- }
- /**
- * 英雄数据
- * @param bool $save 是否需要回存
- * @return Info_UserGameHero
- */
- public function heros($save = true) {
- $this->heros = new Info_UserGameHero($this->heros);
- if ($save) {
- self::save_tag("heros");
- }
- return $this->heros;
- }
- /**
- * 私有数据
- * @param bool $save 是否需要回存
- * @return Info_PrivateState
- */
- public function privateData($save = true) {
- $this->privateState = new Info_PrivateState($this->privateState);
- if ($save) {
- self::save_tag("privateState");
- }
- return $this->privateState;
- }
- /**
- * 关卡数据
- * @param bool $save 是否需要回存
- * @return Info_UserGateDifficulty
- */
- public function gates($save = true) {
- $this->gates = new Info_UserGateDifficulty($this->gates);
- if ($save) {
- self::save_tag("gates");
- }
- return $this->gates;
- }
- /**
- * 新地图数据
- * @param bool $save 是否需要回存
- * @return Info_NewMap
- */
- public function newMap($save = true) {
- $this->newMap = new Info_NewMap($this->newMap);
- if ($save) {
- self::save_tag(__FUNCTION__);
- }
- return $this->newMap;
- }
- /**
- * 任务卡商店
- * @param bool $save 是否需要回存
- * @return Info_TaskCard_Shop
- */
- public function taskCardShop($save = true) {
- $this->taskCardShop = new Info_TaskCard_Shop($this->taskCardShop);
- if ($save) {
- self::save_tag("taskCardShop");
- }
- return $this->taskCardShop;
- }
- /**
- * pvp数据
- * @param bool $save 是否需要回存
- * @return Info_UserPVP
- */
- public function pvp($save = true) {
- $this->pvp = new Info_UserPVP($this->pvp);
- if ($save) {
- self::save_tag("pvp");
- }
- return $this->pvp;
- }
- /**
- * 角色画像数据
- * @param bool $save 是否需要回存
- * @return Data_UserProfile
- */
- public function profile($save = true) {
- $this->profile = new Data_UserProfile($this->profile);
- if ($save) {
- self::save_tag("profile");
- }
- return $this->profile;
- }
- /**
- * 圣哲学院
- * @param bool $save 是否需要回存
- * @return Info_College
- */
- public function college($save = true) {
- $this->college = new Info_College($this->college);
- if ($save) {
- self::save_tag("college");
- }
- return $this->college;
- }
- /**
- * 新手引导
- * @param bool $save 是否需要回存
- * @return Info_NewbieGuide
- */
- public function newbieGuide($save = true) {
- $this->NewbieGuide = new Info_NewbieGuide($this->NewbieGuide);
- if ($save) {
- self::save_tag("NewbieGuide");
- }
- return $this->NewbieGuide;
- }
- /**
- * 战队配置
- * @param bool $save 是否需要回存
- * @return Info_NewbieGuide
- */
- public function &teamConfig($save = true) {
- // $this->NewbieGuide = new Info_NewbieGuide($this->NewbieGuide);
- if ($save) {
- self::save_tag("heroTeamConfig");
- }
- return $this->heroTeamConfig;
- }
- //
- // </editor-fold>
- }
|