/// <summary> /// Method that will return any possible mills that will be made by a player by placing or moving a cow to 'pos' (excluding any mills they already have) /// </summary> /// <param name="pos">Position that will potentially make a mill</param> /// <returns>List of mills made represented as Array of Positions</returns> /* * NOTE: This method needs to be called before a cow is added to a players cow list so as to check if any mills will be made by the player this makes it so that * there is no need to keep track of the players previous state and next state. */ public IEnumerable <IEnumerable <IPosition> > GetMills(IPosition p) { Position Pos = (Position)p; List <Position[]> possibleMills = (List <Position[]>)tmpPos.GetPossibleMills(Pos.pos); List <Position[]> finalMills = new List <Position[]>(); //filter out mills i already have foreach (var mill in possibleMills) { if (!(MyMills.Contains(mill))) { finalMills.Add(mill); } } Cows.Add(Pos); //temporarily add cow to accurrately filter cows //filter out mills that i don't have the cows for foreach (var mill in possibleMills) { if (!(Cows.Contains(mill[0]) && Cows.Contains(mill[1]) && Cows.Contains(mill[2]))) { finalMills.Remove(mill); } } Cows.Remove(Pos); //remove temporary cow return(finalMills); }
/// <summary> /// Initializes from list. /// </summary> /// <param name="player"></param> /// <param name="controller"></param> public override void Initialize(Player player, GameController controller) { cows = new List <Cow>(); foreach (var cowInfo in AppCore.AttackSettings.Cows) { if (string.IsNullOrEmpty(cowInfo.UserName)) { continue; } var farmCows = ObjectProvider.Instance.GetCowsByName(cowInfo.UserName); if (farmCows.Count == 0) { farmCows = AddNewCow(cowInfo.UserName, controller, player); } foreach (var cow in farmCows) { cow.MilkingCoulomb = cowInfo.Coulomb; cow.RivalHealth = 1000; cow.RivalInjuryHealth = 1000; Cows.Add(cow); } } FillResults(controller); }
/// <summary> /// Method that 'moves cows' by taking in two positions (Old position and New Position) and removes oldPos from players current cows and adds newPos to players current cows /// </summary> /// <param name="oldPos">Cow to remove </param> /// <param name="newPos">Cow to add</param> public void MoveCow(IPosition oPos, IPosition nPos) { Position oldPos = (Position)oPos; Position newPos = (Position)nPos; ShootCow(oldPos); Cows.Add(newPos); }