private static void Trace(PokemonProxy pm) { var pms = new List <PokemonProxy>(); foreach (var p in pm.Controller.Board[1 - pm.Pokemon.TeamId].GetAdjacentPokemonsByOppositeX(pm.OnboardPokemon.X)) { if (ATs.Trace(p.OnboardPokemon.Ability)) { pms.Add(p); } } var n = pms.Count; if (n != 0) { pm.RaiseAbility(); var target = pms[pm.Controller.GetRandomInt(0, n - 1)]; pm.ChangeAbility(target.OnboardPokemon.Ability); pm.Controller.ReportBuilder.ShowLog("Trace", target.Id, target.OnboardPokemon.Ability); } }