|
@@ -160,183 +160,6 @@ class Data_UserGame extends HashSaver {
|
|
$this->profile = new Data_UserProfile(); # 初始化用户画像模块
|
|
$this->profile = new Data_UserProfile(); # 初始化用户画像模块
|
|
}
|
|
}
|
|
|
|
|
|
- // <editor-fold defaultstate="collapsed" desc=" functions ">
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 扣除玩家钻石
|
|
|
|
- * @param Info_UserBase $user
|
|
|
|
- * @param int $amt
|
|
|
|
- * @return bool 成功与否
|
|
|
|
- */
|
|
|
|
- static public function Consume_Cash($user, $amt) {
|
|
|
|
- if ($amt >= 0 && isset($user) && isset($user->cash)) {
|
|
|
|
- if ($user->cash - $amt >= 0) {
|
|
|
|
- $user->cash -= $amt;
|
|
|
|
- return true;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 扣除玩家金币
|
|
|
|
- * @param Info_UserBase $user
|
|
|
|
- * @param int $amt
|
|
|
|
- * @return boolean true:成功, false:金币不足
|
|
|
|
- */
|
|
|
|
- static public function Consume_Gold($user, $amt) {
|
|
|
|
- if ($amt > 0 && isset($user) && isset($user->gold)) {
|
|
|
|
- if ($user->gold - $amt >= 0) {
|
|
|
|
- $user->gold -= $amt;
|
|
|
|
- return true;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 扣除资源点
|
|
|
|
- * @param Info_UserBase $user
|
|
|
|
- * @param type $amt
|
|
|
|
- * @return boolean true:成功, false:资源点不足
|
|
|
|
- */
|
|
|
|
- static public function Consume_ResPoint($user, $amt) {
|
|
|
|
- if ($amt > 0 && isset($user) && isset($user->resPoint)) {
|
|
|
|
- if ($user->resPoint - $amt >= 0) {
|
|
|
|
- $user->resPoint -= $amt;
|
|
|
|
- return true;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 扣除玩家友情点
|
|
|
|
- * @param Info_UserBase $user
|
|
|
|
- * @param int $amt
|
|
|
|
- */
|
|
|
|
- static public function Consume_FriendShipPoint($user, $amt) {
|
|
|
|
- if ($amt > 0 && isset($user) && isset($user->friendPoint)) {
|
|
|
|
- if ($user->friendPoint - $amt >= 0) {
|
|
|
|
- $user->friendPoint -= $amt;
|
|
|
|
- return true;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 扣除玩家碎片
|
|
|
|
- * @param Data_UserGame $user
|
|
|
|
- * @param int $segmentId 碎片ID
|
|
|
|
- * @param int $amt 数量
|
|
|
|
- * @return boolean true 成功, false 失败
|
|
|
|
- */
|
|
|
|
- static public function Consume_HeroSegment($user, $segmentId, $amt) {
|
|
|
|
- if ($amt > 0 && isset($user)) {
|
|
|
|
- if (CommUtil::isPropertyExists($user->store->items, $segmentId)) {
|
|
|
|
- if ($user->store->items->$segmentId - $amt >= 0) {
|
|
|
|
- $user->store->items->$segmentId -= $amt;
|
|
|
|
- return true;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 增加用户钻石
|
|
|
|
- * @param Info_UserBase $user
|
|
|
|
- * @param type $amt
|
|
|
|
- * @return type
|
|
|
|
- */
|
|
|
|
- static function Add_Cash($user, $amt) {
|
|
|
|
- my_Assert($user, "user为空");
|
|
|
|
- my_Assert($amt >= 0, "amt值为负");
|
|
|
|
- $user->cash += $amt;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 增加用户友情点
|
|
|
|
- * @param Info_UserBase $user
|
|
|
|
- * @param type $amt
|
|
|
|
- * @return type
|
|
|
|
- */
|
|
|
|
- static function Add_FriendPoint($user, $amt) {
|
|
|
|
- my_Assert($user, "user为空");
|
|
|
|
- my_Assert($amt >= 0, "amt值为负");
|
|
|
|
- $user->friendPoint += $amt; # 业务逻辑
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 用户获得经验值
|
|
|
|
- * @param Info_UserBase $user Description
|
|
|
|
- * @param int $amt
|
|
|
|
- */
|
|
|
|
- static function Add_Exp($user, $amt) {
|
|
|
|
- my_Assert($user, "user为空");
|
|
|
|
- my_Assert($amt >= 0, "amt值为负");
|
|
|
|
- $cfgLVs = GameConfig::playerlevel();
|
|
|
|
- $user->xp += $amt;
|
|
|
|
- $initLevel = $curLevel = $user->level;
|
|
|
|
- $nextLevel = $curLevel + 1;
|
|
|
|
- while ($user->xp >= $cfgLVs->$nextLevel->xp_need) { # 超过升级所需经验
|
|
|
|
- if ($user->level < glc()->Game_MaxPlayerLevel) { # 如果未到达最大等级
|
|
|
|
- $user->level++;
|
|
|
|
- $user->xp -= $cfgLVs->$nextLevel->xp_need;
|
|
|
|
- $curLevel = $user->level;
|
|
|
|
- $nextLevel = $curLevel + 1;
|
|
|
|
- my_Assert(CommUtil::isPropertyExists($cfgLVs, $nextLevel), ErrCode::err_const_no); // "取英雄升级常量数据失败." . $nextLevel . "级");
|
|
|
|
- $user->maxXp = $cfgLVs->$nextLevel->xp_need;
|
|
|
|
-// StatProc::UserLevel($nowlv); // 等级统计
|
|
|
|
- // todo:: 发发宝箱奖励, 如果有的话
|
|
|
|
- } else { // 如果已到达最大等级则仅补齐缺失的经验即可
|
|
|
|
- $user->xp = $user->maxXp; # 经验不能超过最大值
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if ($user->level != $initLevel) { # 插入玩家升级的系统消息
|
|
|
|
- SystemProc::UserLevelUp(req()->zoneid, $user, $user->level);
|
|
|
|
- TaskProc::OnUserLevelUp($user->level); # 通知任务模块,这里应该有事件模块
|
|
|
|
- EventProc::OnUserLevelup($initLevel, $user->level); # 事件模块
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 用户获得金币
|
|
|
|
- * @param Info_UserBase $user 玩家数据
|
|
|
|
- * @param int $amt
|
|
|
|
- */
|
|
|
|
- static function Add_Gold(&$user, $amt) {
|
|
|
|
- my_Assert($user, "参数null");
|
|
|
|
- my_Assert($amt >= 0, "参数为负");
|
|
|
|
- $user->gold += $amt;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 给玩家增加体力
|
|
|
|
- * @param int $amt
|
|
|
|
- * @return type
|
|
|
|
- */
|
|
|
|
- static function Add_tili($amt) {
|
|
|
|
- $user = req()->userInfo->game;
|
|
|
|
- my_Assert($user, "user为空");
|
|
|
|
- my_Assert($amt >= 0, "体力amt小于0");
|
|
|
|
- ActiveProc::ChangeTili($amt);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 增加资源点
|
|
|
|
- * @param Info_UserBase $user
|
|
|
|
- * @param type $amt
|
|
|
|
- */
|
|
|
|
- static function Add_resPoint(&$user, $amt) {
|
|
|
|
- my_Assert($user, "参数null");
|
|
|
|
- my_Assert($amt >= 0, "参数为负");
|
|
|
|
- $user->resPoint += $amt;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-// </editor-fold>
|
|
|
|
// <editor-fold defaultstate="collapsed" desc="实例方法">
|
|
// <editor-fold defaultstate="collapsed" desc="实例方法">
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -344,7 +167,7 @@ class Data_UserGame extends HashSaver {
|
|
* @param bool $save 是否需要回存
|
|
* @param bool $save 是否需要回存
|
|
* @return Info_UserBase
|
|
* @return Info_UserBase
|
|
*/
|
|
*/
|
|
- public function base($save = false) {
|
|
|
|
|
|
+ public function base($save = true) {
|
|
$this->baseInfo = new Info_UserBase($this->baseInfo);
|
|
$this->baseInfo = new Info_UserBase($this->baseInfo);
|
|
if ($save) {
|
|
if ($save) {
|
|
self::save_tag("baseInfo");
|
|
self::save_tag("baseInfo");
|
|
@@ -357,7 +180,7 @@ class Data_UserGame extends HashSaver {
|
|
* @param bool $save 是否需要回存
|
|
* @param bool $save 是否需要回存
|
|
* @return Info_Store
|
|
* @return Info_Store
|
|
*/
|
|
*/
|
|
- public function store($save = false) {
|
|
|
|
|
|
+ public function store($save = true) {
|
|
$this->store = new Info_Store($this->store);
|
|
$this->store = new Info_Store($this->store);
|
|
if ($save) {
|
|
if ($save) {
|
|
self::save_tag("store");
|
|
self::save_tag("store");
|
|
@@ -370,7 +193,7 @@ class Data_UserGame extends HashSaver {
|
|
* @param bool $save 是否需要回存
|
|
* @param bool $save 是否需要回存
|
|
* @return Info_UserShop
|
|
* @return Info_UserShop
|
|
*/
|
|
*/
|
|
- public function shop($save = false) {
|
|
|
|
|
|
+ public function shop($save = true) {
|
|
$this->shopdata = new Info_UserShop($this->shopdata);
|
|
$this->shopdata = new Info_UserShop($this->shopdata);
|
|
if ($save) {
|
|
if ($save) {
|
|
self::save_tag("shopdata");
|
|
self::save_tag("shopdata");
|
|
@@ -383,7 +206,7 @@ class Data_UserGame extends HashSaver {
|
|
* @param bool $save 是否需要回存
|
|
* @param bool $save 是否需要回存
|
|
* @return Info_UserSecretshop
|
|
* @return Info_UserSecretshop
|
|
*/
|
|
*/
|
|
- public function secretshop($save = false) {
|
|
|
|
|
|
+ public function secretshop($save = true) {
|
|
$this->userSecretshop = new Info_UserSecretshop($this->userSecretshop);
|
|
$this->userSecretshop = new Info_UserSecretshop($this->userSecretshop);
|
|
if ($save) {
|
|
if ($save) {
|
|
self::save_tag("userSecretshop");
|
|
self::save_tag("userSecretshop");
|
|
@@ -396,7 +219,7 @@ class Data_UserGame extends HashSaver {
|
|
* @param bool $save 是否需要回存
|
|
* @param bool $save 是否需要回存
|
|
* @return Info_UserGameHero
|
|
* @return Info_UserGameHero
|
|
*/
|
|
*/
|
|
- public function heros($save = false) {
|
|
|
|
|
|
+ public function heros($save = true) {
|
|
$this->heros = new Info_UserGameHero($this->heros);
|
|
$this->heros = new Info_UserGameHero($this->heros);
|
|
if ($save) {
|
|
if ($save) {
|
|
self::save_tag("heros");
|
|
self::save_tag("heros");
|
|
@@ -409,7 +232,7 @@ class Data_UserGame extends HashSaver {
|
|
* @param bool $save 是否需要回存
|
|
* @param bool $save 是否需要回存
|
|
* @return Info_PrivateState
|
|
* @return Info_PrivateState
|
|
*/
|
|
*/
|
|
- public function private($save = false) {
|
|
|
|
|
|
+ public function private($save = true) {
|
|
$this->privateState = new Info_PrivateState($this->privateState);
|
|
$this->privateState = new Info_PrivateState($this->privateState);
|
|
if ($save) {
|
|
if ($save) {
|
|
self::save_tag("privateState");
|
|
self::save_tag("privateState");
|
|
@@ -422,7 +245,7 @@ class Data_UserGame extends HashSaver {
|
|
* @param bool $save 是否需要回存
|
|
* @param bool $save 是否需要回存
|
|
* @return Info_UserGateDifficulty
|
|
* @return Info_UserGateDifficulty
|
|
*/
|
|
*/
|
|
- public function gates($save = false) {
|
|
|
|
|
|
+ public function gates($save = true) {
|
|
$this->gates = new Info_UserGateDifficulty($this->gates);
|
|
$this->gates = new Info_UserGateDifficulty($this->gates);
|
|
if ($save) {
|
|
if ($save) {
|
|
self::save_tag("gates");
|
|
self::save_tag("gates");
|
|
@@ -435,7 +258,7 @@ class Data_UserGame extends HashSaver {
|
|
* @param bool $save 是否需要回存
|
|
* @param bool $save 是否需要回存
|
|
* @return Info_Map
|
|
* @return Info_Map
|
|
*/
|
|
*/
|
|
- public function map($save = false) {
|
|
|
|
|
|
+ public function map($save = true) {
|
|
$this->map = new Info_Map($this->map);
|
|
$this->map = new Info_Map($this->map);
|
|
if ($save) {
|
|
if ($save) {
|
|
self::save_tag("map");
|
|
self::save_tag("map");
|
|
@@ -448,7 +271,7 @@ class Data_UserGame extends HashSaver {
|
|
* @param bool $save 是否需要回存
|
|
* @param bool $save 是否需要回存
|
|
* @return Info_TaskCard_Shop
|
|
* @return Info_TaskCard_Shop
|
|
*/
|
|
*/
|
|
- public function taskCardShop($save = false) {
|
|
|
|
|
|
+ public function taskCardShop($save = true) {
|
|
$this->taskCardShop = new Info_TaskCard_Shop($this->taskCardShop);
|
|
$this->taskCardShop = new Info_TaskCard_Shop($this->taskCardShop);
|
|
if ($save) {
|
|
if ($save) {
|
|
self::save_tag("taskCardShop");
|
|
self::save_tag("taskCardShop");
|
|
@@ -461,7 +284,7 @@ class Data_UserGame extends HashSaver {
|
|
* @param bool $save 是否需要回存
|
|
* @param bool $save 是否需要回存
|
|
* @return Info_UserPVP
|
|
* @return Info_UserPVP
|
|
*/
|
|
*/
|
|
- public function pvp($save = false) {
|
|
|
|
|
|
+ public function pvp($save = true) {
|
|
$this->pvp = new Info_UserPVP($this->pvp);
|
|
$this->pvp = new Info_UserPVP($this->pvp);
|
|
if ($save) {
|
|
if ($save) {
|
|
self::save_tag("pvp");
|
|
self::save_tag("pvp");
|
|
@@ -474,7 +297,7 @@ class Data_UserGame extends HashSaver {
|
|
* @param bool $save 是否需要回存
|
|
* @param bool $save 是否需要回存
|
|
* @return Data_UserProfile
|
|
* @return Data_UserProfile
|
|
*/
|
|
*/
|
|
- public function profile($save = false) {
|
|
|
|
|
|
+ public function profile($save = true) {
|
|
$this->profile = new Data_UserProfile($this->profile);
|
|
$this->profile = new Data_UserProfile($this->profile);
|
|
if ($save) {
|
|
if ($save) {
|
|
self::save_tag("profile");
|
|
self::save_tag("profile");
|
|
@@ -487,7 +310,7 @@ class Data_UserGame extends HashSaver {
|
|
* @param bool $save 是否需要回存
|
|
* @param bool $save 是否需要回存
|
|
* @return Info_College
|
|
* @return Info_College
|
|
*/
|
|
*/
|
|
- public function college($save = false) {
|
|
|
|
|
|
+ public function college($save = true) {
|
|
$this->college = new Info_College($this->college);
|
|
$this->college = new Info_College($this->college);
|
|
if ($save) {
|
|
if ($save) {
|
|
self::save_tag("college");
|
|
self::save_tag("college");
|
|
@@ -500,7 +323,7 @@ class Data_UserGame extends HashSaver {
|
|
* @param bool $save 是否需要回存
|
|
* @param bool $save 是否需要回存
|
|
* @return Info_NewbieGuide
|
|
* @return Info_NewbieGuide
|
|
*/
|
|
*/
|
|
- public function newbieGuide($save = false) {
|
|
|
|
|
|
+ public function newbieGuide($save = true) {
|
|
$this->NewbieGuide = new Info_NewbieGuide($this->NewbieGuide);
|
|
$this->NewbieGuide = new Info_NewbieGuide($this->NewbieGuide);
|
|
if ($save) {
|
|
if ($save) {
|
|
self::save_tag("NewbieGuide");
|
|
self::save_tag("NewbieGuide");
|
|
@@ -513,7 +336,7 @@ class Data_UserGame extends HashSaver {
|
|
* @param bool $save 是否需要回存
|
|
* @param bool $save 是否需要回存
|
|
* @return Info_NewbieGuide
|
|
* @return Info_NewbieGuide
|
|
*/
|
|
*/
|
|
- public function &teamConfig($save = false) {
|
|
|
|
|
|
+ public function &teamConfig($save = true) {
|
|
// $this->NewbieGuide = new Info_NewbieGuide($this->NewbieGuide);
|
|
// $this->NewbieGuide = new Info_NewbieGuide($this->NewbieGuide);
|
|
if ($save) {
|
|
if ($save) {
|
|
self::save_tag("heroTeamConfig");
|
|
self::save_tag("heroTeamConfig");
|