Browse Source

扣除体力接口.

王刚 1 year ago
parent
commit
21dc96b75e

+ 3 - 3
Gameserver/App/base/CmdCode.php

@@ -88,7 +88,7 @@ class CmdCode {
     const cmd_user_gameconstinfo = 6002;
 
     /**
-     *
+     *  走完片头后给值 1
      */
     const cmd_user_setAnimation = 6004;
     // </editor-fold>
@@ -183,9 +183,9 @@ class CmdCode {
      * 进化解锁
      */
     const cmd_fight_evolveUnlock = 6805;
-    
+
     /**
-     * 
+     *
      */
     const cmd_fight_plotSav = 6806;
     

+ 25 - 14
Gameserver/App/model/User/Info_UserBase.php

@@ -78,19 +78,19 @@ class Info_UserBase extends Object_ext {
      * @var type
      */
     public $maxXp = 0;
-    
+
     /**
      * @var int 历史充值总金额(单位:分)
      */
     public $charge_amt = 0;
-    
+
     /**
      * 新解锁的头像框
      * @var type
      */
     #[ArrayType]
     public $headImgFrameList = array();
-    
+
     /**
      * 片头动画
      * @var type
@@ -99,14 +99,14 @@ class Info_UserBase extends Object_ext {
 
     public function initialize() {
 //        my_Assert(GameConfig::primordial_data(), "找不到账号初始化数据");         # 防御
-       $this->gold = 1000000;
+        $this->gold = 1000000;
         $this->cash = 5000;
 //        $this->xp = GameConfig::primordial_data()->User_XP;
 //        $this->tili = GameConfig::globalsettings()->TiliMaxVal;                 # 最大体力
 //        $this->maxXp = 0;
         $this->level = 1;
         $this->name = '';
-      
+
         $this->headImg = "";
         $this->img = "";
     }
@@ -121,13 +121,24 @@ class Info_UserBase extends Object_ext {
     function Add_tili($amt) {
         my_Assert($amt >= 0, "体力amt小于0");
         //ActiveProc::ChangeTili($amt);
+        $this->tili += $amt;
     }
-    
+
+    /**
+     * 扣除玩家体力
+     * @param int $amt
+     * @return bool 成功与否
+     */
     function Consume_tili($amt) {
-        my_Assert($amt >= 0, "体力amt小于0");
-        //ActiveProc::ChangeTili($amt);
+        if ($amt >= 0) {
+            if ($this->tili - $amt >= 0) {
+                $this->tili -= $amt;
+                return true;
+            }
+        }
+        return false;
     }
-    
+
     /**
      * 用户获得金币
      * @param int $amt
@@ -145,7 +156,7 @@ class Info_UserBase extends Object_ext {
      */
     function Consume_Gold($amt) {
         if ($amt > 0) {
-            if ($this->gold - $amt >= 0) {               
+            if ($this->gold - $amt >= 0) {
                 $this->gold -= $amt;
                 return true;
             }
@@ -170,13 +181,13 @@ class Info_UserBase extends Object_ext {
      */
     function Consume_Cash($amt) {
         if ($amt >= 0) {
-            if ($this->cash - $amt >= 0) {             
+            if ($this->cash - $amt >= 0) {
                 $this->cash -= $amt;
                 return true;
             }
         }
         return false;
-    }   
+    }
 
     /**
      * 用户获得经验值
@@ -185,7 +196,7 @@ class Info_UserBase extends Object_ext {
     function Add_Exp($amt) {
 //        my_Assert($amt >= 0, "amt值为负");
 //        $cfgLVs = GameConfig::playerlevel();
-//     
+//
 //        $this->xp += $amt;
 //        $initLevel = $curLevel = $this->level;
 //        $nextLevel = $curLevel + 1;
@@ -204,7 +215,7 @@ class Info_UserBase extends Object_ext {
 //            }
 //        }
 //        if ($this->level != $initLevel) {                                       # 插入玩家升级的系统消息
-//           
+//
 //        }
     }
 

+ 11 - 11
Gameserver/App/process/FightProc.php

@@ -28,9 +28,9 @@ class FightProc {
                 return FightProc::PassGateTsPrizeReceive();
             case CmdCode::cmd_fight_selectGate:                                 # 6803 关卡选择
                 return FightProc::SelectGate();
-            case CmdCode::cmd_fight_gateChallengePriceReviced:                  # 6804
+            case CmdCode::cmd_fight_gateChallengePriceReviced:                  # 6804 挑战奖励
                 return FightProc::GateChallengePriceReviced();
-            case CmdCode::cmd_fight_evolveUnlock:                               # 6805进化解锁
+            case CmdCode::cmd_fight_evolveUnlock:                               # 6805 进化解锁
                 return FightProc::EvolveUnlock();
             case CmdCode::cmd_fight_plotSav:                                    # 6806 剧情回存
                 return FightProc::PlotSav();
@@ -74,19 +74,19 @@ class FightProc {
      */
     public static function PlotSav() {
         list($gateId) = req()->paras;
-               
-        my_Assert(StlUtil::dictHasProperty(ctx()->gates->GateList,$gateId), ErrCode::err_const_no);
+
+        my_Assert(StlUtil::dictHasProperty(ctx()->gates->GateList, $gateId), ErrCode::err_const_no);
         ctx()->gates->GateList->$gateId->plotStart = 1;
-                           
+
         UserProc::updateUserInfo();
-        $ret = array(                   
-            'ok' => 1,        
-            );
+        $ret = array(
+            'ok' => 1,
+        );
         return Resp::ok($ret);
     }
-    
+
     /**
-     * EvolveUnlock
+     * 6805 进化解锁
      * @return type
      */
     public static function EvolveUnlock() {
@@ -121,7 +121,7 @@ class FightProc {
     }
 
     /**
-     * 挑战奖励领取
+     * 6804 挑战奖励领取
      * @return type
      */
     public static function GateChallengePriceReviced() {

+ 90 - 108
Gameserver/App/process/StoreProc.php

@@ -14,6 +14,7 @@ namespace loyalsoft;
  * @author c'y'zhao
  */
 class StoreProc {
+
     /**
      * 逻辑分发
      * 所有的Proc中必须有这样一个方法
@@ -22,44 +23,41 @@ class StoreProc {
     public static function procMain($req) {
         switch ($req->cmd) {
             case CmdCode::cmd_store_put:                                        # 6401 放入仓库
-                return StoreProc::AddItemInStore();  
-            case CmdCode::cmd_store_equip:                                      # 6402
-                return StoreProc::equip();    
-            case CmdCode::cmd_store_RemoveEquip:                                #6403卸下装备
-                return StoreProc::RemoveEquip();                                
-            case CmdCode::cmd_store_equipUpgrade:                               # 6403
-                return StoreProc::equipUpgrade();  
-            case CmdCode::cmd_store_equipUpgrade_MaxLv:                         # 6404
-                return StoreProc::equipUpgrade_MaxLv();    
-            case CmdCode::cmd_store_equipCompose:                               # 6404
-                return StoreProc::equipCompose();     
-                
+                return StoreProc::AddItemInStore();
+            case CmdCode::cmd_store_equip:                                      # 6402 装备
+                return StoreProc::equip();
+            case CmdCode::cmd_store_RemoveEquip:                                # 6403 卸下装备
+                return StoreProc::RemoveEquip();
+            case CmdCode::cmd_store_equipUpgrade:                               # 6404 装备升级
+                return StoreProc::equipUpgrade();
+            case CmdCode::cmd_store_equipUpgrade_MaxLv:                         # 6405 一键升级(装备)
+                return StoreProc::equipUpgrade_MaxLv();
+            case CmdCode::cmd_store_equipCompose:                               # 6406 装备合成(升阶/进化)
+                return StoreProc::equipCompose();
             default:
                 Err(ErrCode::cmd_err);
         }
     }
-    
+
     /**
-     * 合成
+     * 6406 合成
      * @return type
      */
     public static function equipCompose() {
         list($uid) = req()->paras;
         $user = ctx();
 
-        //my_Assert(StlUtil::dictHasProperty($user->store->equip, $uid), ErrCode::user_store_NoEquip);                  
-        
-        
-        
-                      
+        //my_Assert(StlUtil::dictHasProperty($user->store->equip, $uid), ErrCode::user_store_NoEquip);
+
+
+
+
         UserProc::updateUserInfo();
-        return Resp::ok(array(                   
-                    'heros' => $user->heros,                   
+        return Resp::ok(array(
+                    'heros' => $user->heros,
                     'store' => $user->store,));
-        
     }
-    
-    
+
     /**
      * 装备
      * @return type
@@ -68,52 +66,49 @@ class StoreProc {
         list($uid) = req()->paras;
         $user = ctx();
 
-        my_Assert(StlUtil::dictHasProperty($user->store->equip, $uid), ErrCode::user_store_NoEquip);                  
-               
+        my_Assert(StlUtil::dictHasProperty($user->store->equip, $uid), ErrCode::user_store_NoEquip);
+
         $mo = GameConfig::equip_getItem($user->store->equip->$uid->typeId);
         my_Assert($mo != null, ErrCode::err_const_no);
         $posId = $mo->position;
-        
+
         $heroId = $user->heros->CurrentHeroId;
-        
-        $user->store->equip->$uid->posId = $posId;             
-        if($user->heros->Dic->$heroId->equipPosition->$posId > 0){
+
+        $user->store->equip->$uid->posId = $posId;
+        if ($user->heros->Dic->$heroId->equipPosition->$posId > 0) {
             $oldUid = $user->heros->Dic->$heroId->equipPosition->$posId;
-            $user->store->equip->$oldUid->posId = 0;            
+            $user->store->equip->$oldUid->posId = 0;
         }
-        
+
         $user->heros->Dic->$heroId->equipPosition->$posId = $uid;
-                      
+
         UserProc::updateUserInfo();
-        return Resp::ok(array(                   
-                    'heros' => $user->heros,                   
+        return Resp::ok(array(
+                    'heros' => $user->heros,
                     'store' => $user->store,));
-        
     }
-    
+
     /**
      * 卸下装备
      * @return type
      */
     public static function RemoveEquip() {
-        list($posId) = req()->paras; 
+        list($posId) = req()->paras;
         $user = ctx();
 
         $heroId = $user->heros->CurrentHeroId;
-        if($user->heros->Dic->$heroId->equipPosition->$posId > 0){
+        if ($user->heros->Dic->$heroId->equipPosition->$posId > 0) {
             $oldUid = $user->heros->Dic->$heroId->equipPosition->$posId;
-            $user->store->equip->$oldUid->posId = 0;      
+            $user->store->equip->$oldUid->posId = 0;
             $user->heros->Dic->$heroId->equipPosition->$posId = 0;
         }
-              
+
         UserProc::updateUserInfo();
         return Resp::ok(array(
-                    'heros' => $user->heros,                   
+                    'heros' => $user->heros,
                     'store' => $user->store,));
-        
     }
-    
-    
+
     /**
      * 升级装备
      * @return type
@@ -122,78 +117,74 @@ class StoreProc {
         list($uid) = req()->paras; //mask = 1:表示战斗中掉落
         $user = ctx();
 
-        $lv = $user->store->equip->$uid->level;            
-        $Mo = GameConfig::equip_levelupgrade_getItem($lv+1);         
-        my_Assert($user->baseInfo->gold >= $Mo->needGold, ErrCode::notenough_gold_msg);                  
-                 
-        $position = GameConfig::equip_getItem($user->store->equip->$uid->typeId)->position;//图纸
+        $lv = $user->store->equip->$uid->level;
+        $Mo = GameConfig::equip_levelupgrade_getItem($lv + 1);
+        my_Assert($user->baseInfo->gold >= $Mo->needGold, ErrCode::notenough_gold_msg);
+
+        $position = GameConfig::equip_getItem($user->store->equip->$uid->typeId)->position; //图纸
         $typeId = 0;
         $strArr = explode(';', GameConfig::globalsettings()->equipLeveUpTuzhi);
         foreach ($strArr as $str) {
             $list = explode(',', $str);
-            if($list[0] == $position){
+            if ($list[0] == $position) {
                 $typeId = $list[1];
                 break;
             }
-        }              
+        }
         $num = $Mo->needItemNum;
-        if (StlUtil::dictHasProperty($user->store->items,$typeId) && $user->store->items->$typeId >= $num)
-        {
+        if (StlUtil::dictHasProperty($user->store->items, $typeId) && $user->store->items->$typeId >= $num) {
             $user->store->removeItem($typeId, $num);
-        }                  
+        }
+
+        $user->store->equip->$uid->level += 1;
 
-        $user->store->equip->$uid->level += 1;       
-        
         ctx($user);
         UserProc::updateUserInfo();
         return Resp::ok(array(
-                    'gold' => $user->baseInfo->gold,                         
+                    'gold' => $user->baseInfo->gold,
                     'store' => $user->store));
-        
     }
+
     /**
      * 装备一键升级
      * @return type
      */
     public static function equipUpgrade_MaxLv() {
         list($uid) = req()->paras; //mask = 1:表示战斗中掉落
-        $user = ctx();     
-       
+        $user = ctx();
+
         $equip = $user->store->equip->$uid;
 
         $lv = $equip->level;
         $maxLv = GameConfig::equip_getItem($equip->typeId)->maxLv;
-                 
+
         $need_gold = 0;
         $need_item = 0;
 
         $itemNum = 0;
-        $position = GameConfig::equip_getItem($equip->typeId)->position;       
+        $position = GameConfig::equip_getItem($equip->typeId)->position;
         $tuzhiId = 0;
         $strArr = explode(';', GameConfig::globalsettings()->equipLeveUpTuzhi);
         foreach ($strArr as $str) {
             $list = explode(',', $str);
-            if($list[0] == $position){
+            if ($list[0] == $position) {
                 $tuzhiId = $list[1];
                 break;
             }
-        }  
-        
-        
+        }
+
+
         $needItem2 = 0;
-        if (StlUtil::dictHasProperty($user->store->items,$tuzhiId))
-        {
+        if (StlUtil::dictHasProperty($user->store->items, $tuzhiId)) {
             $itemNum = $user->store->items->$tuzhiId;
-        }                  
+        }
 
         $nGold = 0;
         $ll = 0;
-        for ($i = $lv+1; $i <= $maxLv; $i++)
-        {                      
-            $nGold += GameConfig::equip_levelupgrade_getItem($i)->needGold;                 
+        for ($i = $lv + 1; $i <= $maxLv; $i++) {
+            $nGold += GameConfig::equip_levelupgrade_getItem($i)->needGold;
             $needItem2 += GameConfig::equip_levelupgrade_getItem($i)->needItemNum;
-            if ($user->baseInfo->gold >= $nGold &&  $itemNum >= $needItem2)
-            {
+            if ($user->baseInfo->gold >= $nGold && $itemNum >= $needItem2) {
                 $need_gold = $nGold;
                 $need_item = $needItem2;
                 $ll = $i;
@@ -201,24 +192,21 @@ class StoreProc {
             }
 
             break;
-
-        }        
+        }
 
         $user->baseInfo->gold -= $need_gold;
-        $user->store->removeItem($tuzhiId, $need_item);             
+        $user->store->removeItem($tuzhiId, $need_item);
         $user->store->equip->$uid->level += $ll;
-                     
+
         ctx($user);
         UserProc::updateUserInfo();
         return Resp::ok(array(
                     'gold' => $user->baseInfo->gold,
                     //'tili' => $user->baseInfo->tili,
-                    'store' => $user->store,                   
-                    ));
-        
+                    'store' => $user->store,
+        ));
     }
-    
-    
+
     public static function AddItemInStore() {
         list($rwdStr) = req()->paras; //mask = 1:表示战斗中掉落
         $user = ctx();
@@ -226,16 +214,15 @@ class StoreProc {
         $err = self::AddMultiItemInStore($rwdStr);
 
         my_Assert(ErrCode::ok == $err, $err);
-        
+
         UserProc::updateUserInfo();
         return Resp::ok(array(
                     //'gold' => $user->baseInfo->gold,
                     //'tili' => $user->baseInfo->tili,
-                    //'cash' => $user->baseInfo->cash,                   
+                    //'cash' => $user->baseInfo->cash,
                     'store' => $user->store));
-        
     }
-    
+
     /**
      * 具体奖励存入背包
      * @param type $goodsStr
@@ -248,8 +235,8 @@ class StoreProc {
             my_Assert(count($val) > 1, "解析奖励字符串出错");
 
             list($itemId, $num) = $val;                                         # ID, 数量
-            if(GameConfig::equip_getItem($itemId) != null){
-                self::PutEquipInStore($itemId, $num);   
+            if (GameConfig::equip_getItem($itemId) != null) {
+                self::PutEquipInStore($itemId, $num);
             } else {
                 $itemMo = GameConfig::item_getItem($itemId);
                 switch ($itemMo->itemType) {
@@ -265,45 +252,40 @@ class StoreProc {
                     case 100:
                     case 101:
                     case 102:
-                        self::PutItemsInStore($itemId, $num);   
+                        self::PutItemsInStore($itemId, $num);
 
-                        break;                 
+                        break;
                     default:
 
                         break;
                 }
-                
-                
-                
             }
-            
-            
         }
     }
-    
-    public static function PutItemsInStore($itemId,$num) {
+
+    public static function PutItemsInStore($itemId, $num) {
         $items = ctx()->store->items;
-        if(StlUtil::dictHasProperty($items, $itemId)){
+        if (StlUtil::dictHasProperty($items, $itemId)) {
             $items->$itemId += $num;
         } else {
             $items->$itemId = $num;
         }
-        
+
         ctx()->store->items = $items;
     }
-    
-    public static function PutEquipInStore($equipId,$num) {
-        if($equipId == 0){
+
+    public static function PutEquipInStore($equipId, $num) {
+        if ($equipId == 0) {
             return;
         }
-        $n = count((array)ctx()->store->equip)+1;
-        
+        $n = count((array) ctx()->store->equip) + 1;
+
         for ($index = 0; $index < $num; $index++) {
             $Equip = new Ins_Equip();
             $Equip->uid = $n;
             $Equip->typeId = $equipId;
-            $Equip->qual = GameConfig::equip_getItem($equipId)->qual;           
-            ctx()->store->equip->$n = $Equip;           
+            $Equip->qual = GameConfig::equip_getItem($equipId)->qual;
+            ctx()->store->equip->$n = $Equip;
             $n += 1;
         }
     }

+ 11 - 15
Gameserver/App/process/UserProc.php

@@ -25,22 +25,25 @@ class UserProc {
             case CmdCode::cmd_user_loginuserinfo:                               # 6001 登录/新玩家直接注册并登录
                 return UserProc::loginUserInfo();
             case CmdCode::cmd_user_gameconstinfo:                               # 6002 下载游戏配置
-                return UserProc::downloadConstInfo();  
-            case CmdCode::cmd_user_setAnimation:
-                return UserProc::setAnimation();            
+                return UserProc::downloadConstInfo();
+            case CmdCode::cmd_user_setAnimation:                                # 6004 片头播放记录
+                return UserProc::setAnimation();
             default:
                 Err(ErrCode::cmd_err);
         }
     }
-    
+
+    /**
+     * 6004 设置片头播放记录
+     * @return type
+     */
     public static function setAnimation() {
         list($tag) = req()->paras;
-        
-        if (ctx()->baseInfo->animation == 0 && $tag>0)
-        {
+
+        if (ctx()->baseInfo->animation == 0 && $tag > 0) {
             ctx()->baseInfo->animation = 1;
         }
-             
+
         UserProc::updateUserInfo();
         $ret = array();
         return Resp::ok($ret);
@@ -116,13 +119,6 @@ class UserProc {
             $userZoneInfo = new Data_UserZoneInfo();
             $userZoneInfo->lastZone = $defaultZone;                             # 新用户导向默认分区
             $isNewUser = true;
-
-//            $err = self::RegisterNewUser($req);  # 新用户添加到总表中
-//            if ($err != ErrCode::succeed) {
-//                return ResponseVo::myErrResponse($req, $err);
-//            }
-# 统计模块添加记录
-//            StatProc::UserGuidStep(CommUtil::tsCurrent(), $req->zoneid, -1, 1); // 第一次进入游戏
         } else { # 转换一下格式,去掉key,只保留value的集合
 //            $userZoneInfo->playedZones = ArrayInit();
 //            array_merge($userZoneInfo->playedZones, array_values((array) $userZoneInfo->playedZones));