| | |
| | | public class AlchemyModel : Model, IBeforePlayerDataInitialize, IPlayerLoginOk
|
| | | {
|
| | | Dictionary<int, uint> m_AlchemyTimes = new Dictionary<int, uint>();
|
| | | Dictionary<int, AlchemyCount> m_AlchemyCounts = new Dictionary<int, AlchemyCount>(); |
| | | Dictionary<int, AlchemyCount> m_AlchemyCounts = new Dictionary<int, AlchemyCount>();
|
| | | Dictionary<int, int> m_AlchemyQualityLucks = new Dictionary<int, int>();
|
| | | Dictionary<int, List<Item>> m_AlchemyMaterials = new Dictionary<int, List<Item>>();
|
| | |
|
| | | int m_SelectQuality = 0;
|
| | | public int selectQuality
|
| | |
| | |
|
| | | public int stoveLevel { get; private set; }
|
| | | public int stoveExp { get; private set; }
|
| | | public string alchemySuccRate { get; private set; }
|
| | |
|
| | | public event Action selectQualityRefresh;
|
| | | public event Action selectAlchemyRefresh;
|
| | |
| | | var max = intArray[intArray.Length - 1][1];
|
| | | if (m_AlchemyCounts.ContainsKey(config.AlchemyQuality))
|
| | | {
|
| | | var alchemyCount = m_AlchemyCounts[config.AlchemyQuality];
|
| | | if (min < alchemyCount.min)
|
| | | {
|
| | | alchemyCount.min = min;
|
| | | m_AlchemyCounts[config.AlchemyQuality] = alchemyCount;
|
| | | }
|
| | | if (max > alchemyCount.max)
|
| | | {
|
| | | alchemyCount.max = max;
|
| | | m_AlchemyCounts[config.AlchemyQuality] = alchemyCount;
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | m_AlchemyCounts[config.AlchemyQuality] = new AlchemyCount()
|
| | | {
|
| | | min = min,
|
| | | max = max,
|
| | | };
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | {
|
| | | var funcConfig = FuncConfigConfig.Get("alchemySuccess");
|
| | | alchemySuccRate = funcConfig.Numerical3;
|
| | |
|
| | | var json = LitJson.JsonMapper.ToObject(funcConfig.Numerical2);
|
| | | foreach (var key in json.Keys)
|
| | | {
|
| | | var quality = int.Parse(key);
|
| | | m_AlchemyQualityLucks.Add(quality, int.Parse(json[key].ToString()));
|
| | | }
|
| | | }
|
| | |
|
| | | {
|
| | | var configs = AlchemyConfig.GetValues();
|
| | | foreach (var config in configs)
|
| | | {
|
| | | m_AlchemyMaterials.Add(config.ID, new List<Item>());
|
| | | var dict = ConfigParse.GetDic<int, int>(config.Material);
|
| | | foreach (var key in dict.Keys)
|
| | | {
|
| | | m_AlchemyMaterials[config.ID].Add(new Item()
|
| | | {
|
| | | id = key,
|
| | | count = dict[key],
|
| | | });
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | public bool TryGetAlchemyStartTime(int alchemyId, out uint tick)
|
| | | {
|
| | | return m_AlchemyTimes.TryGetValue(alchemyId, out tick);
|
| | | }
|
| | |
|
| | | public bool TryGetAlchemyCount(int alchemyId, out AlchemyCount alchemyCount)
|
| | | {
|
| | | var config = AlchemyConfig.Get(alchemyId);
|
| | | if (config == null)
|
| | | {
|
| | | alchemyCount = default(AlchemyCount);
|
| | | return false;
|
| | | }
|
| | | if (config.AlchemType == (int)AlchemyType.Fairy)
|
| | | {
|
| | | alchemyCount = AlchemyCount.one;
|
| | | return true;
|
| | | }
|
| | | return m_AlchemyCounts.TryGetValue(config.AlchemyQuality, out alchemyCount);
|
| | | }
|
| | |
|
| | | public bool TryGetAlchemyMaterials(int alchemyId, out List<Item> items)
|
| | | {
|
| | | return m_AlchemyMaterials.TryGetValue(alchemyId, out items);
|
| | | }
|
| | |
|
| | | public float GetAlchemySuccRate(int alchemyId)
|
| | | {
|
| | | var config = AlchemyConfig.Get(alchemyId);
|
| | | if (config == null)
|
| | | {
|
| | | return 0f;
|
| | | }
|
| | | if (config.AlchemType == (int)AlchemyType.Fairy)
|
| | | {
|
| | | return 10000f;
|
| | | }
|
| | | var itemConfig = ItemConfig.Get(config.AlchemItemID);
|
| | | var luckValue = PlayerDatas.Instance.extersion.luckValue;
|
| | | return GetAlchemySuccRate(stoveLevel, itemConfig.LV, luckValue);
|
| | | }
|
| | |
|
| | | public float GetAlchemySuccRate(int stoveLevel, int itemLevel, int luck)
|
| | | {
|
| | | Equation.Instance.Clear();
|
| | | Equation.Instance.AddKeyValue("alchemyLV", stoveLevel);
|
| | | Equation.Instance.AddKeyValue("alchemyQuality", itemLevel);
|
| | | Equation.Instance.AddKeyValue("curLuckValue", luck);
|
| | | var qualityNeedLuck = m_AlchemyQualityLucks.ContainsKey(itemLevel) ? m_AlchemyQualityLucks[itemLevel] : 0;
|
| | | Equation.Instance.AddKeyValue("qualityNeedLuck", qualityNeedLuck);
|
| | | return Equation.Instance.Eval<float>(alchemySuccRate);
|
| | | }
|
| | |
|
| | | public bool IsGraspRecipe(int alchemyId)
|
| | |
| | |
|
| | | public enum AlchemyType
|
| | | {
|
| | | Normal,
|
| | | Fairy,
|
| | | Normal = 1,
|
| | | Fairy = 2,
|
| | | }
|
| | |
|
| | | public struct AlchemyCount
|
| | | {
|
| | | public int min;
|
| | | public int max;
|
| | |
|
| | | public static readonly AlchemyCount one = new AlchemyCount()
|
| | | {
|
| | | min = 1,
|
| | | max = 1,
|
| | | };
|
| | | }
|
| | | } |
| | | |