using System; using System.Collections.Generic; using System.Linq; using UnityEngine; using Wizard.Battle; namespace Wizard; internal static class EnemyAIUtil { private class SelectableInfo { public List Cards; public int Count; public SelectableInfo(List cards, int count) { Cards = cards; Count = count; } } private static void SetupTargetsList(int depth, List currentList, List selectablesList, Dictionary> choiceSelectableList, List> out_targetsList, bool isFusion = false) { if (depth == selectablesList.Count) { out_targetsList.Add(new List(currentList)); return; } SelectableInfo selectableInfo = selectablesList[depth]; if (isFusion) { int num = (1 << selectableInfo.Cards.Count) - 1; for (int i = 1; i <= num; i++) { int num2 = i; int num3 = 0; for (int j = 0; j < selectableInfo.Cards.Count; j++) { BattleCardBase item = selectableInfo.Cards[j]; if (((num2 >> j) & 1) > 0) { currentList.Add(item); num3++; } } SetupTargetsList(depth + 1, currentList, selectablesList, choiceSelectableList, out_targetsList, isFusion: true); for (int k = 0; k < num3; k++) { currentList.RemoveAt(currentList.Count - 1); } } return; } List list = new List(); for (int l = 0; l < selectableInfo.Cards.Count; l++) { list.Add(l); } foreach (int[] item2 in AIMathematicsLibrary.EnumerateCombinations(list, selectableInfo.Count)) { BattleCardBase firstCard = selectableInfo.Cards[item2[0]]; bool flag = true; for (int m = 0; m < item2.Length; m++) { BattleCardBase card = selectableInfo.Cards[item2[m]]; if (currentList.Any((BattleCardBase c) => c.Index == card.Index && c.IsPlayer == card.IsPlayer)) { flag = false; } currentList.Add(card); } if (flag) { if (choiceSelectableList != null && choiceSelectableList.Any((KeyValuePair> p) => p.Key == firstCard.Index)) { if (choiceSelectableList[firstCard.Index] != null) { SetupTargetsList(0, currentList, choiceSelectableList[firstCard.Index], null, out_targetsList); } } else { SetupTargetsList(depth + 1, currentList, selectablesList, choiceSelectableList, out_targetsList); } } for (int num4 = 0; num4 < item2.Length; num4++) { currentList.RemoveAt(currentList.Count - 1); } } } public static void TurnEnd(BattleManagerBase mgr, bool isPlayer) { if (isPlayer) { mgr.VfxMgr.RegisterSequentialVfx(mgr.OperateMgr.PlayerTurnEnd()); } else { mgr.VfxMgr.RegisterSequentialVfx(mgr.OperateMgr.TurnEndOperation(isPlayer)); } } public static void SetupPlayCardSkillOptionValue(BattleCardBase playCard, BattlePlayerPair pair) { IEnumerable selectTypeSkill = playCard.GetSelectTypeSkill(); if (selectTypeSkill == null) { return; } foreach (SkillBase item in selectTypeSkill) { SkillCollectionBase.SetupOptionValue(item.OptionValue, pair, playCard, item); } } }