public void DecideMove(List <Player> players, List <Enemy> enemies) { if (!IsConscious) { return; } SelectedTargets.Clear(); SelectedSkill = Skills.Count > 0 ? Skills[RandInt(0, Skills.Count - 1)] : null; SelectedItem = null; SelectedWeapon = Weapons.Count > 0 && SelectedSkill != null && SelectedSkill.IsOffense() ? Weapons[RandInt(0, Weapons.Count - 1)] : null; SelectedTargets.Add(players[RandInt(0, players.Count - 1)]); }
// Helper function for RedirectUnconsciousTarget private void RedirectRandomScope <T>(List <T> opponents, int toReplace) where T : Battler { while (toReplace > 0) { T newTarget = RandList(opponents); if (!newTarget.IsConscious) { continue; } SelectedTargets.Add(newTarget); toReplace--; } }
public override bool TryToAddTarget(object target) { if (!WaitForTarget) { if (RemainingCost != null) { if (RemainingCost.RequiredTargetCount > 0 && target is CardInstance) { CardInstance cat = target as CardInstance; RemainingCost = RemainingCost.Pay(ref cat, CardSource); if (cat == null) { return(true); } } } return(false); } if (target is CardInstance) { CardInstance ci = target as CardInstance; if (ci.BindedAction != null) { target = ci.BindedAction; } } //other target group are possible, should change foreach (Target ct in ValidTargets) { if (ct.Accept(target, CardSource)) { if (Source.Effects.AcceptTarget(target)) { SelectedTargets.Add(target); return(true); } } } Magic.AddLog("Invalid target: " + target.ToString()); return(false); }
// Helper function for RedirectUnconsciousTarget private void RedirectScopeSplash <T>(List <T> opponents, int i) where T : Battler { T newTarget = opponents[i]; SelectedTargets.Clear(); SelectedTargets.Add(newTarget); foreach (T oneTarget in opponents) { int xDist = Math.Abs(oneTarget.XPosition - newTarget.XPosition); int zDist = Math.Abs(oneTarget.ZPosition - newTarget.ZPosition); if (xDist > 1 && zDist > 1) { continue; } if (xDist != 0 || zDist != 0) { SelectedTargets.Add(newTarget); } } }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// -- Tool Pre-Actions -- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public bool RedirectUnconsciousTarget <T>(List <T> opponents) where T : Battler { int i; int removed = 0; bool removedMain = false; for (i = 0; i < SelectedTargets.Count; i++) { if (SelectedTargets[i].IsConscious) { continue; } SelectedTargets.RemoveAt(i); removed++; if (i == 0) { removedMain = true; } } if (SelectedTargets.Count > 0) { return(true); } i = 0; int scope = 0; int randomActs = 0; if (SelectedSkill != null) { scope = SelectedSkill.Scope; } else if (SelectedItem != null) { scope = SelectedItem.Scope; } if (SelectedSkill != null) { randomActs = SelectedSkill.RandomActs; } else if (SelectedItem != null) { randomActs = SelectedItem.RandomActs; } switch (scope) { case 1: case 2: while (i < opponents.Count && !opponents[i].IsConscious) { i++; } if (i == opponents.Count) { return(false); } if (scope == 1 && randomActs > 0) { RedirectRandomScope(opponents, removed); } else if (scope == 2 && removedMain) { RedirectScopeSplash(opponents, i); } else { SelectedTargets.Add(opponents[i]); } break; case 3: case 4: int redirected = -1; for (i = 0; i < opponents.Count; i++) { int pos = scope == 3 ? opponents[i].XPosition : opponents[i].ZPosition; if (!opponents[i].IsConscious || redirected >= 0 && redirected != pos) { continue; } SelectedTargets.Add(opponents[i]); redirected = pos; } break; } return(true); }