public GameLogic() { m_propertySequence = new List<Property>(); m_playerList = new List<Player>(); m_chanceList = new List<Chance>(); m_currentPlayer = null; m_currentPlayerIndex = -1; m_doubleCount = 0; LoadPropertySequence(); LoadPropertyGroups(); LoadRandomizedChanceList(); }
public Boolean BuyHouse(Property prop, Player player) { int buildingValue = (int)prop.BuildingValue; //verifica se o jogador possui o dinheiro suficiente ou se já comprou as casas todas if ((player.Money < buildingValue) || prop.NumHouses >= 5) return false; player.UpdateMoney(-buildingValue); prop.NumHouses++; return true; }
private int? m_value; //valor da compra #endregion Fields #region Constructors public Property(PropertyType type, String desc, int? value, int? charge, int? house1, int? house2, int? house3, int? house4, int? hotel, int? buildingValue) { m_type = type; m_description = desc; m_value = value; m_owner = null; m_numHouses = 0; m_charge = charge; m_chargeHouse1 = house1; m_chargeHouse2 = house2; m_chargeHouse3 = house3; m_chargeHouse4 = house4; m_chargeHotel = hotel; m_buildingValue = buildingValue; }
public void AddPlayer(TcpClient client, String name) { Player player = new Player(150000, name, client); m_playerList.Add(player); }
public Boolean UpdateCurrentPlayer() { if (m_doubleCount > 0) return false; // Não é necessário atualizar o current player, porque ele tem que voltar a jogar while (true) { //atualiza currentPlayer para o player seguinte //se o seguinte for o ultimo da lista +1, currentPlayer é definido como o primeiro da lista:0 m_currentPlayerIndex = (m_currentPlayerIndex + 1) % m_playerList.Count; m_currentPlayer = m_playerList[m_currentPlayerIndex]; //verifica se o PROXIMO jogador está bloqueado e atualiza o nº de vezes q/ deve ficar retido if (m_currentPlayer.JailCount > 0) { m_currentPlayer.JailCount--; } //se o proximo jogador nao estiver bloqueado, pode jogar (currentPlayer ja foi atualizado) else break; } return true; }
public Boolean SellProperty(Player player, Property prop) { switch (prop.Type) { case Property.PropertyType.PROPERTY: { PropertyGroup group = prop.Group; foreach (Property property in group.PropertyList) { if (property.NumHouses > 0) { return false; } } player.BoughtProperty.Remove(prop); break; } case Property.PropertyType.TRAIN: player.NumTrains--; break; case Property.PropertyType.COMPANY: player.NumCompanys--; break; } int propValue = (int)prop.Value; player.UpdateMoney((int)(propValue * 0.5)); prop.Owner = null; return true; }
public void SellHouse(Property prop, Player player) { int buildingValue = (int)prop.BuildingValue; player.UpdateMoney((int)(buildingValue * 0.5)); if (prop.NumHouses == 5) prop.NumHouses = 0; else if (prop.NumHouses > 1) prop.NumHouses--; else prop.NumHouses = 0; }