using CommonAI.Data; using CommonLang.Log; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using XmdsCommonServer.XLS.Data; using XmdsCommonSkill.Plugin.CardSkill; namespace XmdsCommonServer.Plugin.CardSkill.PlayerCardSkill { //下一次卡牌技能强化 public class JSNextCardSkillStrengthenhModule { protected static Logger sLog = LoggerFactory.GetLogger("JSNextCardSkillStrengthenhModule"); // 本次强化效果: 可能存在多个累加 private CardStrengthData[] mCardStrengthInfo = new CardStrengthData[(int)CardStrengthenType.Max + 1]; //下次强化加成 private List mStrengthenList = new List(); //---------------------------------------------- -------------------------------------------------------------------- //---------------------------------------------特殊效果数据记录-------------------------------------------------------- //------------------------------------------------------------------------------------------------------------------- public void Update(XmdsVirtual player) { for (int i = mStrengthenList.Count - 1; i >= 0; i--) { NextCardStrengthenInfo data = mStrengthenList[i]; if (data.validTime <= CommonLang.CUtils.localTimeMS || data.validTimes == 0) { //如果绑定buff if (data.bindBuffID > 0 && data.validTimes <= 0) { player.mUnit.removeBuff(data.bindBuffID); } mStrengthenList.RemoveAt(i); } } } public void Init() { for (int i = 0; i <= (int)CardStrengthenType.Max; i++) { if (mCardStrengthInfo[i] == null) { mCardStrengthInfo[i] = new CardStrengthData(); mCardStrengthInfo[i].data = new IntIntData(); } } } public void ReSet() { for (int i = 0; i <= (int)CardStrengthenType.Max; i++) { mCardStrengthInfo[i].type = CardStrengthenType.None; } this.mStrengthenList.Clear(); } public NextCardStrengthenInfo AddStrength(CardType type, CardStrengthenType strenghType, int value1, int value2, int validTime, int validTimes = -1, byte needSames = 0, DamageType dmgType = DamageType.None, CardLayerRule layerRules = null) { long validEndTime = validTime + CommonLang.CUtils.localTimeMS; //this.SetAllStrengthTimeByType(strenghType, validEndTime, validTimes); NextCardStrengthenInfo data = new NextCardStrengthenInfo(); data.layerRules = layerRules; data.pointCard = type; data.needSames = needSames; data.needDmgType = dmgType; data.type = strenghType; data.value1 = value1; data.value2 = value2; data.validTime = validEndTime; data.validTimes = validTimes; //data.bindBuffID = bindBuffID; do { if (data.layerRules == null) { break; } if (!data.layerRules.IsValid()) { sLog.Error("AddStrength异常:" + type + ", " + strenghType + ", " + data); return null; } NextCardStrengthenInfo oldData = this.GetStrengthInfoByUniqueID(data.layerRules.uniqueID); if (oldData == null) { break; } if (data.layerRules.layerType == CardLayerType.Replace) { //针对那种多个覆盖形式的 oldData.Replace(data); //System.Console.WriteLine("伤害覆盖:" + data.value2 + " -> " + oldData.value2); return oldData; } else if(data.layerRules.layerType == CardLayerType.Layers) { //针对叠层 oldData.AddLayers(data); //System.Console.WriteLine("伤害叠层:" + data.value2 + " -> " + oldData.value2); return oldData; } } while (false); this.mStrengthenList.Add(data); return data; } private NextCardStrengthenInfo GetStrengthInfoByUniqueID(int uniqueID) { foreach (NextCardStrengthenInfo info in this.mStrengthenList) { if (info.layerRules != null && info.layerRules.uniqueID == uniqueID) { return info; } } return null; } //private void SetAllStrengthTimeByType(CardStrengthenType strenghType, long validTime, int validTimes) //{ // 重置剩余层数的所有时间 // if (strenghType != CardStrengthenType.DmgLayer) // { // return; // } // for (int i = 0; i < mStrengthenList.Count; i++) // { // NextCardStrengthenInfo data = mStrengthenList[i]; // if (data.type == strenghType) // { // data.validTime = validTime; // data.validTimes = validTimes; // } // } //} //重置当前强化效果 public void TriggerSkillLoadStrength(CardSkillData skillData, int sameNums) { for (int i = 1; i < (int)CardStrengthenType.Max; i++) { if (this.GetStrengthInfo(skillData.type, (CardStrengthenType)i, sameNums, skillData.dmgType, mCardStrengthInfo[i].data)) { mCardStrengthInfo[i].type = (CardStrengthenType)i; } else { mCardStrengthInfo[i].type = CardStrengthenType.None; mCardStrengthInfo[i].data.ReSet(); } } } public IntIntData GetStrengthInfo(CardStrengthenType strgnthenType) { return mCardStrengthInfo[(int)strgnthenType].data; } //获得强化加成效果 private bool GetStrengthInfo(CardType cardType, CardStrengthenType strgnthenType, int sameNums, DamageType dmgType, IntIntData strengthenInfo) { //处理卡牌珠生成逻辑,优先处理最近的 bool process = false; for (int i = mStrengthenList.Count - 1; i >= 0; i--) { NextCardStrengthenInfo data = mStrengthenList[i]; if (data.pointCard != CardType.Max && data.pointCard != cardType) { continue; } else if (strgnthenType != data.type || data.validTime < CommonLang.CUtils.localTimeMS || data.validTimes == 0) { continue; } else if (data.needSames > 0 && sameNums < data.needSames) { continue; } else if (data.needDmgType != DamageType.None && data.needDmgType != dmgType) { continue; } if (data.validTimes > 0) { data.validTimes--; } //特殊模块的特殊处理 process = true; if (data.layerRules != null && data.layerRules.layerType == CardLayerType.Layers) { // 仅层数叠加 strengthenInfo.value1 = data.value1 * data.value2; strengthenInfo.value2 += data.value2; } else { strengthenInfo.value1 += data.value1; strengthenInfo.value2 += data.value2; } } return process; } } }