using System.Collections.Generic; namespace Wizard; public static class CardSkillHashUtility { public static int NEWEST_CARD_SKILL_HASH_VERSION = 1; public static ulong GetSkillHash(BattleCardBase card, int skillHashVersion) { return 0 + GetSkillCollectionHash(card.Skills) * 2591 + GetSkillApplyInformationHash(card.SkillApplyInformation, skillHashVersion) * 131; } private static ulong GetSkillCollectionHash(SkillCollectionBase skillCollection) { ulong num = 0uL; foreach (SkillBase item in skillCollection) { num += GetSingleSkillBaseHash(item); } return num; } public static List GetSingleSkillHashStringList(SkillCollectionBase skillCollection) { List list = null; foreach (SkillBase item in skillCollection) { list = AIParamQuery.AddElementToList(GetSingleSkillBaseHash(item).ToString(), list); } return list; } public static ulong GetSingleSkillBaseHash(SkillBase skill) { ulong num = 0uL; SkillCreator.SkillBuildInfo buildInfo = skill.SkillPrm.buildInfo; num += (ulong)((long)buildInfo._type.GetHashCode() * 6007L); num += (ulong)((long)buildInfo._timing.GetHashCode() * 17L); num += (ulong)((long)buildInfo._option.GetHashCode() * 47L); string text = ""; for (int i = 0; i < buildInfo._parsedConditionNew.Count; i++) { string text2 = buildInfo._parsedConditionNew[i]; if (i > 0) { text += "&"; } text += text2; } num += (ulong)((long)text.GetHashCode() * 107L); string text3 = ""; for (int j = 0; j < buildInfo._parsedTargetNew.Count; j++) { string text4 = buildInfo._parsedTargetNew[j]; if (j > 0) { text3 += "&"; } text3 += text4; } return num + (ulong)((long)text3.GetHashCode() * 227L); } private static ulong GetSkillApplyInformationHash(ISkillApplyInformation skillApplyInformation, int version) { ulong num = 0uL; if (version >= 1) { num += GetRepeatSkillTimingInfoHash(skillApplyInformation.RepeatSkillTimingList); } return num; } private static ulong GetRepeatSkillTimingInfoHash(List repeatSkillInfoList) { ulong num = 0uL; if (repeatSkillInfoList == null || repeatSkillInfoList.Count <= 0) { return num; } for (int i = 0; i < repeatSkillInfoList.Count; i++) { RepeatSkillInfo repeatSkillInfo = repeatSkillInfoList[i]; num += (ulong)((long)repeatSkillInfo.Timing.GetHashCode() * 37L); num += (ulong)((long)repeatSkillInfo.Target.GetHashCode() * 67L); num += GetSingleSkillBaseHash(repeatSkillInfo.Skill); num += (ulong)(repeatSkillInfo.IsRemoveReservation ? 127 : 0); } return num; } }