Ver código fonte

体力系统

王刚 1 ano atrás
pai
commit
8ff75d2501

Diferenças do arquivo suprimidas por serem muito extensas
+ 311 - 0
DevOps/flscfg/sqlback/jzhj2023_cfg20230907142240.sql


Diferenças do arquivo suprimidas por serem muito extensas
+ 311 - 0
DevOps/flscfg/sqlback/jzhj2023_cfg20230907142936.sql


Diferenças do arquivo suprimidas por serem muito extensas
+ 311 - 0
DevOps/flscfg/sqlback/jzhj2023_cfg20230907142944.sql


+ 1 - 1
Gameserver/App/Services/AppServer.php

@@ -62,7 +62,7 @@ class AppServer {
      * @param Resp $resp
      */
     private static function AfterProc(&$resp) {
-        if (req()->userInfoChanged) {                                           # 回写玩家数据
+        if (req()->userInfoChanged || (null != ctx() && ctx()->NeedSave())) {   # 回写玩家数据
             if (!UserProc::setUserInfo(ctx())) {                                # 失败, 改写返回值
                 return false;
             }

+ 6 - 1
Gameserver/App/base/CmdCode.php

@@ -188,12 +188,17 @@ class CmdCode {
      *
      */
     const cmd_fight_plotSav = 6806;
-    
+
     /**
      * 巡逻
      */
     const cmd_fight_xunluoPrizeReceived = 6807;
 
+    /**
+     * 开始挑战
+     */
+    const fight_startFight = 6808;
+
     // </editor-fold>
     // <editor-fold defaultstate="collapsed" desc="    反射方法    ">
 

+ 11 - 4
Gameserver/App/base/HashSaver.php

@@ -5,21 +5,28 @@ namespace loyalsoft;
 /**
  * 对象字段将以hash表结构存入Redis中.
  * 以达到拆分读写各个子节点的目标, 最终能够节省(带宽、内存、运算)消耗,提升性能.
- * @author gwang 
+ * @author gwang
  * @version
  *           1.0.1 增加了一个stVer 记录存储次数. --gwang 2022.2.22
  *           1.0.0 创建. 2年以前就跟高健讨论过的理念,我一直没有落到实处(高健已经使用了). --gwang 2020.4.24
  */
 class HashSaver extends Object_ext {
 
-    private static $save_tag = array();
+    private $save_tag = array();
 
     /**
      * 添加回存记录
      * @param type $name
      */
-    protected static function save_tag($name) {
-        self::$save_tag[] = $name;
+    protected function save_tag($name) {
+        $this->save_tag[] = $name;
+    }
+
+    /**
+     * @return bool 是否需要回存
+     */
+    public function NeedSave(): bool {
+        return count($this->save_tag) > 0;
     }
 
     /**

+ 1 - 1
Gameserver/App/model/Const/GameConfig.php

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2023-09-07 12:00:20
+ // 日期: 2023-09-07 14:29:41
 ////////////////////
 
 /**

+ 1 - 1
Gameserver/App/model/Const/globalsettings.php

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2023-09-01 10:34:51
+ // 日期: 2023-09-07 12:04:51
 ////////////////////
 
 

+ 6 - 1
Gameserver/App/model/Const/sm_gate.php

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2023-09-06 16:21:17
+ // 日期: 2023-09-07 14:33:22
 ////////////////////
 
 
@@ -28,6 +28,11 @@ class sm_gate
     */
     public $gateName;
 
+    /**
+    * @var Int32 扣除体力 default(5) 
+    */
+    public $cost_tili;
+
     /**
     * @var String 章节描述文字  
     */

+ 14 - 14
Gameserver/App/model/User/Data_UserGame.php

@@ -94,7 +94,7 @@ class Data_UserGame extends HashSaver {
     public function gates($save = true) {
         $this->gates = new Info_Gates($this->gates);
         if ($save) {
-            self::save_tag("gates");
+            $this->save_tag("gates");
         }
         return $this->gates;
     }
@@ -107,7 +107,7 @@ class Data_UserGame extends HashSaver {
     public function base($save = true) {
         $this->baseInfo = new Info_UserBase($this->baseInfo);
         if ($save) {
-            self::save_tag("baseInfo");
+            $this->save_tag("baseInfo");
         }
         return $this->baseInfo;
     }
@@ -120,7 +120,7 @@ class Data_UserGame extends HashSaver {
     public function store($save = true) {
         $this->store = new Info_Store($this->store);
         if ($save) {
-            self::save_tag("store");
+            $this->save_tag("store");
         }
         return $this->store;
     }
@@ -133,7 +133,7 @@ class Data_UserGame extends HashSaver {
     public function shop($save = true) {
         $this->shopdata = new Info_UserShop($this->shopdata);
         if ($save) {
-            self::save_tag("shopdata");
+            $this->save_tag("shopdata");
         }
         return $this->shopdata;
     }
@@ -146,7 +146,7 @@ class Data_UserGame extends HashSaver {
     public function secretshop($save = true) {
         $this->userSecretshop = new Info_UserSecretshop($this->userSecretshop);
         if ($save) {
-            self::save_tag("userSecretshop");
+            $this->save_tag("userSecretshop");
         }
         return $this->userSecretshop;
     }
@@ -159,7 +159,7 @@ class Data_UserGame extends HashSaver {
     public function heros($save = true) {
         $this->heros = new Info_Heros($this->heros);
         if ($save) {
-            self::save_tag("heros");
+            $this->save_tag("heros");
         }
         return $this->heros;
     }
@@ -172,7 +172,7 @@ class Data_UserGame extends HashSaver {
     public function privateData($save = true) {
         $this->privateState = new Info_PrivateState($this->privateState);
         if ($save) {
-            self::save_tag("privateState");
+            $this->save_tag("privateState");
         }
         return $this->privateState;
     }
@@ -185,7 +185,7 @@ class Data_UserGame extends HashSaver {
     public function newMap($save = true) {
         $this->newMap = new Info_NewMap($this->newMap);
         if ($save) {
-            self::save_tag(__FUNCTION__);
+            $this->save_tag(__FUNCTION__);
         }
         return $this->newMap;
     }
@@ -198,7 +198,7 @@ class Data_UserGame extends HashSaver {
     public function taskCardShop($save = true) {
         $this->taskCardShop = new Info_TaskCard_Shop($this->taskCardShop);
         if ($save) {
-            self::save_tag("taskCardShop");
+            $this->save_tag("taskCardShop");
         }
         return $this->taskCardShop;
     }
@@ -211,7 +211,7 @@ class Data_UserGame extends HashSaver {
     public function pvp($save = true) {
         $this->pvp = new Info_UserPVP($this->pvp);
         if ($save) {
-            self::save_tag("pvp");
+            $this->save_tag("pvp");
         }
         return $this->pvp;
     }
@@ -224,7 +224,7 @@ class Data_UserGame extends HashSaver {
     public function profile($save = true) {
         $this->profile = new Data_UserProfile($this->profile);
         if ($save) {
-            self::save_tag("profile");
+            $this->save_tag("profile");
         }
         return $this->profile;
     }
@@ -237,7 +237,7 @@ class Data_UserGame extends HashSaver {
     public function college($save = true) {
         $this->college = new Info_College($this->college);
         if ($save) {
-            self::save_tag("college");
+            $this->save_tag("college");
         }
         return $this->college;
     }
@@ -250,7 +250,7 @@ class Data_UserGame extends HashSaver {
     public function newbieGuide($save = true) {
         $this->NewbieGuide = new Info_NewbieGuide($this->NewbieGuide);
         if ($save) {
-            self::save_tag("NewbieGuide");
+            $this->save_tag("NewbieGuide");
         }
         return $this->NewbieGuide;
     }
@@ -263,7 +263,7 @@ class Data_UserGame extends HashSaver {
     public function &teamConfig($save = true) {
 //        $this->NewbieGuide = new Info_NewbieGuide($this->NewbieGuide);
         if ($save) {
-            self::save_tag("heroTeamConfig");
+            $this->save_tag("heroTeamConfig");
         }
         return $this->heroTeamConfig;
     }

+ 30 - 4
Gameserver/App/model/User/Info_UserBase.php

@@ -63,7 +63,7 @@ class Info_UserBase extends Object_ext {
     public $cash;
 
     /**
-     * 体力值
+     * 额外体力值
      * @var int
      */
     public $tili = 120;
@@ -126,7 +126,13 @@ class Info_UserBase extends Object_ext {
     function Add_tili($amt) {
         my_Assert($amt >= 0, "体力amt小于0");
         //ActiveProc::ChangeTili($amt);
-        $this->tili += $amt;
+        for ($i = 0; $i < $amt; $i++) {
+            if ((now() - $this->tili_ts) / glc()->tili_RecoverTS < glc()->tili_RecoverrMax) {
+                $this->tili_ts -= glc()->tili_RecoverTS;
+            } else {
+                $this->tili++;
+            }
+        }
     }
 
     /**
@@ -136,14 +142,34 @@ class Info_UserBase extends Object_ext {
      */
     function Consume_tili($amt) {
         if ($amt >= 0) {
-            if ($this->tili - $amt >= 0) {
-                $this->tili -= $amt;
+            $cpt = glc()->tili_RecoverTS;
+            if ($this->tili > 0) {
+                if ($this->tili - $amt >= 0) {
+                    $this->tili -= $amt;
+                    return true;
+                } else {
+                    $amt -= $this->tili;
+                    $this->tili = 0;
+                    $this->tili_ts += $amt * $cpt;
+                    return true;
+                }
+            } else if ($this->tili_ts + $amt * $cpt < now()) {
+                $this->tili_ts += $amt * $cpt;
                 return true;
             }
         }
         return false;
     }
 
+    /**
+     * @return int 计算当前可用体力值
+     */
+    function CurTili() {
+        $rec = (now() - $this->tili_ts) / glc()->tili_RecoverTS;
+        $t = $this->tili + $rec;
+        return $t;
+    }
+
     /**
      * 用户获得金币
      * @param int $amt

+ 27 - 172
Gameserver/App/process/FightProc.php

@@ -36,192 +36,51 @@ class FightProc {
                 return FightProc::PlotSav();
             case CmdCode::cmd_fight_xunluoPrizeReceived:                        #6807 巡逻奖励领取
                 return FightProc::XunluoPrizeReceived();
+            case CmdCode::fight_startFight:                                     # 6808 开始挑战
+                return self::StartFight();
             default:
                 Err(ErrCode::cmd_err);
         }
     }
-    
+
+    /**
+     * 6808 开始挑战 (扣除体力)
+     */
+    private static function StartFight() {
+        list($gateId) = req()->paras;
+        my_Assert($gateId > 0, ErrCode::paras_err);
+        $mo = GameConfig::gate_getItem($gateId);
+        my_Assert(null != $mo, ErrCode::err_const_no);
+        my_Assert(ctx()->base()->Consume_tili($mo->cost_tili), ErrCode::notenough_tili);
+        return Resp::ok(array("tili" => ctx()->baseInfo->tili, "tili_ts" => ctx()->baseInfo->tili_ts));
+    }
+
     /**
      * 6807 巡逻奖励领取
      * @return type
      */
     public static function XunluoPrizeReceived() {
         list($type) = req()->paras;
-            
+
         $gateId = ctx()->gates->UnlockedGatesMaxId;
         $gateMo = GameConfig::gate_getItem($gateId);
-        my_Assert($gateMo!=null, ErrCode::err_const_no);
-                      
-        if($type == 1){//巡逻                  
-            $curTs = now();
-            $startTs = ctx()->gates->xunluo_StartTs;
-            $ts = $curTs - $startTs;
-            $ts2 = intval($ts/60);//总的分钟数 
-
-            $fenzhong = intval($ts2/10);//有几个10分钟
-            $gold = 0;
-            $exp = 0;
-            $price = "";
-            if ($fenzhong > 0)
-            {
-                $gold = intval($gateMo->gold_xunluo / 6 * $fenzhong);
-                $exp = intval($gateMo->exp_xunluo / 6 * $fenzhong);    
-                $price = "1,".$gold.';'."4,".$exp;
-            }            
-            
-            $itemStr = explode(';', $gateMo->xunluo_item_ts);                     
-            $itemId = 0;
-            $itemNum = 0;
-             
-            $tempTs = 0;
-            foreach ($itemStr as $s) {
-                $arr = explode('-', $s);
-                $tsItemArr = explode(',', $arr[0]);
-                $sTs = $tsItemArr[0];//开始时间
-                $eTs = $tsItemArr[1]; //终止时间
-                $produceTs = $tsItemArr[2];//间隔
-                while (true)
-                {                       
-                        $tempTs += $produceTs;
-                        if ($tempTs <= $eTs && $tempTs <= $ts2)
-                        {
-                            $sList = explode(',', $arr[1]);
-                            $itemId = $sList[0];
-                            $itemNum += $sList[1];
-                        }
-
-                        if ($tempTs >= $ts2)
-                        {
-                            break;
-                        }
-
-                        if ($tempTs >= $eTs)
-                        {
-                            $tempTs = $eTs;
-                            break;
-                        }
-                }
-                
-                if ($tempTs >= $ts2)
-                {
-                    break;
-                }                
-            }
-            if($itemNum > 0){
-                $price = $price.";".$itemId.','.$itemNum;
-            }
-            
-            //---------------------------
-            $tuzhiStr = explode(';',$gateMo->xunluo_tuzhi_ts);                                          
-            $tuzhiId = 0;
-            $tuzhiNum = 0;
-
-            $tempTs2 = 0;
-            foreach ($tuzhiStr as $s)
-            {
-                $arr = explode('-', $s);
-                $tsItemArr = explode(',', $arr[0]);
-                $sTs = $tsItemArr[0];//开始时间
-                $eTs = $tsItemArr[1]; //终止时间
-                $produceTs = $tsItemArr[2];//间隔
-
-                    while (true)
-                    {
-                        $tempTs2 += $produceTs;
-                        if ($tempTs2 <= $eTs && $tempTs2 <= $ts2)
-                        {
-                            $sList = explode(',', $arr[1]);
-                            $tuzhiId = $sList[0];
-                            $tuzhiNum += $sList[1];
-                        }
-
-                        if ($tempTs2 >= $ts2)
-                        {
-                            break;
-                        }
-
-                        if ($tempTs2 >= $eTs)
-                        {
-                            $tempTs2 = $eTs;
-                            break;
-                        }
-                    }
-
-                    if ($tempTs2 >= $ts2)
-                    {
-                        break;
-                    }
-            }
-            if($tuzhiNum > 0){
-                $price = $price.";".$tuzhiId.','.$tuzhiNum;   
-            }
-            
-            //---------------------
-            $equipStr = explode(';', $gateMo->xunluo_equip_ts);                                     
-            $equipId = 0;
-            $equipNum = 0;
-
-            $tempTs3 = 0;
-                foreach ($equipStr as $s)
-                {
-                    $arr = explode('-', $s);
-                    $tsItemArr = explode(',', $arr[0]);
-                    $sTs = $tsItemArr[0];//开始时间
-                    $eTs = $tsItemArr[1]; //终止时间
-                    $produceTs = $tsItemArr[2];//间隔
-
-                    while (true)
-                    {
-                        $tempTs3 += $produceTs;
-                        if ($tempTs3 <= $eTs && $tempTs3 <= $ts2)
-                        {
-                            $sList = explode(',', $arr[1]);
-                            $equipId = $sList[0];
-                            $equipNum += $sList[1];
-                        }
-
-                        if ($tempTs3 >= $ts2)
-                        {
-                            break;
-                        }
-
-                        if ($tempTs3 >= $eTs)
-                        {
-                            $tempTs3 = $eTs;
-                            break;
-                        }
-                    }
-
-                    if ($tempTs3 >= $ts2)
-                    {
-                        break;
-                    }
-                }
-            if($equipNum > 0){
-                $price = $price.";".$equipId.','.$equipNum;
-            } 
-            StoreProc::AddMultiItemInStore($price);
+        my_Assert($gateMo != null, ErrCode::err_const_no);
+
+        if ($type == 1) {//巡逻
             ctx()->gates->xunluo_StartTs = now();
-            
-        } else {//快速巡逻            
-            my_Assert(ctx()->gates->xunluo_quick_buyRecord < $gateMo->xueluo_quick_num, ErrCode::err_const_no);
+        } else {//快速巡逻
             ctx()->gates->xunluo_quick_buyRecord += 1;
-            ctx()->baseInfo->Consume_tili(15);        
-            StoreProc::AddMultiItemInStore($gateMo->xueluo_quick_reward);
-        }    
-        
+            ctx()->baseInfo->Consume_tili(15);
+        }
+
         UserProc::updateUserInfo();
-        $ret = array(                   
-            'gates' => ctx()->gates,        
-            );
+        $ret = array(
+            'ok' => 1,
+        );
         return Resp::ok($ret);
     }
-    
-    public static function FightDailyClear() {
-        ctx()->gates->xunluo_quick_buyRecord = 0;
-    }
 
-        /**
+    /**
      * 剧情回存
      * @return type
      */
@@ -308,7 +167,6 @@ class FightProc {
         return Resp::ok($ret);
     }
 
-    
     /**
      * 关卡选择
      * @return type
@@ -369,10 +227,8 @@ class FightProc {
             'store' => ctx()->store,
         );
         return Resp::ok($ret);
-        
     }
 
-    
     /**
      * 章节宝箱的领取
      * @return type
@@ -430,5 +286,4 @@ class FightProc {
         );
         return Resp::ok($ret);
     }
-    
 }

Alguns arquivos não foram mostrados porque muitos arquivos mudaram nesse diff