Browse Source

1. 添加竞技场功能模块的代码.

gwang 5 years ago
parent
commit
52124c06f7

+ 8 - 8
Gameserver/Amfphp/base/ErrCode.php

@@ -887,7 +887,7 @@ class ErrCode {
     const pvp_wrongMather = 4021;
 
     /**
-     * 竞技场 - 尚未达到免费刷新时间
+     * 竞技场 - 刷新过于频繁
      */
     const pvp_refresh_time = 4022;
 
@@ -897,9 +897,9 @@ class ErrCode {
     const pvp_tili_chargenum = 4023;
 
     /**
-     * 竞技场 - 体力未有剩余就去挑战了.
+     * 竞技场 - 挑战票不足.
      */
-    const pvp_wrongtili = 4024;
+    const pvp_no_tickets = 4024;
 
     /**
      * 竞技场 - 刷新对手花费数据对不上.
@@ -912,19 +912,19 @@ class ErrCode {
     const pvp_refresh_max = 4029;
 
     /**
-     * 竞技场 - 体力购买, 跟预期的值对不上
+     * 竞技场 - 挑战票购买, 跟预期的值对不上
      */
-    const pvp_tili_cost_ilegal = 4028;
+    const pvp_ticket_cost_ilegal = 4028;
 
     /**
-     * 竞技场 - 当日体力购买已达上限
+     * 竞技场 - 道具已售罄
      */
-    const pvp_tili_soldout = 4027;
+    const pvp_item_soldout = 4027;
 
     /**
      * 竞技场 - 活跃值不够
      */
-    const pvp_activenotenough = 4026;
+    const pvp_coinnotenough = 4026;
 
     /**
      * 剧情关卡 - 剧情关卡不能重复挑战,只能挑战一次

+ 9 - 41
Gameserver/Amfphp/configs/GameConfig.php

@@ -6,7 +6,7 @@ namespace loyalsoft;
 // 由CodeGenerator创建。
 // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
 // author: gwang 
-// 日期: 2020-04-15 16:47:51
+// 日期: 2020-05-09 14:08:57
 ////////////////////
 
 /**
@@ -438,23 +438,7 @@ class GameConfig {
     }
 
     /**
-     * pvp分段奖励
-     * @return \pvp_leaguereward
-     */
-    public static function pvp_leaguereward() {
-        static $a = null;
-        return self::initValue($a, 'pvp_leaguereward');
-    }
-
-    /**
-     * @return \sm_pvp_leaguereward pvp_leaguereward item数据 
-     */
-    public static function pvp_leaguereward_getItem($itemid) {
-        return self::get_hash_item('pvp_leaguereward', $itemid);
-    }
-
-    /**
-     * pvp 百名榜单奖励
+     * 竞技场 上榜单奖励
      * @return \pvp_rankreward
      */
     public static function pvp_rankreward() {
@@ -470,19 +454,19 @@ class GameConfig {
     }
 
     /**
-     * pvp_ 分数段
-     * @return \pvp_leaguescore
+     * 竞技 商店
+     * @return \pvp_shop
      */
-    public static function pvp_leaguescore() {
+    public static function pvp_shop() {
         static $a = null;
-        return self::initValue($a, 'pvp_leaguescore');
+        return self::initValue($a, 'pvp_shop');
     }
 
     /**
-     * @return \sm_pvp_leaguescore pvp_leaguescore item数据 
+     * @return \sm_pvp_shop pvp_shop item数据 
      */
-    public static function pvp_leaguescore_getItem($itemid) {
-        return self::get_hash_item('pvp_leaguescore', $itemid);
+    public static function pvp_shop_getItem($itemid) {
+        return self::get_hash_item('pvp_shop', $itemid);
     }
 
     /**
@@ -533,22 +517,6 @@ class GameConfig {
         return self::get_hash_item('gate_carbon_content', $itemid);
     }
 
-    /**
-     * pvp活跃奖励数据
-     * @return \pvp_activityreward
-     */
-    public static function pvp_activityreward() {
-        static $a = null;
-        return self::initValue($a, 'pvp_activityreward');
-    }
-
-    /**
-     * @return \sm_pvp_activityreward pvp_activityreward item数据 
-     */
-    public static function pvp_activityreward_getItem($itemid) {
-        return self::get_hash_item('pvp_activityreward', $itemid);
-    }
-
     /**
      * 抽奖保底数据
      * @return \choujiang_baodi

+ 211 - 313
Gameserver/Amfphp/model/Const/globalsettings.php

@@ -1,612 +1,510 @@
 <?php
 
 ////////////////////
-// 由CodeGenerator创建。
-// Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
-// author: gwang 
-// 日期: 2020-04-10 13:36:33
+ // 由CodeGenerator创建。
+ // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
+ // author: gwang 
+ // 日期: 2020-05-09 15:07:31
 ////////////////////
 
+
 /**
  * Static Model globalsettings 
  */
-class globalsettings {
+class globalsettings
+{
 
     /**
-     * @var Object demo  
-     */
+    * @var Object demo  
+    */
     public $key;
 
     /**
-     * @var Object 某战斗开启的玩家等级限制  
-     */
+    * @var Object 某战斗开启的玩家等级限制  
+    */
     public $Fight_OpenLevelLimit;
 
     /**
-     * @var Object 英雄升级_消耗卡牌的卡槽,最大数量  
-     */
+    * @var Object 英雄升级_消耗卡牌的卡槽,最大数量  
+    */
     public $Hero_Upgrade_MaxCostHeroCardNum;
 
     /**
-     * @var Object 七日大奖要求完成的任务点数  
-     */
+    * @var Object 七日大奖要求完成的任务点数  
+    */
     public $day7_dianshu;
 
     /**
-     * @var Object 七日最终奖励  
-     */
+    * @var Object 七日最终奖励  
+    */
     public $day7_reward;
 
     /**
-     * @var Object 装备经验=吞噬经验X系数+初始值  
-     */
+    * @var Object 装备经验=吞噬经验X系数+初始值  
+    */
     public $shengxing_xishu;
 
     /**
-     * @var Object 升级成为高1等级的宝石需要的数量  
-     */
+    * @var Object 升级成为高1等级的宝石需要的数量  
+    */
     public $baoshi_shengjishu;
 
     /**
-     * @var Object 游戏内玩家账号的最高等级限制  
-     */
+    * @var Object 游戏内玩家账号的最高等级限制  
+    */
     public $Game_MaxPlayerLevel;
 
     /**
-     * @var Object 战斗内攻击时间间隔(毫秒)  
-     */
+    * @var Object 战斗内攻击时间间隔(毫秒)  
+    */
     public $Fight_AttackTime;
 
     /**
-     * @var Object 英雄升级_当前卡提供的基础经验值  
-     */
+    * @var Object 英雄升级_当前卡提供的基础经验值  
+    */
     public $Hero_Upgrade_BasicEXP;
 
     /**
-     * @var Object 英雄升级_当前卡的累计经验值,折扣系数  
-     */
+    * @var Object 英雄升级_当前卡的累计经验值,折扣系数  
+    */
     public $Hero_Upgrade_EXP_XiShu;
 
     /**
-     * @var Object 英雄升级_获得经验与消耗金币之间的系数  
-     */
+    * @var Object 英雄升级_获得经验与消耗金币之间的系数  
+    */
     public $Hero_Upgrade_ExpConverGold;
 
     /**
-     * @var Object 英雄升级——英雄能达到的最大等级  
-     */
+    * @var Object 英雄升级——英雄能达到的最大等级  
+    */
     public $Hero_Upgrade_BasicMaxLevel;
 
     /**
-     * @var Object 英雄升星——最大星级  
-     */
+    * @var Object 英雄升星——最大星级  
+    */
     public $Hero_Star_MaxStarLevel;
 
     /**
-     * @var Object 英雄升星——升星消耗的道具种类 (  金元素)  
-     */
+    * @var Object 英雄升星——升星消耗的道具种类 (  金元素)  
+    */
     public $Hero_Star_CostItem_1;
 
     /**
-     * @var Object 英雄升星——升星消耗的道具种类 (  木元素)  
-     */
+    * @var Object 英雄升星——升星消耗的道具种类 (  木元素)  
+    */
     public $Hero_Star_CostItem_2;
 
     /**
-     * @var Object 英雄升星——升星消耗的道具种类 (  水元素)  
-     */
+    * @var Object 英雄升星——升星消耗的道具种类 (  水元素)  
+    */
     public $Hero_Star_CostItem_3;
 
     /**
-     * @var Object 强化5,10级时,当前属性乘以一次系数  
-     */
+    * @var Object 强化5,10级时,当前属性乘以一次系数  
+    */
     public $item_qianghua;
 
     /**
-     * @var Object 英雄升星——升星消耗的道具种类 (  火元素)  
-     */
+    * @var Object 英雄升星——升星消耗的道具种类 (  火元素)  
+    */
     public $Hero_Star_CostItem_4;
 
     /**
-     * @var Object 英雄升星——升星消耗的道具种类 (  土元素)  
-     */
+    * @var Object 英雄升星——升星消耗的道具种类 (  土元素)  
+    */
     public $Hero_Star_CostItem_5;
 
     /**
-     * @var Object 英雄装备_每个卡槽的开放要求好感度  
-     */
+    * @var Object 英雄装备_每个卡槽的开放要求好感度  
+    */
     public $Hero_Equip_SlotOpenConditions_Favor;
 
     /**
-     * @var Object 英雄分解——不同的星星数量分解转换的晶石数量  
-     */
+    * @var Object 英雄分解——不同的星星数量分解转换的晶石数量  
+    */
     public $Hero_Separate_StarConvertToSpar;
 
     /**
-     * @var Object 英雄分解—— 消耗卡牌的卡槽,最大数量  
-     */
+    * @var Object 英雄分解—— 消耗卡牌的卡槽,最大数量  
+    */
     public $Hero_Separate_MaxCostHeroCardNum;
 
     /**
-     * @var Object 英雄升星——消耗英雄的卡槽,最大数量  
-     */
+    * @var Object 英雄升星——消耗英雄的卡槽,最大数量  
+    */
     public $Hero_Star_MaxCostHeroCardNum;
 
     /**
-     * @var Object 英雄升阶——最大等阶  
-     */
+    * @var Object 英雄升阶——最大等阶  
+    */
     public $Hero_Stength_MaxStrengthLevel;
 
     /**
-     * @var Object 游戏账号内_默认,收集的英雄数量上限  
-     */
+    * @var Object 游戏账号内_默认,收集的英雄数量上限  
+    */
     public $Game_CollectHero_BasicMaxCount;
 
     /**
-     * @var Object 游戏账号内_收集的英雄数量上限_每次购买数目  
-     */
+    * @var Object 游戏账号内_收集的英雄数量上限_每次购买数目  
+    */
     public $Game_CollectHero_OneBuyLimtNum;
 
     /**
-     * @var Object 战斗_每个页面上存在的关卡的数量(删)  
-     */
+    * @var Object 战斗_每个页面上存在的关卡的数量(删)  
+    */
     public $Battle_GateNumOnePage;
-//
-//    /**
-//    * @var Object 社交好友——玩家好友数量上限  
-//    */
-//    public $User_Friends_Number_Max;
-//
-//    /**
-//    * @var Object 社交好友——向好友示好(浇水,送花等)的冷却时间(按好友分别计时), 6小时  
-//    */
-//    public $User_Friends_overtures_coding_time;
-//
-//    /**
-//    * @var Object 社交好友——和每个好友的聊天记录保留的最大条数  
-//    */
-//    public $User_Friends_MessageCount_Max;
-//
-//    /**
-//    * @var Object 社交好友——向好友示好记录的过期时间(秒), 24小时  
-//    */
-//    public $User_Friends_Gift_ExpireTs;
-//
-//    /**
-//    * @var Object 社交好友——好友请求的过期时间(秒), 24小时  
-//    */
-//    public $User_Friends_Apply_ExpireTs;
-
-    /**
-     * @var Object 默认背包最大数量  
-     */
+
+    /**
+    * @var Object 默认背包最大数量  
+    */
     public $Item_Packet_MaxNum;
 
     /**
-     * @var Object 每开10个格子需要消耗的钻石价格  
-     */
+    * @var Object 每开10个格子需要消耗的钻石价格  
+    */
     public $Item_Packet_NumCostCash;
 
     /**
-     * @var Object 英雄评论区一个赞的排行权重(秒), 3600秒
-     *  Ps. 暂行公式: score = ts + praise * weight
-     *    按照score 从大到小排序.  
-     */
+    * @var Object 英雄评论区一个赞的排行权重(秒), 3600秒
+    *  Ps. 暂行公式: score = ts + praise * weight
+    *    按照score 从大到小排序.  
+    */
     public $Hero_Discuss_Praise_weight;
 
     /**
-     * @var Object 战前消耗金币购买buff  
-     */
+    * @var Object 战前消耗金币购买buff  
+    */
     public $Battle_CostGoldBuyBuff;
 
     /**
-     * @var Object 战斗计算的 格属性比重系数(李宁)  
-     */
+    * @var Object 战斗计算的 格属性比重系数(李宁)  
+    */
     public $Battle_PowerFactor;
 
     /**
-     * @var Object 单场战斗总时间, 单位毫秒  
-     */
+    * @var Object 单场战斗总时间, 单位毫秒  
+    */
     public $Battle_BattleShowTime;
 
     /**
-     * @var Object 战斗队伍最大人数(千万别改)  
-     */
+    * @var Object 战斗队伍最大人数(千万别改)  
+    */
     public $Battle_BattleTeamMaxFighter;
 
     /**
-     * @var Object 己方释放技能恢复己方团队能量值  
-     */
+    * @var Object 己方释放技能恢复己方团队能量值  
+    */
     public $Battle_IncreasePowerByCastSkill;
 
     /**
-     * @var Object 己方连击能量值上限(数值满足时,可以进行连击)  
-     */
+    * @var Object 己方连击能量值上限(数值满足时,可以进行连击)  
+    */
     public $Battle_BlueTeamMaxPower;
 
     /**
-     * @var Object 神秘商城, 刷新时间间隔(单位: 秒)  
-     */
+    * @var Object 神秘商城, 刷新时间间隔(单位: 秒)  
+    */
     public $secretshop_refresh_interval;
 
     /**
-     * @var Object 物品栏购买栏位梯度价格  
-     */
+    * @var Object 物品栏购买栏位梯度价格  
+    */
     public $Item_Packet_MaxNumPrice;
 
     /**
-     * @var Object 游戏账号内_收集的英雄数量上限_英雄栏购买栏位梯度价格  
-     */
+    * @var Object 游戏账号内_收集的英雄数量上限_英雄栏购买栏位梯度价格  
+    */
     public $Game_CollectHero_BasicMaxPrice;
 
     /**
-     * @var Object 无穷无尽关卡——每天的挑战次数总上限  
-     */
+    * @var Object 无穷无尽关卡——每天的挑战次数总上限  
+    */
     public $Battle_Forever_MaxCountEveryDay;
 
     /**
-     * @var Object 玩家发送一条系统消息消(当前分区)耗钻石数量  
-     */
+    * @var Object 玩家发送一条系统消息消(当前分区)耗钻石数量  
+    */
     public $SystemMessage_UserSendToMyZone_Cos;
 
     /**
-     * @var Object 系统消息 - 对英雄升星进行系统广播的最低星级限制  
-     */
+    * @var Object 系统消息 - 对英雄升星进行系统广播的最低星级限制  
+    */
     public $SystemMessage_HeroStar_Limit_Min;
 
     /**
-     * @var Object 系统消息 - 对英雄升阶进行系统广播的最低等阶限制  
-     */
+    * @var Object 系统消息 - 对英雄升阶进行系统广播的最低等阶限制  
+    */
     public $SystemMessage_HeroStage_Limit_Min;
 
     /**
-     * @var Object 系统消息 - 对装备强化进行系统广播的最低等级限制  
-     */
+    * @var Object 系统消息 - 对装备强化进行系统广播的最低等级限制  
+    */
     public $SystemMessage_WeaponLevel_Limit_Min;
 
     /**
-     * @var Object 租借好友英雄,消耗的物品数量。结构为【id,num】  
-     */
-    public $User_Friends_HireFriendForBattle_Cost;
-
-    /**
-     * @var Object 新手引导中抽奖的掉落  
-     */
+    * @var Object 新手引导中抽奖的掉落  
+    */
     public $choujiang_guide_items;
 
     /**
-     * @var Object 神秘商城最单个物品大购买次数  
-     */
+    * @var Object 神秘商城最单个物品大购买次数  
+    */
     public $secretshop_itembuy_maxtimes;
 
     /**
-     * @var Object 宝箱开启里大R充值判断条件  
-     */
+    * @var Object 宝箱开启里大R充值判断条件  
+    */
     public $bigRPay_Condition;
 
     /**
-     * @var Object 宝箱开启里大R当日抽奖次数判断条件  
-     */
+    * @var Object 宝箱开启里大R当日抽奖次数判断条件  
+    */
     public $bigROpenBoxTimesDayliy_Condition;
 
     /**
-     * @var Object 租借好友英雄的佣金邮件的有效时间, 15天  
-     */
-    public $User_Friends_HireFriendForBattle_MailExpireTs;
-
-    /**
-     * @var Object 租借好友英雄的佣金邮件的文本内容  
-     */
-    public $User_Friends_HireFriendForBattle_MailContents;
-
-    /**
-     * @var Object 租借好友英雄佣金, 课税后收益, cost * (1-this) = 好友收益  
-     */
-    public $User_Friends_HireFriendForBattle_Tax;
-
-    /**
-     * @var Object 手动刷新对手花费钻石数量,(按次梯度定价),达到上限禁止继续刷新  
-     */
-    public $PVP_reFresh_Match_cost;
-
-    /**
-     * @var Object 恢复一点体力所需时间(秒)  
-     */
-    public $PVP_reCover_Tili_costSec;
-
-    /**
-     * @var Object PVP 胜利奖励积分  
-     */
-    public $PVP_PK_Win_Score;
-
-    /**
-     * @var Object 每种熔炼元素在角色身上的最大数量  
-     */
-    public $Melt_Element_MaxNum;
-
-    /**
-     * @var Object PVP 胜利奖励金币  
-     */
-    public $PVP_PK_Win_Gold;
-
-    /**
-     * @var Object PVP 胜利奖励PVP币  
-     */
-    public $PVP_PK_Win_PvpCoin;
-
-    /**
-     * @var Object 免费刷新对手所需恢复时间,单位秒  
-     */
-    public $PVP_refresh_Match_RecoverSeconds;
-
-    /**
-     * @var Object 可熔炼装备的最低需求(level:等级;xingji:星级)装备默认是1星1级  
-     */
-    public $Melt_Equip_Requst;
-
-    /**
-     * @var Object 恢复5点体力所需花费钻石数量,(按次数阶梯定价),达到上限禁止继续购买  
-     */
-    public $PVP_recover_tili_cost_cash;
-
-    /**
-     * @var Object 打车券的itemid  
-     */
-    public $choujiang_dachequan_itemid;
-
-    /**
-     * @var Object 修改昵称消耗的道具itemid,0代表不消耗  
-     */
+    * @var Object 修改昵称消耗的道具itemid,0代表不消耗  
+    */
     public $User_SetNickname_CostItemid;
 
     /**
-     * @var Object 新手引导中发放所需碎片(cardid,numb;cardid,num...)  
-     */
+    * @var Object 新手引导中发放所需碎片(cardid,numb;cardid,num...)  
+    */
     public $User_SetNewbieGuideCards;
 
     /**
-     * @var Object 系统设定: 操作日志保存天数  
-     */
+    * @var Object 系统设定: 操作日志保存天数  
+    */
     public $syscfg_oplog_keepdays;
 
     /**
-     * @var Object 装备属性升级的参数  
-     */
+    * @var Object 装备属性升级的参数  
+    */
     public $Equip_Upgrade_Property;
 
     /**
-     * @var Object 神秘商城最大刷新次数  
-     */
+    * @var Object 神秘商城最大刷新次数  
+    */
     public $secretshop_refresh_maxtimes;
 
     /**
-     * @var Object 己方连击(倒计时)时间  
-     */
+    * @var Object 己方连击(倒计时)时间  
+    */
     public $Battle_BlueCriticalTime;
 
     /**
-     * @var Object 连击伤害概率(x/100)  
-     */
+    * @var Object 连击伤害概率(x/100)  
+    */
     public $Battle_BattleLianJiDamageRate;
 
     /**
-     * @var Object PVP 奖励积分: 积分差额外奖励系数  
-     */
-    public $PVP_PK_ScoreDiff_factor;
+    * @var Object 竞技商店 - 刷新花费(钻石)  
+    */
+    public $PVP_shop_refresh_cash;
 
     /**
-     * @var Object PVP 被人挑战成功扣除积分  
-     */
-    public $PVP_PK_be_defeated_score;
+    * @var Object 竞技商店 - 免费刷新间隔  
+    */
+    public $PVP_shop_refresh_interval;
 
     /**
-     * @var Object PVP 被人挑战并战胜对手获得积分  
-     */
-    public $PVP_PK_be_undefeated_score;
-
-    /**
-     * @var Object 碎片融合时需要花费的金币  
-     */
+    * @var Object 碎片融合时需要花费的金币  
+    */
     public $Compose_Pieces_Gold;
 
     /**
-     * @var Object 首充活动礼包的商品ID  
-     */
+    * @var Object 首充活动礼包的商品ID  
+    */
     public $FirstPay_ItemId;
 
     /**
-     * @var Object 赠送体力的时间段(24小时的数字无前导0, 逗号分隔)  
-     */
+    * @var Object 赠送体力的时间段(24小时的数字无前导0, 逗号分隔)  
+    */
     public $activity_presentTili_times;
 
     /**
-     * @var Object 每次赠送体力的数量  
-     */
+    * @var Object 每次赠送体力的数量  
+    */
     public $activity_presentTili_number;
 
     /**
-     * @var Object PVP 蝉联奖励,10万钻(待运营策划填正式数据)  
-     */
-    public $PVP_Chanlian_RewardStr;
+    * @var Object 竞技场-挑战票价格(钻石)  
+    */
+    public $PVP_pk_ticket_price;
 
     /**
-     * @var Object 当前客户端版本号  
-     */
+    * @var Object 【废弃】当前客户端版本号  
+    */
     public $clientVer;
 
     /**
-     * @var Object 支付模块是否开放  
-     */
+    * @var Object 支付模块是否开放  
+    */
     public $Game_Pay_Open;
 
     /**
-     * @var Object 更新开始时间戳  
-     */
+    * @var Object 更新开始时间戳  
+    */
     public $updatingBeginTs;
 
     /**
-     * @var Object 更新结束时间戳  
-     */
+    * @var Object 更新结束时间戳  
+    */
     public $updatingEndTs;
 
     /**
-     * @var Object 开宝箱的公共冷却值(热保护值)  
-     */
+    * @var Object 开宝箱的公共冷却值(热保护值)  
+    */
     public $Box_Total_CoolDown;
 
     /**
-     * @var Object 免cd开各种宝箱所花费的钻石数。  
-     */
+    * @var Object 免cd开各种宝箱所花费的钻石数。  
+    */
     public $Box_NoCoolDown_Cash;
 
     /**
-     * @var Object 公会开启最小等级  
-     */
+    * @var Object 公会开启最小等级  
+    */
     public $Guild_Join_LeastLevel;
 
     /**
-     * @var Object 创建公会所需花费  
-     */
+    * @var Object 创建公会所需花费  
+    */
     public $Guild_Found_CostGold;
 
     /**
-     * @var Object 公会申请记录的容量限制  
-     */
+    * @var Object 公会申请记录的容量限制  
+    */
     public $Guild_ApplyCapacityLimit;
 
     /**
-     * @var Object 公会副会长最多人数  
-     */
+    * @var Object 公会副会长最多人数  
+    */
     public $Guild_ViceChairManLimit;
 
     /**
-     * @var Object 公会干部最多人数  
-     */
+    * @var Object 公会干部最多人数  
+    */
     public $Guild_OfficerManLimit;
 
     /**
-     * @var Object 公会申请被拒接后冷却时间  
-     */
+    * @var Object 公会申请被拒接后冷却时间  
+    */
     public $Guild_ApplyrefuseCoolLimit;
 
     /**
-     * @var Object 弹劾会长有效时间  
-     */
+    * @var Object 弹劾会长有效时间  
+    */
     public $Guild_AccuseChairManTimeLimit;
 
     /**
-     * @var Object 可弹劾公长所需时长  
-     */
+    * @var Object 可弹劾公长所需时长  
+    */
     public $Guild_ChairManLastLoginLimit;
 
     /**
-     * @var Object 加入公会申请反复发送的时间间隔  
-     */
+    * @var Object 加入公会申请反复发送的时间间隔  
+    */
     public $Guild_MoreApplyLimit;
 
     /**
-     * @var Object 弹劾会长失败冷却时间  
-     */
+    * @var Object 弹劾会长失败冷却时间  
+    */
     public $Guild_AccuseFailCoolingTime;
 
     /**
-     * @var Object 每次请求卡牌时间间隔  
-     */
+    * @var Object 每次请求卡牌时间间隔  
+    */
     public $Guild_RequestCardIntervalTime;
 
     /**
-     * @var Object 不同种卡牌一次可以请求的数量  
-     */
+    * @var Object 不同种卡牌一次可以请求的数量  
+    */
     public $Guild_RequsetCardNum;
 
     /**
-     * @var Object 公会每天捐献总数量最大值  
-     */
+    * @var Object 公会每天捐献总数量最大值  
+    */
     public $Guild_EveryDayDonateTotalNumMax;
 
     /**
-     * @var Object 公会捐献冷却时间  
-     */
+    * @var Object 公会捐献冷却时间  
+    */
     public $Guild_DonateCoolingTime;
 
     /**
-     * @var Object 公会等级及对应捐献度  
-     */
+    * @var Object 公会等级及对应捐献度  
+    */
     public $Guild_ContributeLevel;
 
     /**
-     * @var Object 公会不开放请求的碎片类型  
-     */
+    * @var Object 公会不开放请求的碎片类型  
+    */
     public $Guild_NotOpenChipType;
 
     /**
-     * @var Object PVP 挑战失败扣除的积分  
-     */
-    public $PVP_PK_Fail_Score;
-
-    /**
-     * @var Object 购买钻石礼包给公会成员额外奖励  
-     */
+    * @var Object 购买钻石礼包给公会成员额外奖励  
+    */
     public $Guild_BuyCashGiftExtraReward;
 
     /**
-     * @var Object 公会公告编辑冷却时间  
-     */
+    * @var Object 公会公告编辑冷却时间  
+    */
     public $Guild_AnnouncementEditCoolingTime;
 
     /**
-     * @var Object 公会公告显示时间  
-     */
+    * @var Object 公会公告显示时间  
+    */
     public $Guild_AnnouncementShowTime;
 
     /**
-     * @var Object 新手引导中发放所需经验卡(id,num;id,num...)  
-     */
+    * @var Object 新手引导中发放所需经验卡(id,num;id,num...)  
+    */
     public $User_SetNewbieGuideExps;
 
     /**
-     * @var Object 创建公会——加入公会的分数  
-     */
+    * @var Object 创建公会——加入公会的分数  
+    */
     public $Guild_Found_ScoreLimit;
 
     /**
-     * @var Object 游戏聊天功能——是否开放 1开放0 关闭  
-     */
+    * @var Object 游戏聊天功能——是否开放 1开放0 关闭  
+    */
     public $Game_ChatIsOpen;
 
     /**
-     * @var Object 游戏引导功能——是否开放 1开放0 关闭  
-     */
+    * @var Object 游戏引导功能——是否开放 1开放0 关闭  
+    */
     public $Game_Guide_IsOpen;
 
     /**
-     * @var Object 己方(释放技能)共用总能量条(按时间增长)  
-     */
+    * @var Object 己方(释放技能)共用总能量条(按时间增长)  
+    */
     public $Battle_BlueTeamMaxSkillPower;
 
     /**
-     * @var Object 敌方(释放技能)共用总能量条(按时间增长)  
-     */
+    * @var Object 敌方(释放技能)共用总能量条(按时间增长)  
+    */
     public $Battle_RedTeamMaxSkillPower;
 
     /**
-     * @var Object 系统公告图片的网址  
-     */
+    * @var Object 系统公告图片的网址  
+    */
     public $Game_PublicNotice;
 
     /**
-     * @var Object 进入战场后,角色初始能量(sp)  
-     */
+    * @var Object 进入战场后,角色初始能量(sp)  
+    */
     public $Arenas_Init_SP;
 
     /**
-     * @var Object 普通攻击(一击)命中目标并造成上海, 增加3点能量SP  
-     */
+    * @var Object 普通攻击(一击)命中目标并造成上海, 增加3点能量SP  
+    */
     public $Arenas_hit_SP;
 
     /**
-     * @var Object 触发极限闪避并进入【失控漩涡】时间, 增加2点能量SP  
-     */
+    * @var Object 触发极限闪避并进入【失控漩涡】时间, 增加2点能量SP  
+    */
     public $Arenas_jixianshanbi_SP;
 
 }
+

+ 1 - 1
Gameserver/Amfphp/model/Const/primordial_data.php

@@ -4,7 +4,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2020-02-12 08:05:24
+ // 日期: 2020-04-27 11:19:57
 ////////////////////
 
 

+ 1 - 1
Gameserver/Amfphp/model/Const/sm_gate.php

@@ -4,7 +4,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2020-02-12 08:04:46
+ // 日期: 2020-04-26 15:37:26
 ////////////////////
 
 

+ 1 - 1
Gameserver/Amfphp/model/Const/sm_gatelevel.php

@@ -4,7 +4,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2020-03-26 15:20:00
+ // 日期: 2020-04-30 13:38:13
 ////////////////////
 
 

+ 1 - 1
Gameserver/Amfphp/model/Const/sm_item_base.php

@@ -4,7 +4,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2020-02-12 08:05:13
+ // 日期: 2020-05-09 15:00:54
 ////////////////////
 
 

+ 1 - 1
Gameserver/Amfphp/model/Const/sm_item_yanling.php

@@ -4,7 +4,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2020-04-08 16:51:08
+ // 日期: 2020-04-24 18:01:06
 ////////////////////
 
 

+ 5 - 10
Gameserver/Amfphp/model/Const/sm_pvp_rankreward.php

@@ -4,7 +4,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2020-02-12 08:05:27
+ // 日期: 2020-05-09 15:02:24
 ////////////////////
 
 
@@ -35,19 +35,14 @@ class sm_pvp_rankreward
     public $maxRank;
 
     /**
-    * @var String 奖励内容1(例: 399001,450)  
+    * @var String 每日上榜_奖励内容(例: 399001,450)  
     */
-    public $reward1;
+    public $reward_day;
 
     /**
-    * @var String 奖励内容2(例: 399001,450)  
+    * @var String 赛季上榜_奖励内容(例: 399001,450)  
     */
-    public $reward2;
-
-    /**
-    * @var String 奖励内容3(例: 399001,450)  
-    */
-    public $reward3;
+    public $reward_season;
 
 }
 

+ 68 - 0
Gameserver/Amfphp/model/Const/sm_pvp_shop.php

@@ -0,0 +1,68 @@
+<?php
+
+////////////////////
+ // 由CodeGenerator创建。
+ // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
+ // author: gwang 
+ // 日期: 2020-05-11 09:04:58
+////////////////////
+
+
+/**
+ * Static Model pvp_shop 
+ */
+class sm_pvp_shop
+{
+
+    /**
+    * @var Int32 用途未知!!请到数据库中添加字段注释。  
+    */
+    public $id;
+
+    /**
+    * @var Int32 商品ID  
+    */
+    public $typeId;
+
+    /**
+    * @var String 商品名称  
+    */
+    public $name;
+
+    /**
+    * @var Int32 物品售价,  
+    */
+    public $price;
+
+    /**
+    * @var Int32 定价类型: 0.RMB(元), 1.金币(个), 2.钻石(颗), 3. 体力 4. 友情点 5. 竞技币 default(5) 
+    */
+    public $priceType;
+
+    /**
+    * @var Int32 玩家等级达到之后才能刷新出来  
+    */
+    public $unlock_level;
+
+    /**
+    * @var Int32 被刷新到的基础概率(权重)  
+    */
+    public $probability;
+
+    /**
+    * @var String 内容(itemId,num)  
+    */
+    public $goods;
+
+    /**
+    * @var DateTime 上次修改 default(CURRENT_TIMESTAMP) 
+    */
+    public $lastupdate;
+
+    /**
+    * @var Int32 售罄:0 false, 1 true, 这个策划不用改, 程序用的 default(0) 
+    */
+    public $sealed;
+
+}
+

+ 1 - 1
Gameserver/Amfphp/model/Const/sm_rankreward_passgate.php

@@ -4,7 +4,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2020-04-09 17:33:00
+ // 日期: 2020-04-27 11:41:57
 ////////////////////
 
 

+ 1 - 1
Gameserver/Amfphp/model/User/UserPVPModel.php

@@ -45,7 +45,7 @@ class UserPVPModel extends Object_ext {
     /**
      * @var int 挑战记录最后拉取时间戳(晚于此时间戳的记录为新记录,显示小红点)
      */
-    public $tsFightLog = 0;
+    public $lastCheckDefLog_ts = 0;
 
     /**
      * @var type 当前竞技商店内道具列表(子结构可以记录售罄状态)

+ 32 - 16
Gameserver/Amfphp/process/EmailProc.php

@@ -261,28 +261,44 @@ class EmailProc {
     }
 
     /**
-     * 系统邮件 - 发送pvp排行榜奖励
+     * 系统邮件 - 发送竞技场赛季排行榜奖励
      * @param type $zoneid
      * @param type $uid
      * @param type $rank
      */
-    public static function SendPvpRankReward($zoneid, $uid, $rank) {
+    public static function SendPvpRankReward_Season($zoneid, $uid, $rank) {
         foreach (GameConfig::pvp_rankreward() as $rkrwd) {
-            isEditor() and $rkrwd = new sm_pvp_rankreward;
+            isEditor() and $rkrwd = new \sm_pvp_rankreward();
             if ($rank >= $rkrwd->minRank and $rank <= $rkrwd->maxRank) {
-                for ($i = 1; $i <= 3; $i++) {
-                    $r = "reward$i";
-                    $rdstr = $rkrwd->$r;
-                    if ($rdstr != "") {
-                        $arr = explode(',', $rdstr);
-                        $itemid = $arr[0];
-                        $num = $arr[1];
-                        $mail = new EmailModel(null, enum_Mail_Type::SysTemMail, "竞技场上榜奖励-$i", #
-                                "恭喜您在上周的竞技场战斗中获得总榜" . $rkrwd->rankName . "阶段的奖励", #
-                                $itemid, $num);
-                        self::InsertMail($zoneid, $uid, $mail);
-                    }
-                }
+                $arr = explode(',', $rkrwd->reward_season);
+                $itemid = $arr[0];
+                $num = $arr[1];
+                $mail = new EmailModel(null, enum_Mail_Type::SysTemMail, "竞技场赛季上榜奖励", #
+                        "恭喜您在上赛季的竞技场战斗中获得总榜" . $rkrwd->rankName . "阶段的奖励", #
+                        $itemid, $num);
+                self::InsertMail($zoneid, $uid, $mail);
+                break;
+            }
+        }
+    }
+
+    /**
+     * 系统邮件 - 发送竞技场每日排行榜上榜奖励
+     * @param type $zoneid
+     * @param type $uid
+     * @param type $rank
+     */
+    public static function SendPvpRankReward_Lastday($zoneid, $uid, $rank) {
+        foreach (GameConfig::pvp_rankreward() as $rkrwd) {
+            isEditor() and $rkrwd = new \sm_pvp_rankreward();
+            if ($rank >= $rkrwd->minRank and $rank <= $rkrwd->maxRank) {
+                $arr = explode(',', $rkrwd->reward_day);
+                $itemid = $arr[0];
+                $num = $arr[1];
+                $mail = new EmailModel(null, enum_Mail_Type::SysTemMail, "竞技场每日上榜奖励", #
+                        "恭喜您在昨天的竞技场战斗中获得总榜" . $rkrwd->rankName . "阶段的奖励", #
+                        $itemid, $num);
+                self::InsertMail($zoneid, $uid, $mail);
                 break;
             }
         }

+ 266 - 443
Gameserver/Amfphp/process/FightProc/PVPProc.php

@@ -139,10 +139,10 @@ class PVPProc {
         UserProc::updateUserInfo();                                             # 回写数据
         // 记录拉取时间戳(在主界面有个未读消息条数显示, 需要靠最后拉取时间戳对比, 时间戳之后的消息是未读消息)
         // 回传数据记录
-        array_walk($offLog, function (&$i) {
+        array_walk($offLog, function (&$i) {                                    # 解码一下
             $i = JsonUtil::decode($i);
         });
-        array_walk($defLog, function (&$i) {
+        array_walk($defLog, function (&$i) {                                    # 解码一下
             $i = JsonUtil::decode($i);
         });
         return Resp::ok(array(
@@ -151,114 +151,65 @@ class PVPProc {
         ));
     }
 
-    // <editor-fold defaultstate="collapsed" desc="   竞技场   681x">
-    // 
-
+    // <editor-fold defaultstate="collapsed" desc="   竞技商店  ">
     /**
-     * 取当前赛季的编号(从赛季起始开始算起)
-     * @return int 
+     * 王刚 16:23:39 (2020.5.9)
+      商店现在的模式定位:
+      商店显示所有物品, 刷新时是重置购买/售罄记录
+      刘海 16:24:23 (2020.5.9)
+      没错
      */
-    public static function GetCurSeasonID() {
-        $n = ceil((now() - self::pvpStartTs ) / self::pvpSeasonLengt);          # 进一取整
-        return $n;
-    }
-
-    /**
-     * 取指定赛季的结束时间戳
-     * @param int $seasonID
-     * @return int 
-     */
-    public static function GetSeasonEndTs($seasonID) {
-        $ts = self::pvpStartTs + $seasonID * self::pvpSeasonLengt;              # 从起始点开始 + n个赛季时常
-        return $ts;
-    }
-
-    /**
-     * [6810] 竞技场 拉取主界面信息
-     * @param Req $req
-     */
-    static function pvpMainInfo($req) {
-        $uid = $req->uid;                                                       # 快速访问UID
-        $zoneid = $req->zoneid;                                                 # 快速访问zoneid
-        $pvp = new UserPVPModel($req->userInfo->game->pvp);                     # 设计玩家pvp数据结构
-        $seasonId = self::GetCurSeasonID();                                     # 当前赛季ID
-        $key = MemKey_GameRun::Game_PVPScoreByZoneSeason_zset($zoneid, $seasonId); # 积分总榜
-        // 玩家数据
-        // 积分 + 排名
-        // 总战力
-        // 战报小红点
-        // 对手列表
-        // =======
-        // 检查昨日奖励是否发放
-        // 检查赛季奖励是否发放
-        // 返回
-        $score = self::_getScore_by_uid($uid, $key);                            # 玩家积分
-        $rank = self::_getRank_by_uid($uid, $key);                              # 玩家排名
-        $fPower = HeroProc::CalcUserFightPower($zoneid, $uid, $req->userInfo->game); # 玩家总战力?还是当前防守队伍的战斗力?
-        $bHasNewLog = true; // todo: 真正查询是否有新战报
-        $matches = self::getNewMatches($pvp, gMem(), $uid, $zoneid);            # 获得新的匹配对手
-
-        if ($pvp->haventReward_season > 0 && $pvp->haventReward_season < $seasonId) { # 尚未发放上赛季奖励
-            $haventKey = MemKey_GameRun::Game_PVPScoreByZoneSeason_zset($zoneid, $pvp->haventReward_season);
-            // todo:发放上周奖励邮件
-        }
-        if ($pvp->haventReward_tsDay > 0 && $pvp->haventReward_tsDay < tsDay()) { # 尚未发放昨天奖励
-            $haventKey_day = MemKey_GameRun::Game_PVPScoreByZone_zset_Day($zoneid, $day);
-            if (gMem()->exists($haventKey_day)) {                               # 昨天的积分记录不存在
-                gMem()->zcopy($key, $haventKey_day);                            # 复制一份当前积分作为昨天的截止积分榜
-            }
-            // todo:发放昨天奖励
-        }
-        // 组装 返回值结构
-        $ret = array(
-            'score' => $score, #                                                # 自己的积分
-            'rank' => $rank, #                                                  # 自己的排名
-            'pvpCoins' => $pvp->pvpCoins, #                                     # 自己的竞技币
-            'fPower' => $fPower, #                                              # 自己的总战力
-            'fightTicket' => $pvp->fightTicket, #                               # 自己的挑战票
-            'defTeam' => $pvp->defTeam, #                                       # 自己的防守队伍
-            'bHasNewFightLog' => $bHasNewLog, #                                 # 是否有战报刷新
-            'matches' => $matches, #                                            # 对手列表
-        );
-        return Resp::ok($ret);                                                  # 返回
-    }
-
-// </editor-fold>
-// 
-// <editor-fold defaultstate="collapsed" desc="   竞技商店  ">
 
     /**
      * [6820] 竞技商店 主界面
-     * @param type $req
+     * @param req $req
      */
     public static function pvpShopMain($req) {
-        // 商品列表
-        // 检查刷新时间<now => 刷新商品列表
-        // 返回
+        $pvp = new UserPVPModel($req->userInfo->game->pvp);                     # PVP信息
+        if ($pvp->shopRefreshTs < now()) {                                      # 检查刷新时间<now => 刷新商品列表
+            $pvp->shopRefreshTs = now() + glc()->PVP_shop_refresh_interval;     # 更新刷新时间
+            $pvp->curShopItems = GameConfig::pvp_shop();                        # 重刷道具
+            $req->userInfo->game->pvp = $pvp;                                   # 回写
+            UserProc::updateUserInfo();
+        }
+        return Resp::ok($pvp);                                                  // 返回
     }
 
     /**
      * [6821] 竞技 商店 购买道具
-     * @param type $req
+     * @param req $req
      */
     public static function pvpShopBuy($req) {
-        // 查询物品配置数据
-        // 扣除竞技币
-        // 发放道具
-        // 回写数据
-        // 返回
+        $index = $req->paras[0];                                                # 参数:道具索引(typeId)
+        $pvp = new UserPVPModel($req->userInfo->game->pvp);                     # PVP 数据
+        my_Assert(CommUtil::isPropertyExists($pvp->curShopItems, $index), ErrCode::err_innerfault); # 没有找到改商品
+//        isEditor() && $citem = new \sm_pvp_shop();
+        $citem = $pvp->curShopItems->$index;                                    # 查询物品数据
+        my_Assert($citem->sealed == 0, ErrCode::pvp_item_soldout);              # 防御道具已售罄
+        my_Assert($citem->pricetype == 5, ErrCode::pay_price_err);              # 防御定价异常
+        my_Assert($pvp->pvpCoins > $citem->price, ErrCode::pvp_coinnotenough);  # pvp币不足 
+        $citem->sealed += 1;                                                    # 设置已售罄/已购买标志
+        $pvp->pvpCoins -= $citem->price;                                        # 扣除竞技币 
+        StoreProc::AddMultiItemInStore($req, $citem->goods);                    // 发放道具
+        $req->userInfo->game->pvp = $pvp;                                       // 回写数据
+        UserProc::updateUserInfo();
+        return Resp::ok();                                                      // 返回
     }
 
     /**
      * [6822] 竞技 商店 刷新道具
-     * @param type $req
+     * @param req $req
      */
     public static function pvpShopRefresh($req) {
         // 扣除刷新消耗
-        // 更新刷新时间
-        // 重刷道具
-        // 回写数据
-        // 返回
+        $pvp = new UserPVPModel($req->userInfo->game->pvp);
+        $costCash = glc()->PVP_shop_refresh_cash;
+        my_Assert(UserGameModel::Consume_Cash($req->userInfo->game, $costCash), ErrCode::notenough_cash_msg);
+        $pvp->shopRefreshTs = now() + glc()->PVP_shop_refresh_interval;         # 更新刷新时间
+        $pvp->curShopItems = GameConfig::pvp_shop();                            # 重刷道具
+        $req->userInfo->game->pvp = $pvp;                                       # 回写
+        UserProc::updateUserInfo();                                             # 回写玩家数据
+        return Resp::ok($pvp);                                                  # 返回
     }
 
     /**
@@ -334,80 +285,90 @@ class PVPProc {
 
 // // </editor-fold>
     //
-    // <editor-fold defaultstate="collapsed" desc=" 旧版PVP 681x ">
-//
+    // <editor-fold defaultstate="collapsed" desc="   竞技场   681x">
+    // 
 
     /**
-     * @deprecated since version 2020.5.8
-     * @param Req $req
-     * @param type $uid
-     * @param type $addValue Description
+     * 辅助方法:取当前赛季的编号(从赛季起始开始算起)
+     * @return int 
      */
-    private static function _addScore_by_uid($req, $uid, $addValue) {
-        if ($addValue <= 0) {                                                   # 防御
-            return;
-        }
-        $mem = $req->mem;
-        $zoneid = $req->zoneid;
-        $key = MemKey_GameRun::Game_PVPScoreByZone_zset($zoneid);               # 积分榜
-        $score = $mem->zscore($key, $uid);
-        if (!$score || $score <= 0) {                                           # 分数异常
-            $leagueScore = GameConfig::pvp_leaguescore_getItem(1);              # 新手基础分
-            $score = $leagueScore->minScore;
-            $mem->zadd($key, array($uid => $score));                            # 重置玩家积分
-        }
-        $newscore = $mem->zincrby($key, $uid, $addValue);                       # 返回最新值
-        $mem->zadd(MemKey_GameRun::Game_PVPScoreByZone_zset_curWeek($zoneid), array($uid => $newscore));
-        return $newscore;
+    public static function GetCurSeasonID() {
+        $n = ceil((now() - self::pvpStartTs ) / self::pvpSeasonLengt);          # 进一取整
+        return $n;
     }
 
     /**
-     * @deprecated since version 2020.5.8
-     * @param type $req
-     * @param type $uid
-     * @param type $subValue
+     * 辅助方法:取指定赛季的结束时间戳
+     * @param int $seasonID
+     * @return int 
      */
-    private static function _subScore_by_uid($req, $uid, $subValue) {
-        if ($subValue >= 0) {                                                   # 防御异常数值
-            return;
-        }
-        $mem = $req->mem;
-        $zoneid = $req->zoneid;
-        $key = MemKey_GameRun::Game_PVPScoreByZone_zset($zoneid);               # 积分榜
-        $score = $mem->zscore($key, $uid);
-        $leagueScore = GameConfig::pvp_leaguescore_getItem(1);                  # 新手基础分
-        if (!$score || $score <= 0                                              #
-                || ($score + $subValue) <= $leagueScore->minScore) {            # 分数异常
-            $score = $leagueScore->minScore;                                    # 新手基础分
-            $mem->zadd($key, array($uid => $score));                            # 重置玩家积分
-        } else {
-            $score = $mem->zincrby($key, $uid, $subValue);                      # 扣除积分并返回最新值
-        }
-        $mem->zadd(MemKey_GameRun::Game_PVPScoreByZone_zset_curWeek($zoneid), array($uid => $score)); # 同步记录
-        return $score;
+    public static function GetSeasonEndTs($seasonID) {
+        $ts = self::pvpStartTs + $seasonID * self::pvpSeasonLengt;              # 从起始点开始 + n个赛季时常
+        return $ts;
     }
 
     /**
-     * 发送上周上榜奖励
+     * [6810] 竞技场 拉取主界面信息
      * @param Req $req
      */
-    public static function sendLastRankReward($req) {
-        $mem = gMem();
-        $zoneid = $req->zoneid;
-        $tsweek = TimeUtil::tsWeek();
-        $key = MemKey_GameRun::Game_PVPRankRewardRecord_set($zoneid);
-        if (!$mem->sismember($key, $tsweek)) {                                  # 上周榜单尚未处理, 每周只处理一次
-            // 上周是空的情况.
-            $lastKey = MemKey_GameRun::Game_PVPRankRewardRecord_byWeek_str($zoneid, $tsweek - 1);
-            $mem->sadd($key, $tsweek);                                          # 添加处理记录
-            $key_total = MemKey_GameRun::Game_PVPScoreByZone_zset($zoneid);     # 拉取上榜人员
-            $uids = $mem->zrevrange($key_total, 0, 99);
-            $rank = 0;
-            foreach ($uids as $uid) {
-                EmailProc::SendPvpRankReward($zoneid, $uid, ++$rank);           # 发送奖励邮件
+    static function pvpMainInfo($req) {
+        $uid = $req->uid;                                                       # 快速访问UID
+        $zoneid = $req->zoneid;                                                 # 快速访问zoneid
+        $pvp = new UserPVPModel($req->userInfo->game->pvp);                     # 设计玩家pvp数据结构
+        $seasonId = self::GetCurSeasonID();                                     # 当前赛季ID
+        $key = MemKey_GameRun::Game_PVPScoreByZoneSeason_zset($zoneid, $seasonId); # 积分总榜
+
+        $score = self::_getScore_by_uid($uid, $key);                            # 玩家积分
+        $rank = self::_getRank_by_uid($uid, $key);                              # 玩家排名
+        $fPower = HeroProc::CalcUserFightPower($zoneid, $uid, $req->userInfo->game); # 玩家总战力?还是当前防守队伍的战斗力?
+        $bHasNewLog = true; // todo: 真正查询是否有新战报
+        $matches = self::getNewMatches($pvp, gMem(), $uid, $zoneid);            # 获得新的匹配对手
+
+        if ($pvp->haventReward_season > 0 && $pvp->haventReward_season < $seasonId) { # 尚未发放上赛季奖励
+            $haventKey = MemKey_GameRun::Game_PVPScoreByZoneSeason_zset($zoneid, $pvp->haventReward_season);
+            // todo:发放上赛季奖励邮件
+            $rank = self::_getRank_by_uid($uid, $haventKey);                    # 查询上赛季排名
+            if ($rank <= self::pvpMaxRank) {                                    # 防御未上榜
+                foreach (GameConfig::pvp_rankreward() as $cfg) {
+                    $cfg = new \sm_pvp_rankreward();
+                    if ($rank >= $cfg->minRank && $rank <= $cfg->maxRank) {     # 找到对应的名次段
+                        EmailProc::SendPvpRankReward_Season($zoneid, $uid, $rank); # 发放奖励邮件(竞技币)
+                    }
+                }
             }
-            $mem->add($lastKey, $uids);
+            $pvp->haventReward_season = $seasonId;                              # 更新待发奖赛季
         }
+        if ($pvp->haventReward_tsDay > 0 && $pvp->haventReward_tsDay < tsDay()) { # 尚未发放昨天奖励
+            $haventKey_day = MemKey_GameRun::Game_PVPScoreByZone_zset_Day($zoneid, $pvp->haventReward_tsDay);
+            if (!gMem()->exists($haventKey_day) && $pvp->haventReward_tsDay == tsDay() - 1) { # 昨天的积分记录不存在
+                gMem()->zcopy($key, $haventKey_day);                            # 复制一份当前积分作为昨天的截止积分榜
+            } else {
+                // 不是昨天登录的, 且没有对应的数据 就不再复制当前数据了.直接未上榜处理
+            }
+            $rank = self::_getRank_by_uid($uid, $haventKey_day);                # 查询上一天排名
+            if ($rank <= self::pvpMaxRank) {                                    # 防御未上榜
+                foreach (GameConfig::pvp_rankreward() as $cfg) {
+                    $cfg = new \sm_pvp_rankreward();
+                    if ($rank >= $cfg->minRank && $rank <= $cfg->maxRank) {     # 找到对应的名次段
+                        EmailProc::SendPvpRankReward_Lastday($zoneid, $uid, $rank); # 发放奖励邮件(竞技币)
+                    }
+                }
+            }
+            $pvp->haventReward_tsDay = tsDay();                                 # 更新待发放奖励日期
+        }
+
+        // 组装 返回值结构
+        $ret = array(
+            'score' => $score, #                                                # 自己的积分
+            'rank' => $rank, #                                                  # 自己的排名
+            'pvpCoins' => $pvp->pvpCoins, #                                     # 自己的竞技币
+            'fPower' => $fPower, #                                              # 自己的总战力
+            'fightTicket' => $pvp->fightTicket, #                               # 自己的挑战票
+            'defTeam' => $pvp->defTeam, #                                       # 自己的防守队伍
+            'bHasNewFightLog' => $bHasNewLog, #                                 # 是否有战报刷新
+            'matches' => $matches, #                                            # 对手列表
+        );
+        return Resp::ok($ret);                                                  # 返回
     }
 
     /**
@@ -416,41 +377,16 @@ class PVPProc {
      */
     static function pvp_Refresh($req) {
         // 刷新无花费, 间隔时间3秒(客户端控制得了)
-        // 根据匹配规格获得5个对手即可(1. 排除自己, 2. 最好不要出现已经刷到过的对手)
-        // 低于玩家当前积分 -- 2个 -5%~-20%之间
-        // 与玩家当前积分基本持平 1个, ±5%之间
-        // 高于玩家当前积分 -- 2个 +5%~+40%之间
-//        $amt = $req->paras[0];                                                  # 提取 params , 验证下花费
-//        $pvp = new UserPVPModel($req->userInfo->game->pvp);
-//        $ts = now();
-//        if ($amt <= 0) {                                                        # 免费情况
-//            if ($pvp->nextRefreshTs > $ts) {                                    # 验证时间
-//                return Resp::err(ErrCode::pvp_refresh_time);
-//            }
-//        } else {                                                                # 扣除钻石刷新的情况
-//            $priceArr = explode(',', glc()->PVP_reFresh_Match_cost);            # 价格
-//            if (count($priceArr) < $pvp->dailyRefreshMatchTimes) {              # 超过最大刷新次数
-//                return Resp::err(ErrCode::pvp_refresh_max);
-//            }
-//            $costCash = $priceArr[$pvp->dailyRefreshMatchTimes++];              # 查找对应的定价, 并计次
-//            if ($costCash != $amt) {                                            # 跟预期值不一致,
-//                return Resp::err(ErrCode::pvp_refresh_cost_ilegal);
-//            }
-//            if (!UserGameModel::Consume_Cash($req->userInfo->game, $costCash)) {# 扣除钻石失败
-//                return Resp::err(ErrCode::notenough_cash_msg);
-//            }
-//        }
-//
-//        $pvp->curMatches = self::getNewMatches($pvp, $req->mem, $req->uid, $req->zoneid);
-//        $pvp->nextRefreshTs = now(glc()->PVP_refresh_Match_RecoverSeconds);
-//        $req->userInfo->game->pvp = $pvp;
-//        UserProc::updateUserInfo();                                         # 回写数据
-//
-//        $ret = array(
-//            'nextRefreshTs' => $pvp->nextRefreshTs, #                           # 下次免费刷新的时间戳
-//            'dailyRefreshMatchTimes' => $pvp->dailyRefreshMatchTimes,
-//            'curMatches' => $pvp->curMatches  #                                 # 当前对手清单
-//        );
+        $pvp = new UserPVPModel($req->userInfo->game->pvp);
+        $ts = now();
+        my_Assert($pvp->nextRefreshTs < $ts, ErrCode::pvp_refresh_time);        # 验证时间间隔
+        $pvp->curMatches = self::getNewMatches($pvp, $req->uid, $req->zoneid);
+        $pvp->nextRefreshTs = now(3);
+        $req->userInfo->game->pvp = $pvp;
+        UserProc::updateUserInfo();                                             # 回写数据 
+        $ret = array(
+            'curMatches' => $pvp->curMatches  #                                 # 当前对手清单
+        );
         return Resp::ok($ret);
     }
 
@@ -463,82 +399,38 @@ class PVPProc {
         $target_uid = $req->paras[0];                                           # 对手id
         $result = $req->paras[1];                                               # 胜负结果 0负,1胜
         $pvp = $req->userInfo->game->pvp;
-        // 根据挑战结果, 计算双方积分变化
-        // 更新双方的积分变化 
-        // redis->zincr 修改各自积分
-        // 返回
-//        if (!property_exists($pvp->curMatches, $target_uid)//
-//                or property_exists($pvp->curMatches->$target_uid, 'killed')) {  # 对手已被ko
-//            return Resp::err(ErrCode::pvp_wrongMather);
-//        }
-//        $g = glc();
-//        if (now() - $pvp->tiliTs > $g->PVP_reCover_Tili_costSec * 5) {          # 检查并扣除体力
-//            $pvp->tiliTs = now() - $g->PVP_reCover_Tili_costSec * 5;
-//        }
-//        if ($pvp->tiliExtra > 0) {                                              # 优先扣除溢出值
-//            $pvp->tiliExtra--;
-//        } else {
-//            $pvp->tiliTs += $g->PVP_reCover_Tili_costSec;
-//            if ($pvp->tiliTs > now()) {
-//                return Resp::err(ErrCode::pvp_wrongtili);
-//            }
-//        }
-//# 发放对应奖励并记录挑战记录
-//        $score = 0;
-//        if ($result) {      # 1 胜, 奖金币、积分、pvp币
-//            UserGameModel::Add_Gold($req->userInfo->game, $g->PVP_PK_Win_Gold);
-//            # × 奖励积分的公式: 获胜基础奖励积分 + 积分差距修正系数 * 积分差
-//            # 挑战胜利, 积分改为固定值.
-//            $winnerGainScore = $g->PVP_PK_Win_Score;                            # 本局得分
-//            $score = self::_addScore_by_uid($req, $uid, intval($winnerGainScore)); # 增加积分
-//            $pvp->pvpCoins += $g->PVP_PK_Win_PvpCoin;                           # 发放金币
-//            self::_subScore_by_uid($req, $target_uid, -intval($g->PVP_PK_be_defeated_score)); # 给对手扣除积分
-//            $pvp->contWin++;                                                    # 连胜记录
-//            $pvp->winTimes++;                                                   # 获胜记录
-//            $all = true;                                                        # 全部战胜标记
-//            foreach ($pvp->curMatches as $pid => &$p) {
-//                if ($pid == $target_uid) { #
-//                    $p->killed = 1;                                             # 添加ko标志
-//                    if (property_exists($p, 'fog')) {
-//                        $score = self::_addScore_by_uid($req, $uid, intval($winnerGainScore));    # 神秘对手, 积分翻倍(再加一遍)
-//                    }
-//                }
-//                if (!property_exists($p, 'killed')) {
-//                    $all = false;                                               # 尚未全部战胜
-//                }
-//            }
-//            if ($all) {                                                         # 全部战胜之后,刷新对手
-//                $pvp->curMatches = self::getNewMatches($pvp, $req->mem, $req->uid, $req->zoneid);
-//                $pvp->nextRefreshTs = now(glc()->PVP_refresh_Match_RecoverSeconds);
-//            }
-//        } else {             # 0 挑战失败 只扣除积分
-//            # × 奖励积分的公式: 获胜基础奖励积分 + 积分差距修正系数 * 积分差
-//            # 挑战失败, 扣除固定积分
-//            $loserGainScore = $g->PVP_PK_Fail_Score;
-//            $score = self::_subScore_by_uid($req, $uid, -intval($loserGainScore)); # 扣除积分
-//            self::_addScore_by_uid($req, $target_uid, intval($g->PVP_PK_be_undefeated_score)); # 给对手发放积分
-//            $pvp->contWin = 0;                                                  # 连胜置零
-//        }
-//        if (property_exists($pvp->curMatches, $target_uid) && property_exists($pvp->curMatches->$target_uid, 'fog')) {
-//            unset($pvp->curMatches->$target_uid->fog);
-//        }
-//        $pvp->totalTimes++;
-//        $leagueid = self::GetLeagueByScore($score);
-//        if ($pvp->leagueId != $leagueid) {
-//            $pvp->leagueId = $leagueid;
-//            SystemProc::PVP_league($req->zoneid, $req->userInfo->game, $leagueid);
-//        }
-//        $pvp->actives++;
-//        $pvp->dailyPkCnt++;
-//        $req->userInfo->game->pvp = $pvp;
-////todo: debuging...
-//        UserProc::updateUserInfo();                                       # 回写数据
-//        $ret = array(
-//            'contWin' => $pvp->contWin,
-//            'leagueId' => $pvp->leagueId,
-//            'newscore' => $score, #                                             # 返回最新积分
-//        );
-        return Resp::ok($ret);
+
+        if ($pvp->freeFightTickets > 0) {                                       # 有免费挑战票,先扣除免费的
+            $pvp->freeFightTickets -= 1;
+        } else {
+            my_Assert($pvp->fightTicket > 0, ErrCode::pvp_no_tickets);          # 防御: 挑战票不足
+            $pvp->fightTicket -= 1;                                             # 扣除挑战票
+        }
+        $season = self::GetCurSeasonID();                                       # 当前赛季
+        $key = MemKey_GameRun::Game_PVPScoreByZoneSeason_zset($zoneid, $season); # redis key
+        $RA = self::_getScore_by_uid($uid, $key);                               # A的积分
+        $RB = self::_getScore_by_uid($uid, $key);                               # B的积分
+        $EA = 1 / (1 + pow(10, ($RA - $RB) / 400));                             # A的胜率期望值
+        $EB = 1 / (1 + pow(10, ($RB - $RA) / 400));                             # B的胜率期望值
+        $K = 32;                                                                # 浮动系数, 暂定为32
+        $SA = $result;                                                          # 我的胜负结果
+        $SB = ($result == 1) ? 0 : 1;                                           # 对手的胜负结果
+        $R_A = $RA + $K * ($SA - $EA );                                         # 我的最终积分
+        $R_B = $RB + $K * ($SB - $EB);                                          # 对手的最终积分
+        #
+        self::_addScore_by_uid($zoneid, $uid, $R_A - $RA);                      # 更新A的积分
+        self::_addScore_by_uid($zoneid, $uid, $R_B - $RB);                      # 更新B的积分 
+        $req->userInfo->game->pvp = $pvp;
+        UserProc::updateUserInfo();                                             # 回写数据
+        $ret = array(#                                                          # 组装返回值
+            'freeFightTickets' => $pvp->freeFightTickets, #                     # 自己剩余免费票
+            'fightTicket' => $pvp->fightTicket, #                               # 自己剩余挑战票
+            'RA' => $RA, #                                                      # 自己挑战之前积分
+            'RB' => $RB, #                                                      # 对手挑战之前积分
+            'R_A' => $R_A, #                                                    # 自己最新积分
+            'R_B' => $R_B, #                                                    # 对手最新积分
+        );
+        return Resp::ok($ret);                                                  # 返回
     }
 
     /**
@@ -562,46 +454,28 @@ class PVPProc {
      * @return type
      */
     static function pvp_buyticket($req) {
-        $amt = $req->paras[0];                                                  # 验证下本次扣除的钻石数量
+        $amt = $req->paras[0];                                                  # 购买数量
         # 检查并扣除消耗
         # 增加挑战票
         # 回存数据
         # 返回
-//        $pvp = new UserPVPModel($req->userInfo->game->pvp);
-//        $g = glc();
-//        $curTili = intval((now() - $pvp->tiliTs) / $g->PVP_reCover_Tili_costSec);
-//        if ($curTili > 5) {
-//            $curTili = 5;
-//        }
-//        if ($pvp->tiliExtra > 0) {                                              # 体力溢出值大于0的时候不要购买
-//            return Resp::err(ErrCode::pvp_tili_chargenum);
-//        }
-//        $priceArr = explode(',', $g->PVP_recover_tili_cost_cash);
-//
-//        if (count($priceArr) < $pvp->dailyBuyTiliTimes) {
-//            return Resp::err(ErrCode::pvp_tili_soldout);
-//        }
-//        $costCash = $priceArr[$pvp->dailyBuyTiliTimes++];                       # 查找对应的定价, 并计次
-//        if ($costCash != $amt) {                                                # 跟预期值不一致,
-//            return Resp::err(ErrCode::pvp_tili_cost_ilegal);
-//        }
-//        if (!UserGameModel::Consume_Cash($req->userInfo->game, $costCash)) {    # 扣除钻石失败
-//            return Resp::err(ErrCode::notenough_cash_msg);
-//        }
-//        if ($curTili > 0) {                                                     # 增加溢出值
-//            $pvp->tiliExtra = $curTili;
-//        }
-//
-//        $pvp->tiliTs = now() - ( 5 * $g->PVP_reCover_Tili_costSec);             # 补满
-//        $req->userInfo->game->pvp = $pvp;
-//        UserProc::updateUserInfo();                                         # 回写玩家数据
-//        $ret = array(
-//            'tiliTs' => $pvp->tiliTs,
-//            'tiliExtra' => $pvp->tiliExtra,
-//            'costCash' => $costCash,
-//            'dailyBuyTiliTimes' => $pvp->dailyBuyTiliTimes,
-//            'userCash' => $req->userInfo->game->cash
-//        );
+        my_Assert($amt > 0, ErrCode::paras_err);                                # 数量>0
+        $pvp = new UserPVPModel($req->userInfo->game->pvp);
+        $g = glc();
+        $costCash = $g->PVP_pk_ticket_price * $amt;                             # 计算消耗钻石
+        my_Assert($costCash > 0, ErrCode::pvp_ticket_cost_ilegal);              # 定价数据异常
+
+        if (!UserGameModel::Consume_Cash($req->userInfo->game, $costCash)) {    # 扣除钻石失败
+            return Resp::err(ErrCode::notenough_cash_msg);
+        }
+        $pvp->fightTicket += $amt;                                              # 发放挑战票
+        $req->userInfo->game->pvp = $pvp;
+        UserProc::updateUserInfo();                                             # 回写玩家数据
+        $ret = array(
+            'tickets' => $pvp->fightTicket,
+            'costCash' => $costCash,
+            'userCash' => $req->userInfo->game->cash
+        );
         return Resp::ok($ret);                                                  # 返回
     }
 
@@ -614,23 +488,24 @@ class PVPProc {
         $zoneid = $req->zoneid;
         $index = $req->paras[0];                                                # 起始(0)
         $n = $req->paras[1];                                                    # 数量, (n<=max)
-//        if ($n < 1 || $n > $maxAmt) {                                           # 防御非法情况
-//            $n = $maxAmt;
-//        }
-//        $arr = self::getRankPlayers($req->mem, $zoneid, $index - 1, ($index + $n) - 1);
+        #
+        if ($n < 1 || $n > $maxAmt) {                                           # 防御非法情况
+            $n = $maxAmt;
+        }
+        $arr = self::getRankPlayers($req->mem, $zoneid, $index - 1, ($index + $n) - 1);
 //
-//        $rankId = $index;
-//        $result = ObjectInit();
-//        if (count($arr)) {
-//            foreach ($arr as $key => $value) {//$value 的数据类型是array
-//                $value["uid"] = $key;
-//                $result->$rankId = $value;
-//                $rankId += 1;
-//            }
-//        }
-//        $ret = array(
-//            'arr' => $result
-//        );
+        $rankId = $index;
+        $result = ObjectInit();
+        if (count($arr)) {
+            foreach ($arr as $key => $value) {//  $value 的数据类型是array
+                $value["uid"] = $key;
+                $result->$rankId = $value;
+                $rankId += 1;
+            }
+        }
+        $ret = array(
+            'dic' => $result
+        );
         return Resp::ok($ret);
     }
 
@@ -642,12 +517,51 @@ class PVPProc {
         // 提取主动挑战+被挑战记录
         // 更新下刷新时间
         // 返回
+        // 参数:无
+        $key_off = MemKey_User::PVP_OffensiveLog_zset($req->zoneid, $req->uid);
+        $key_def = MemKey_User::PVP_DefensiveLog_zset($req->zoneid, $req->uid);
+        // 拉取自己的挑战记录
+        $offLog = $req->mem->zrange($key_off, 0, self::maxLogCount);            # 主动挑战数据
+        $defLog = $req->mem->zrange($key_def, 0, self::maxLogCount);            # 防守数据
+        // Ps. 挑战记录分为2个榜, 且按照时间戳记录,晚于指定时间戳的判定为未读消息,挑战记录最多记录50条
+        $pvp = new UserPVPModel($req->userInfo->game->pvp);                     # 玩家竞技场数据
+        $pvp->lastCheckDefLog_ts = now();                                       # 记录时间戳 
+        UserProc::updateUserInfo();                                             # 回写数据 
+        array_walk($offLog, function (&$i) {                                    # 解码一下
+            $i = JsonUtil::decode($i);
+        });
+        array_walk($defLog, function (&$i) {                                    # 解码一下
+            $i = JsonUtil::decode($i);
+        });
+        return Resp::ok(array(
+                    'offLog' => $offLog,
+                    'defLog' => $defLog
+        ));
         return Resp::ok($ret);
     }
 
 // ---------------- 辅助函数 -----------------------
 // <editor-fold defaultstate="collapsed" desc="    辅助 函数   ">
 
+    /**
+     * 修改积分
+     * @param int $zoneid
+     * @param string $uid
+     * @param int $addValue 可以是负值
+     */
+    private static function _addScore_by_uid($zoneid, $uid, $addValue) {
+        $mem = gMem();
+        $seasonId = self::GetCurSeasonID();
+        $key = MemKey_GameRun::Game_PVPScoreByZoneSeason_zset($zoneid, $seasonId); # 积分榜
+        $score = $mem->zscore($key, $uid);
+        if (is_null($score) || $score <= 0) {                                   # 分数异常, 理论上不会出现负分
+            $score = self::pvpBaseScore;                                        # 新手基础分 
+            $mem->zadd($key, array($uid => $score));                            # 重置玩家积分
+        }
+        $newscore = $mem->zincrby($key, $uid, $addValue);                       # 返回最新值 
+        return $newscore;
+    }
+
     /**
      * 竞技场 查询玩家的积分 
      * @param type $uid
@@ -660,7 +574,7 @@ class PVPProc {
         }
         $mem = gMem();
         $score = $mem->zscore($key, $uid);
-        if (!$score || $score <= 0) {                                           # 分数异常
+        if (is_null($score) || $score <= 0) {                                   # 分数异常
             $score = self::pvpBaseScore;                                        # 新手基础分
             $mem->zadd($key, array($uid => $score));                            # 更新玩家积分
         }
@@ -687,38 +601,6 @@ class PVPProc {
         return $rank;                                                           # 返回
     }
 
-    /**
-     * 清理每日计数器
-     * @deprecated since version 2020.5.8
-     * @param Req $req
-     */
-    public static function ClearDailyPkcnt($req) {
-        $pvp = new UserPVPModel($req->userInfo->game->pvp);
-        $pvp->dailyPkCnt = 0;
-        $pvp->dailyBuyTiliTimes = 0;
-        $pvp->dailyRefreshMatchTimes = 0;
-        $pvp->dailyMatchRecord = array($req->uid);                              # 屏蔽自己
-        $pvp->curMatches = self::getNewMatches($pvp, $req->mem, $req->uid, $req->zoneid); # added by: 李宁,2017年8月1日 11:45:41
-        $pvp->nextRefreshTs = tsDay() * 86400 + glc()->PVP_refresh_Match_RecoverSeconds;
-        $req->userInfo->game->pvp = $pvp;
-    }
-
-    /**
-     * 依据积分获得所在阶段的id
-     * @deprecated since version 2020.5.8
-     * @param type $curScore
-     * @return int
-     */
-    private static function GetLeagueByScore($curScore) {
-        foreach (GameConfig::pvp_leaguescore() as $id => $lg) {
-            isEditor() and $lg = new sm_pvp_leaguescore;
-            if ($lg->maxScore >= $curScore && $lg->minScore <= $curScore) {
-                return $id;
-            }
-        }
-        return 1;                                                               # 找不到对应所属阶段的时候,返回 默认值 1
-    }
-
     /**
      * 获取对手匹配结果
      * @param UserPVPModel $pvp
@@ -727,16 +609,13 @@ class PVPProc {
      * @param type $zoneid
      */
     private static function getNewMatches($pvp, $uid, $zoneid) {
-        $arr = array();
         $seasonID = self::GetCurSeasonID();
         $key = MemKey_GameRun::Game_PVPScoreByZoneSeason_zset($zoneid, $seasonID); # redis key
-        self::findmatcher($zoneid, $key, $uid, $pvp, $arr);                     # 积分榜查找 
+        $arr = self::findmatcher($zoneid, $key, $uid, $pvp);                     # 积分榜查找 
         if (count($arr) < self::matchCount) {                                   # 再不行, 准备机器人吧
-// todo: 这里引入gm对手数据,
-            CLog::err('PVP刷对手数量不足, 赶快考虑加入机器人.', 'PVP');
+            CLog::err('PVP刷对手数量不足, 赶快考虑加入机器人.', 'PVP');    // todo: 这里引入gm对手数据,
         }
         $ret = self::GetPlayerInfosForPVP(gMem(), $zoneid, $arr);
-
         return $ret;
     }
 
@@ -749,41 +628,45 @@ class PVPProc {
      * @param type $arr
      */
     private static function findmatcher($zoneid, $key, $uid, &$pvp, &$arr) {
+        // 根据匹配规格获得5个对手即可(1. 排除自己, 2. 最好不要出现已经刷到过的对手)
+        // 低于玩家当前积分 -- 2个 -5%~-20%之间
+        // 与玩家当前积分基本持平 1个, ±5%之间
+        // 高于玩家当前积分 -- 2个 +5%~+40%之间
         $mem = gMem();
-        $rank = $mem->zrevrank($key, $uid);                                     # 直接查排名
+        $rank = self::_getRank_by_uid($uid, $key);                              # 直接查排名
+        $score = self::_getScore_by_uid($uid, $key);                            # 查积分
         $zlen = $mem->zlen($key);                                               # 数据长度
         $i = 0;                                                                 # 计数器
         $b = false;                                                             # 上下标志位
-        while (count($arr) < self::matchCount && $i < 50) {                     # 找够数量为止,或者查找超过100个位置, 跳出查找
-            $index = $rank + ($b ? - $i : $i);
-            $b = !$b;
-            if ($b) {                                                           # 变化查找方向
-                $i++;                                                           #
-            }
-            if ($index < 0 || $index >= $zlen) {                                # 跳过不合理位置
-                continue;
-            }
-            $back = $mem->zrevrange($key, $index, $index, true);                # 取1个人
-            if (count($back) <= 0) {
-                continue;                                                       # 跳过
-            }
-            $us = array_keys($back);
-            $d_uid = $us[0];
-            if ($d_uid == $uid) {                                               # 避开自己
-                continue;
-            }
-            $user = $mem->get(MemKey_User::Info_hash($zoneid, $d_uid));
-            if (null == $user) {                                                # 找不到对手数据,跳过
-                continue;
-            }
-//            $fp = HeroProc::CalcTeamFightPower($zoneid, $d_uid, $user);
-//            if ($fp > 0) {
-            if (!in_array($d_uid, $pvp->dailyMatchRecord)) {                    # 已经匹配过的对手不在出现
-                $arr[$d_uid] = $back[$d_uid];
-                $pvp->dailyMatchRecord[] = $d_uid;
-            }
-//            }
+        // 计算 比自己弱的 上线下线
+        $bH = ceil($score * (1 - 0.05));                                        # 低于当前玩家积分5%
+        $bL = ceil($score * (1 - 0.2));                                         # 低于当前玩家积分20%
+        $aL = ceil($score * (1 + 0.05));                                        # 高于当前玩家积分5%
+        $aH = ceil($score * (1 + 0.2));                                         # 高于当前玩家积分20%
+        $bPlayerUIDs = gMem()->zrevrangebyscore($key, $bH, $bL, true, true, 0, 2); # 取低于玩家积分的uids2个
+        $mPlayerUIDs = gMem()->zrevrangebyscore($key, $aL, $bH, true, true, 0, 2); # 取玩家相当的uid2个(以防包含玩家自己)
+        $aPlayerUIDs = gMem()->zrevrangebyscore($key, $aH, $aL, true, true, 0, 2); # 取高于玩家的uids2个
+        if (array_key_exists($uid, $mPlayerUIDs)) {                             # 如果积分相近的那一组包含自己
+            unset($mPlayerUIDs[$uid]);                                          # 剔除掉
+        } else {                                                                # 或者不包含自己
+            array_pop($mPlayerUIDs);                                            # 那多一个人,踢掉一个
         }
+        $uidWithScore = array_merge($bPlayerUIDs, $mPlayerUIDs, $aPlayerUIDs);  # 合并为玩家列表
+        return $uidWithScore;                                                   # 返回uid集合
+    }
+
+    /**
+     * 获取榜单玩家
+     * @param Credisutil $mem
+     * @param int $zoneid
+     * @param int $start
+     * @param int $stop
+     * @return type
+     */
+    private static function getRankPlayers($mem, $zoneid, $start, $stop) {
+        $key = MemKey_GameRun::Game_PVPScoreByZoneSeason_zset($zoneid, self::GetCurSeasonID());
+        $retUidsWithScore = $mem->zrevrange($key, $start, $stop, true);
+        return self::GetPlayerInfosForPVP($mem, $zoneid, $retUidsWithScore);
     }
 
     /**
@@ -812,7 +695,7 @@ class PVPProc {
                     $heros->$n_hid = $userGameInfo->game->heros->collectHeros->$hid;
                 }
             }
-
+            $fpower = HeroProc::CalcUserFightPower($zoneid, $uid, $userGameInfo); # 计算总战力
             $adversary = array(#                                                # 拼装玩家信息
                 'uid' => $uid,
                 'name' => my_null_default($userGameInfo->game->name, ""),
@@ -823,6 +706,7 @@ class PVPProc {
                 'yanling' => array("items" => my_null_default($userGameInfo->game->store->yanling, new \stdClass())), # 言灵
                 'heros' => my_null_default($heros, new \stdClass()), #          # 英雄集合
                 'score' => $retUidsWithScore[$uid], #                           # 积分
+                'fpower' => $fpower, #                                          # 总战力
             );
             $arr[$uid] = $adversary;
         }
@@ -832,67 +716,6 @@ class PVPProc {
         return $arr;
     }
 
-    /**
-     * 获取榜单玩家
-     * @deprecated since version 2020.5.8
-     * @param Credisutil $mem
-     * @param int $zoneid
-     * @param int $start
-     * @param int $stop
-     * @return type
-     */
-    private static function getRankPlayers($mem, $zoneid, $start, $stop) {
-        $key = MemKey_GameRun::Game_PVPScoreByZone_zset($zoneid);
-        $retUidsWithScore = $mem->zrevrange($key, $start, $stop, true);
-        return self::GetPlayerInfosForPVP($mem, $zoneid, $retUidsWithScore);
-    }
-
-    /**
-     * 提取英雄信息以供其他人使用
-     * @deprecated since version 2020.5.8
-     * @param type $userInfo
-     * @param type $heroId
-     * @return UserHeroModel
-     */
-    public static function getHeroInfoForShare($userInfo, $heroId) {
-        if ($heroId) {
-            $heroInfo = $userInfo->heros->collectHeros->$heroId;
-        } else { // todo: 暂定如果没有设置共享英雄,默认取集合中第一个英雄, 征询策划是否修订规则
-            $coll = $userInfo->heros->collectHeros;
-            $keys = array_keys((array) $coll);
-            if (count($keys) <= 0) {
-                return null;  // 暴力跳过, 防止出现更大的错误
-            }
-            $heroId = $keys[0];
-            $heroInfo = $userInfo->heros->collectHeros->$heroId;
-        }
-// 额外将英雄的装备数据替换为实例数据
-        self::getArmor($userInfo, $heroInfo, 'weapon');
-        self::getArmor($userInfo, $heroInfo, 'armor');
-        self::getArmor($userInfo, $heroInfo, 'ring');
-        return $heroInfo;
-    }
-
-    /**
-     * @deprecated since version 2020.5.8
-     * @param type $userInfo
-     * @param type $hero
-     * @param type $armor
-     * @return type
-     */
-    private static function getArmor($userInfo, $hero, $armor) {
-        if (isset($hero->equip->$armor)) {
-            if (property_exists($hero->equip->$armor, 'itemuid')) {
-                $armorid = $hero->equip->$armor->itemuid;
-                if ($armorid > 0 && isset($userInfo->store->equipment->$armorid)) {
-                    $hero->equip->$armor = $userInfo->store->equipment->$armorid;
-                    return;                                                     # 找到后直接跳出
-                }
-            }
-        }
-        $hero->equip->$armor = null;
-    }
-
 // </editor-fold>
 //
 // </editor-fold>

+ 8 - 1
Gameserver/Amfphp/process/GuildProc.php

@@ -1936,6 +1936,13 @@ class GuildProc {
 // </editor-fold>
 // <editor-fold defaultstate="collapsed" desc="公会封装函数集合">
 
+    /**
+     * @deprecated since version 2020.5.9
+     * @param type $mem
+     * @param type $uid
+     * @param type $zoneid
+     * @return type
+     */
     static function initFightTeamInfo($mem, $uid, $zoneid) {
         $userGameInfo = new UserGameModel();
         $userGameInfo->readDataFromMem(MemKey_User::Info_hash($zoneid, $uid));
@@ -1949,7 +1956,7 @@ class GuildProc {
             $m = 0;
             foreach ($heros_uid as $heroid) {
                 $m++;
-                $heros->$m = $heroid ? PVPProc::getHeroInfoForShare($userGameInfo, $heroid) : null;
+//                $heros->$m = $heroid ? PVPProc::getHeroInfoForShare($userGameInfo, $heroid) : null;
             }
             $team = array(
                 'teamLeader' => $teamConfig->teamDic->$teamid->teamLeader,

+ 13 - 2
Gameserver/Amfphp/test.php

@@ -11,7 +11,18 @@ echoLine("phpver:" . PHP_VERSION);
 
 $key = "testzset";
 $key_new = "wanggang";
-gMem()->zcopy($key, $key_new);
+//gMem()->zcopy($key, $key_new);
 
-var_dump(gMem()->zrevrange($key_new, 0, -1, true));
+$a = gMem()->zrevrangebyscore($key_new, 200, 10, true, true, 0, 3);
+var_dump($a);
 
+if (array_key_exists("wg ", $a)) {
+    unset($a["wg "]);
+    echo "removing wg ";
+}
+foreach ($a as $key => $value) {
+
+    var_dump($key);
+}
+
+//var_dump(gMem()->zrevrangebyscore($key_new, 100, 1, $withScore));

+ 45 - 4
Gameserver/Amfphp/util/CRedisUtil.php

@@ -1024,19 +1024,60 @@ class CRedisUtil extends CMemBase {
     }
 
     /**
+     * 
      * 有序列表 - 获取指定积分区间内的成员
      * @param string $key
      * @param int/float $min
      * @param int/float $max
      * @param boolean $withScore
+     * @param bool $limit 是否限制返回值大小
+     * @param int $offset 限制返回结果的起始位置
+     * @param type $count 返回结果的数量
      * @return type
      */
-    public function zrangebyscore($key, $min, $max, $withScore = false) {
+    public function zrangebyscore($key, $min, $max, $withScore = false, $limit = false, $offset = 0, $count = 10) {
         self::debug();
-        if ($withScore) {
-            return $this->redis->zrangebyscore($key, $min, $max, 'WITHSCORES');
+        if ($limit) {
+            if ($withScore) {
+                return $this->redis->zrangebyscore($key, $min, $max, 'WITHSCORES', "LIMIT", $offset, $count);
+            } else {
+                return $this->redis->zrangebyscore($key, $min, $max, 'LIMIT', $offset, $count);
+            }
         } else {
-            return $this->redis->zrangebyscore($key, $min, $max);
+            if ($withScore) {
+                return $this->redis->zrangebyscore($key, $min, $max, 'WITHSCORES');
+            } else {
+                return $this->redis->zrangebyscore($key, $min, $max);
+            }
+        }
+    }
+
+    /**
+     * 
+     * 有序列表 - 获取按照倒序排序后指定积分区间内的成员
+     * @param string $key
+     * @param int/float $max
+     * @param int/float $min
+     * @param boolean $withScore
+     * @param bool $limit 是否限制返回值大小
+     * @param int $offset 限制返回结果的起始位置
+     * @param type $count 返回结果的数量
+     * @return type
+     */
+    public function zrevrangebyscore($key, $max, $min, $withScore = false, $limit = false, $offset = 0, $count = 10) {
+        self::debug();
+        if ($limit) {
+            if ($withScore) {
+                return $this->redis->zrevrangebyscore($key, $max, $min, 'WITHSCORES', "LIMIT", $offset, $count);
+            } else {
+                return $this->redis->zrevrangebyscore($key, $max, $min, 'LIMIT', $offset, $count);
+            }
+        } else {
+            if ($withScore) {
+                return $this->redis->zrevrangebyscore($key, $max, $min, 'WITHSCORES');
+            } else {
+                return $this->redis->zrevrangebyscore($key, $max, $min);
+            }
         }
     }
 

+ 9 - 1
Gameserver/nbproject/private/private.xml

@@ -11,6 +11,14 @@
         </file>
     </editor-bookmarks>
     <open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
-        <group/>
+        <group>
+            <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/model/User/UserPVPModel.php</file>
+            <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/base/CmdCode.php</file>
+            <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/process/FightProc/PVPProc.php</file>
+            <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/base/MemKey_GameRun.php</file>
+            <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/test.php</file>
+            <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/model/Const/globalsettings.php</file>
+            <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/process/FightProc.php</file>
+        </group>
     </open-files>
 </project-private>

+ 35 - 63
Gameserver/phpRedisAdmin/predis/src/Client.php

@@ -38,8 +38,8 @@ use Predis\Transaction\MultiExec as MultiExecTransaction;
  *
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class Client implements ClientInterface, \IteratorAggregate
-{
+class Client implements ClientInterface, \IteratorAggregate {
+
     const VERSION = '1.1.2-dev';
 
     protected $connection;
@@ -50,8 +50,7 @@ class Client implements ClientInterface, \IteratorAggregate
      * @param mixed $parameters Connection parameters for one or more servers.
      * @param mixed $options    Options to configure some behaviours of the client.
      */
-    public function __construct($parameters = null, $options = null)
-    {
+    public function __construct($parameters = null, $options = null) {
         $this->options = $this->createOptions($options ?: array());
         $this->connection = $this->createConnection($parameters ?: array());
         $this->profile = $this->options->profile;
@@ -68,8 +67,7 @@ class Client implements ClientInterface, \IteratorAggregate
      *
      * @return OptionsInterface
      */
-    protected function createOptions($options)
-    {
+    protected function createOptions($options) {
         if (is_array($options)) {
             return new Options($options);
         }
@@ -100,8 +98,7 @@ class Client implements ClientInterface, \IteratorAggregate
      *
      * @return ConnectionInterface
      */
-    protected function createConnection($parameters)
-    {
+    protected function createConnection($parameters) {
         if ($parameters instanceof ConnectionInterface) {
             return $parameters;
         }
@@ -156,14 +153,13 @@ class Client implements ClientInterface, \IteratorAggregate
      *
      * @return \Closure
      */
-    protected function getConnectionInitializerWrapper($callable)
-    {
+    protected function getConnectionInitializerWrapper($callable) {
         return function () use ($callable) {
             $connection = call_user_func_array($callable, func_get_args());
 
             if (!$connection instanceof ConnectionInterface) {
                 throw new \UnexpectedValueException(
-                    'The callable connection initializer returned an invalid type.'
+                        'The callable connection initializer returned an invalid type.'
                 );
             }
 
@@ -174,16 +170,14 @@ class Client implements ClientInterface, \IteratorAggregate
     /**
      * {@inheritdoc}
      */
-    public function getProfile()
-    {
+    public function getProfile() {
         return $this->profile;
     }
 
     /**
      * {@inheritdoc}
      */
-    public function getOptions()
-    {
+    public function getOptions() {
         return $this->options;
     }
 
@@ -198,8 +192,7 @@ class Client implements ClientInterface, \IteratorAggregate
      *
      * @return Client
      */
-    public function getClientFor($connectionID)
-    {
+    public function getClientFor($connectionID) {
         if (!$connection = $this->getConnectionById($connectionID)) {
             throw new \InvalidArgumentException("Invalid connection ID: $connectionID.");
         }
@@ -210,16 +203,14 @@ class Client implements ClientInterface, \IteratorAggregate
     /**
      * Opens the underlying connection and connects to the server.
      */
-    public function connect()
-    {
+    public function connect() {
         $this->connection->connect();
     }
 
     /**
      * Closes the underlying connection and disconnects from the server.
      */
-    public function disconnect()
-    {
+    public function disconnect() {
         $this->connection->disconnect();
     }
 
@@ -229,8 +220,7 @@ class Client implements ClientInterface, \IteratorAggregate
      * This is the same as `Client::disconnect()` as it does not actually send
      * the `QUIT` command to Redis, but simply closes the connection.
      */
-    public function quit()
-    {
+    public function quit() {
         $this->disconnect();
     }
 
@@ -239,16 +229,14 @@ class Client implements ClientInterface, \IteratorAggregate
      *
      * @return bool
      */
-    public function isConnected()
-    {
+    public function isConnected() {
         return $this->connection->isConnected();
     }
 
     /**
      * {@inheritdoc}
      */
-    public function getConnection()
-    {
+    public function getConnection() {
         return $this->connection;
     }
 
@@ -262,11 +250,10 @@ class Client implements ClientInterface, \IteratorAggregate
      *
      * @return Connection\NodeConnectionInterface
      */
-    public function getConnectionById($connectionID)
-    {
+    public function getConnectionById($connectionID) {
         if (!$this->connection instanceof AggregateConnectionInterface) {
             throw new NotSupportedException(
-                'Retrieving connections by ID is supported only by aggregate connections.'
+                    'Retrieving connections by ID is supported only by aggregate connections.'
             );
         }
 
@@ -286,12 +273,11 @@ class Client implements ClientInterface, \IteratorAggregate
      *
      * @return mixed
      */
-    public function executeRaw(array $arguments, &$error = null)
-    {
+    public function executeRaw(array $arguments, &$error = null) {
         $error = false;
 
         $response = $this->connection->executeCommand(
-            new RawCommand($arguments)
+                new RawCommand($arguments)
         );
 
         if ($response instanceof ResponseInterface) {
@@ -308,26 +294,23 @@ class Client implements ClientInterface, \IteratorAggregate
     /**
      * {@inheritdoc}
      */
-    public function __call($commandID, $arguments)
-    {
+    public function __call($commandID, $arguments) {
         return $this->executeCommand(
-            $this->createCommand($commandID, $arguments)
+                        $this->createCommand($commandID, $arguments)
         );
     }
 
     /**
      * {@inheritdoc}
      */
-    public function createCommand($commandID, $arguments = array())
-    {
+    public function createCommand($commandID, $arguments = array()) {
         return $this->profile->createCommand($commandID, $arguments);
     }
 
     /**
      * {@inheritdoc}
      */
-    public function executeCommand(CommandInterface $command)
-    {
+    public function executeCommand(CommandInterface $command) {
         $response = $this->connection->executeCommand($command);
 
         if ($response instanceof ResponseInterface) {
@@ -351,8 +334,7 @@ class Client implements ClientInterface, \IteratorAggregate
      *
      * @return mixed
      */
-    protected function onErrorResponse(CommandInterface $command, ErrorResponseInterface $response)
-    {
+    protected function onErrorResponse(CommandInterface $command, ErrorResponseInterface $response) {
         if ($command instanceof ScriptCommand && $response->getErrorType() === 'NOSCRIPT') {
             $eval = $this->createCommand('EVAL');
             $eval->setRawArguments($command->getEvalArguments());
@@ -384,16 +366,13 @@ class Client implements ClientInterface, \IteratorAggregate
      *
      * @return mixed
      */
-    private function sharedContextFactory($initializer, $argv = null)
-    {
+    private function sharedContextFactory($initializer, $argv = null) {
         switch (count($argv)) {
             case 0:
                 return $this->$initializer();
 
             case 1:
-                return is_array($argv[0])
-                    ? $this->$initializer($argv[0])
-                    : $this->$initializer(null, $argv[0]);
+                return is_array($argv[0]) ? $this->$initializer($argv[0]) : $this->$initializer(null, $argv[0]);
 
             case 2:
                 list($arg0, $arg1) = $argv;
@@ -413,8 +392,7 @@ class Client implements ClientInterface, \IteratorAggregate
      *
      * @return Pipeline|array
      */
-    public function pipeline(/* arguments */)
-    {
+    public function pipeline(/* arguments */) {
         return $this->sharedContextFactory('createPipeline', func_get_args());
     }
 
@@ -426,8 +404,7 @@ class Client implements ClientInterface, \IteratorAggregate
      *
      * @return Pipeline|array
      */
-    protected function createPipeline(array $options = null, $callable = null)
-    {
+    protected function createPipeline(array $options = null, $callable = null) {
         if (isset($options['atomic']) && $options['atomic']) {
             $class = 'Predis\Pipeline\Atomic';
         } elseif (isset($options['fire-and-forget']) && $options['fire-and-forget']) {
@@ -456,8 +433,7 @@ class Client implements ClientInterface, \IteratorAggregate
      *
      * @return MultiExecTransaction|array
      */
-    public function transaction(/* arguments */)
-    {
+    public function transaction(/* arguments */) {
         return $this->sharedContextFactory('createTransaction', func_get_args());
     }
 
@@ -469,8 +445,7 @@ class Client implements ClientInterface, \IteratorAggregate
      *
      * @return MultiExecTransaction|array
      */
-    protected function createTransaction(array $options = null, $callable = null)
-    {
+    protected function createTransaction(array $options = null, $callable = null) {
         $transaction = new MultiExecTransaction($this, $options);
 
         if (isset($callable)) {
@@ -488,8 +463,7 @@ class Client implements ClientInterface, \IteratorAggregate
      *
      * @return PubSubConsumer|null
      */
-    public function pubSubLoop(/* arguments */)
-    {
+    public function pubSubLoop(/* arguments */) {
         return $this->sharedContextFactory('createPubSub', func_get_args());
     }
 
@@ -501,8 +475,7 @@ class Client implements ClientInterface, \IteratorAggregate
      *
      * @return PubSubConsumer|null
      */
-    protected function createPubSub(array $options = null, $callable = null)
-    {
+    protected function createPubSub(array $options = null, $callable = null) {
         $pubsub = new PubSubConsumer($this, $options);
 
         if (!isset($callable)) {
@@ -521,16 +494,14 @@ class Client implements ClientInterface, \IteratorAggregate
      *
      * @return MonitorConsumer
      */
-    public function monitor()
-    {
+    public function monitor() {
         return new MonitorConsumer($this);
     }
 
     /**
      * {@inheritdoc}
      */
-    public function getIterator()
-    {
+    public function getIterator() {
         $clients = array();
         $connection = $this->getConnection();
 
@@ -544,4 +515,5 @@ class Client implements ClientInterface, \IteratorAggregate
 
         return new \ArrayIterator($clients);
     }
+
 }