public void TakeTurn(Piece piece) { Square oldLoc = piece.getLocation(); diceValue = rollDice(); Square newLoc = board.getSquare(piece.getLocation(), diceValue); piece.setLocation(newLoc); if (newLoc.sell < oldLoc.sell) { PassedGo(); } if (newLoc.sell == 4) { Spend(400m); return; } if (newLoc.sell == 38) { Spend(100m); return; } if (newLoc.sell == 30) { GoToJail(piece); return; } if (newLoc.sell == 10 || newLoc.sell == 20 || newLoc.sell == 0) { return; } if (newLoc.sell == 2 || newLoc.sell == 7 || newLoc.sell == 17 || newLoc.sell == 22 || newLoc.sell == 33 || newLoc.sell == 36) { TakeAChance(); return; } if (!own.Contains(newLoc.sell)) { if (board.owned.Contains(newLoc.sell)) { Spend(newLoc.rent); GivenMoney = newLoc.rent; return; } if (!board.owned.Contains(newLoc.sell)) { if (AbleToSpend(newLoc.Cost)) { own.Add(newLoc.sell); Spend(newLoc.Cost); board.owned.Add(newLoc.sell); added = newLoc.name; PlayersStreets.Enqueue(newLoc); if (newLoc.color != null) { if (districts.ContainsKey(newLoc.color)) { districts[newLoc.color] += 1; } else { districts.Add(newLoc.color, 1); } } } return; } if (newLoc.color != null) { if (newLoc.company == false && newLoc.amountOfFileals < 4 && ((districts[newLoc.color] == 2 && (newLoc.color == "brown") || (newLoc.color == "dark blue")) || (districts[newLoc.color] == 3 && (newLoc.color != "brown" || newLoc.color != "dark blue")))) { newLoc = new Filial(newLoc); newLoc.amountOfFileals++; } else { if (newLoc.company == false && (districts[newLoc.color] == 2 && (newLoc.color == "brown") || (newLoc.color == "dark blue")) || (districts[newLoc.color] == 3 && (newLoc.color != "brown" || newLoc.color != "dark blue"))) { newLoc = new Company(newLoc); newLoc.company = true; newLoc.amountOfFileals = 0; } } } return; } return; }
public GoJailSquare(int index, Square jailSquare) : base(index, SQUARE_NAME+index) { this.jailSquare = jailSquare; Console.WriteLine("GO SQUARE is created at "+index); }
public void SetLocation(Square square) { piece.Location = square; }
public Square GetSquare(Square start, int distance) { var endIndex = (start.GetIndex() + distance) % _size; return((Square)_squares[endIndex]); }
public Square GetSquare(Square currentSquare, int dieFaceValues) { int nextIndex = (currentSquare.Index + dieFaceValues) % SQUARE_SIZE; return squares.ElementAt(nextIndex); }
public Piece(Square _square, string _name) { this.location = _square; this.name = _name; }