yyl
4 小时以前 5d3366f2e0f687995eb7ad2107c4379fe7acd4e8
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
 
 
public class EquipFightPower : Singleton<EquipFightPower>
{
    string scoreFormula;
    string propertyFormula;
 
    public EquipFightPower()
    {
        var config = FuncConfigConfig.Get("FightpowerFormula");
        propertyFormula = config.Numerical1;
        scoreFormula = config.Numerical2;
    }
 
    public int GetSpiritWeaponPower(int itemId)
    {
        var score = ItemLogicUtility.Instance.GetEquipScore(itemId);
        Equation.Instance.Clear();
        Equation.Instance.AddKeyValue("equipScoreTotal", score);
        return Equation.Instance.Eval<int>(scoreFormula);
    }
 
    public int CalculatePower(int level)
    {
        Equation.Instance.Clear();
        Equation.Instance.AddKeyValue("equipScoreTotal", CountEquipScore(level));
        var power = Equation.Instance.Eval<int>(scoreFormula);
 
        var propertyContainer = new Properties();
 
        Equation.Instance.Clear();
        var keys = propertyContainer.keys;
        for (int i = 0; i < keys.Count; i++)
        {
            var id = keys[i];
            var value = propertyContainer[id];
            var config = PlayerPropertyConfig.Get(id);
            Equation.Instance.AddKeyValue(config.Parameter, value);
        }
 
        var propertyPower = Equation.Instance.Eval<int>(propertyFormula);
        power += propertyPower;
 
 
        return power;
    }
 
    private int CountEquipScore(int level)
    {
        var score = 0;
        // for (int i = 1; i <= 12; i++)
        // {
        //     var equipPosition = new Int2(level, i);
        //     var guid = equipModel.GetEquip(equipPosition);
        //     if (string.IsNullOrEmpty(guid))
        //     {
        //         continue;
        //     }
 
        //     var equip = packModel.GetItemByGuid(guid);
        //     if (equip == null)
        //     {
        //         continue;
        //     }
 
        //     score += equip.score;
        // }
 
        return score;
    }
 
 
 
    public int CalculatePower(int job, int level, List<EquipInfo> equipInfos)
    {
        var propertyContainer = new Properties();
        var totalScore = 0;
 
 
        Equation.Instance.Clear();
        Equation.Instance.AddKeyValue("equipScoreTotal", totalScore);
        var power = Equation.Instance.Eval<int>(scoreFormula);
 
        Equation.Instance.Clear();
        var keys = propertyContainer.keys;
        for (int i = 0; i < keys.Count; i++)
        {
            var id = keys[i];
            var value = propertyContainer[id];
            var config = PlayerPropertyConfig.Get(id);
            if (config != null)
            {
                Equation.Instance.AddKeyValue(config.Parameter, value);
            }
 
        }
 
        power += Equation.Instance.Eval<int>(propertyFormula);
 
        return power;
    }
 
    class Properties
    {
        Dictionary<int, int> tables = new Dictionary<int, int>();
 
        public List<int> keys { get { return new List<int>(tables.Keys); } }
 
        public int this[int id] { get { return tables[id]; } }
 
        public void Add(int id, int value)
        {
            if (id == 7)
            {
                Add(67, value);
                Add(68, value);
            }
            else
            {
                if (tables.ContainsKey(id))
                {
                    tables[id] = tables[id] + value;
                }
                else
                {
                    tables[id] = value;
                }
            }
        }
 
        public void AddRange(List<int> ids, List<int> values)
        {
            if (ids.IsNullOrEmpty() || values.IsNullOrEmpty())
            {
                return;
            }
 
            var count = Mathf.Min(ids.Count, values.Count);
            for (int i = 0; i < count; i++)
            {
                Add(ids[i], values[i]);
            }
        }
 
    }
 
    public struct EquipInfo
    {
        public int itemId;
        public int score;
 
    }
 
}