public Node(string pos, List <string> friends)// friends are the neighbouring nodes { Position = pos; occupied = false; neighbours = friends; Cow = null; }
public Player(Phase playerPhase, int unplaced, ICow playerColour) { this.playerPhase = playerPhase; this.unplaced = unplaced; this.placed = 0; this.playerCow = playerColour; HasLost = false; }
public Player(Phase playerPhase, int placed, int unplaced, Cow playerColour)// player constructor { this.playerPhase = playerPhase; this.unplaced = unplaced; this.placed = placed; this.playerCow = playerColour; HasLost = false; }
public void GiveCowName(string x) { CowsAlive[0].changePosition(x); ICow temp = CowsAlive[0]; CowsAlive.RemoveAt(0); CowsAlive.Add(temp); }
public ICow TakeCow(Color c) { ICow cow = Cows.First(x => x.Color == c); List <ICow> list = Cows.ToList(); list.Remove(cow); Cows = list.ToArray(); return(cow); }
// apply extension method to a custom interface public static decimal TotalPrice(this ICow cow) { decimal price = 0; price += cow?.Weight ?? 0; price += cow?.MilkVolume() ?? 0; price += 1000M; return(price); }
private bool CheckMillAgainstBoard(IMill mill, ICow cow)//checks a specified possible mill against a type of cow to see if a mill has been created { bool check = true; List <int> list = mill.ToList(); foreach (int i in list) { check = check && GetNode(i) == cow; } return(check); }
public bool Place(int position, IBoard board, IReferee referee, Phase currPhase) { if (referee.CanPlace(Color, position, currPhase)) { ICow cow = Box.TakeCow(Color); board.Place(cow, position); return(true); } else { return(false); } }
public bool CheckIndexForMill(int index, IPlayer player)//Takes a node index and a player to see if that player has a mill from that node { ICow cow = player.GetCow(); IMills mills = this.mills.GetMillsByIndex(index); foreach (Mill mill in mills.GetMills()) { if (CheckMillAgainstBoard(mill, cow)) { currentMills.Add(mill); return(true); } } return(false); }
public static void MoveCreatesNoDuplicates(int pos, int[] moves) { foreach (int move in moves) { IBoard b = new Board(); ICowBox box = new CowBox(); IReferee r = new Referee(b, box); b.Place(new Cow(-1, Color.Red), pos); b.Move(pos, move); ICow oldPosition = b.Occupant(pos); Assert.That(oldPosition.Color == Color.Black); Assert.That(b.numCowsOnBoard() == 1); } }
public void PlaceCow(ICow cow, string position) { throw new NotImplementedException(); }
// Create an array of default cows public void initialiseCows() { Cows = new ICow[24]; Cows = Cows.Select((x, index) => new Cow(index, Color.Black)).ToArray(); }
public void removeCow() { Cow = null; occupied = false; }
public void MillFormed(ICow cow) { throw new NotImplementedException(); }
public Milk(ICow cow, IFarmer farmer) { }
public void addCow(ICow cow) { Cow = cow; occupied = true; }
public RoastBeef(IButcher butcher, ICow cow) { }
public Salami(IPig pig, ICow cow, IButcher butcher) { }
public void Place(ICow Cow, int Destination) { Cows[Destination] = Cow; UpdateMills(); }
public void SetNode(int index, ICow cow)// sets the value of a node to the given cow value { nodes[index] = cow ?? throw new ArgumentOutOfRangeException(nameof(index)); }