少年修仙传客户端代码仓库
hch
2025-06-12 204ef05a831c9484e2abc561d27ecbff7c797453
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace vnxbqy.UI
{
    
    public class CrossServerOneVsOnePlayerInfo : Singleton<CrossServerOneVsOnePlayerInfo>
    {
        public int Score { get; private set; }    // 当前积分
 
        public int DanLV { get; private set; }    // 当前段位
 
        public int PKCount { get; private set; }     // 总PK次数
 
        public int WinCount { get; private set; }     // 胜利次数
 
        public int CWinCount { get; private set; }     // 连胜次数
 
        public int DayPKCount { get; private set; }     // 当日已PK次数
 
        public int DayWinCount { get; private set;}  //当日胜利次数
 
        public int DayBuyCount { get; private set; }     // 当日已购买次数
 
        public int DayItemAddCount { get; private set; } // 当日物品增加次数
        public int DayRefreshCount { get; private set; } // 今日已刷新匹配次数
 
        private int preDayPkCount;
        CrossServerOneVsOneModel crossServerModel { get { return ModelCenter.Instance.GetModel<CrossServerOneVsOneModel>(); } }
        public event Action UpdatePlayerInfoEvent;
        public event Action UpdateMatchNumEvent;
 
        public void InitData()
        {
            preDayPkCount = 0;
            Score = 0;
            DanLV = 0;
            PKCount = 0;
            WinCount = 0;
            CWinCount = 0;
            DayPKCount = 0;
            DayBuyCount = 0;
            DayWinCount = 0;
            DayRefreshCount = 0;
        }
 
        public void UpdatePlayerInfo(HC101_tagMCCrossRealmPKPlayerInfo playerInfo)
        {
            this.Score = (int)playerInfo.Score;
            this.DanLV = playerInfo.DanLV;
            this.PKCount = playerInfo.PKCount;
            this.WinCount = playerInfo.WinCount;
            this.CWinCount = playerInfo.CWinCount;
            this.DayBuyCount = playerInfo.DayBuyCount;
            this.DayWinCount = playerInfo.DayWinCount;
            this.DayItemAddCount = playerInfo.DayItemAddCount;
            this.DayPKCount = playerInfo.DayPKCount;
            this.DayRefreshCount = playerInfo.DayRefreshCount;
 
            if (this.preDayPkCount != playerInfo.DayPKCount)
            {
                this.preDayPkCount = playerInfo.DayPKCount;
                if (UpdateMatchNumEvent != null)
                {
                    UpdateMatchNumEvent();
                }
            }
          
            if (UpdatePlayerInfoEvent != null)
            {
                UpdatePlayerInfoEvent();
            }
        }
 
        public bool TryGetMaxRank(out int upScore)
        {
            upScore = 0;
            var preArenaConfig = CrossServerArenaConfig.Get(DanLV - 1);
            var arenaConfig = CrossServerArenaConfig.Get(DanLV);
            if (arenaConfig != null && arenaConfig.LVUpScore > 0)
            {
                if(preArenaConfig != null)
                {
                    upScore = arenaConfig.LVUpScore - preArenaConfig.LVUpScore;
                }
                else
                {
                    upScore = arenaConfig.LVUpScore;
                }
            }
            return upScore == 0;
        }
 
        public int GetBuyMatchNumPrice()
        {
            Equation.Instance.Clear();
            Equation.Instance.AddKeyValue("todayBuyCount", DayBuyCount);
            return Equation.Instance.Eval<int>(crossServerModel.priceFormula);
        }
 
        public int GetDayRemainNum()
        {
            int remainNum = DayBuyCount + DayItemAddCount + crossServerModel.freeMaxMatchNum - DayPKCount;
            return remainNum > 0 ? remainNum : 0;
        }
 
        public int GetDayRemainBuyNum()
        {
            int remainNum = crossServerModel.buyMaxMatchNum - DayBuyCount;
            return remainNum > 0 ? remainNum : 0;
        }
 
        //正数代表还有几次免费刷新机会,负数代表仙玉刷新次数
        public int GetDayFreeRefreshNum()
        {
            return crossServerModel.freeMaxMatchRefreshNum - DayRefreshCount;
        }
 
        public int GetDayFreeRefreshPrice()
        {
            int count = GetDayFreeRefreshNum();
            if (count > 0)
            {
                return 0;
            }
            count = Math.Abs(count);
            Equation.Instance.Clear();
            Equation.Instance.AddKeyValue("refreshBuyCount", count);
            return Equation.Instance.Eval<int>(crossServerModel.priceRefreshFormula);
        }
 
 
        public string DisplayWinningRate()
        {
            float rate = PKCount != 0 ? (float)WinCount / PKCount : 0;
            return StringUtility.Contact((float)Math.Round(rate*100,1),"%");
        }
 
    }
}