public override int GetRent(Player player) { print("Desarrollar el método que calcule la renta de una propiedad privada"); PropertyCard card = (PropertyCard)this.gameCard; return(card.rent); }
public static bool TradeOfferDecide(Card item, float money, Cards.PropertyManager pm, AIPlayer player) { if (item is PropertyCard) { PropertyCard propCard = (PropertyCard)item; float requiredMoney = (3 + player.dangerFactor) * propCard.Cost; if (!(pm.OwnsWholeGroup(item.Group, player))) { if (money > requiredMoney) { return(true); } } } else if (item is BonusCard) { if (money > (2 + player.dangerFactor) * item.Cost) { return(true); } } else { if (money > (1.5 + 2 * player.dangerFactor) * item.Cost) { return(true); } } return(false); }
private async void Start() { try { var response = await ApiWrapper.GamePrices(); var propertyPricesArray = (JArray)response["properties"]; propertiesList = new List <PropertyCard>(propertyPricesArray.Count); stationsList = new List <StationCard>(propertyPricesArray.Count); utilitiesList = new List <UtilityCard>(propertyPricesArray.Count); foreach (var property in propertyPricesArray) { var propertyName = property["name"].ToString(); var color = property["color"]?.ToString(); var location = (int)property["location"]; var rents = ((JArray)property["rents"]).Select(rent => (int)rent).ToArray(); var mortgage = (int)property["mortgage"]; var type = (int)property["type"]; switch (type) { case 0: { var houseCosts = (JArray)response["houses"]; var houseCost = (int)houseCosts[location / 10]; var card = new PropertyCard(propertyName, color, location, rents, houseCost, mortgage); propertiesList.Add(card); break; } case 1: { var card = new StationCard(propertyName, location, rents, mortgage); stationsList.Add(card); break; } default: { var card = new UtilityCard(propertyName, location, rents, mortgage); utilitiesList.Add(card); break; } } } } catch (Exception e) { Debug.Log(e); // TODO: Show error to player } }
private void Start() { APIWrapper.Instance.GamePrices((response, error) => { if (error == null) { var propertyPricesArray = (JArray) response["properties"]; propertiesList = new List<PropertyCard>(propertyPricesArray.Count); stationsList = new List<StationCard>(propertyPricesArray.Count); utilitiesList = new List<UtilityCard>(propertyPricesArray.Count); foreach (var property in propertyPricesArray) { var name = property["name"].ToString(); var color = property["color"]?.ToString(); var location = (int) property["location"]; var rents = ((JArray) property["rents"]).Select(rent => (int) rent).ToArray(); var mortgage = (int) property["mortgage"]; var type = (int) property["type"]; switch (type) { case 0: { var houseCosts = (JArray) response["houses"]; var houseCost = (int) houseCosts[location / 10]; var card = new PropertyCard(name, color, location, rents, houseCost, mortgage); propertiesList.Add(card); break; } case 1: { var card = new StationCard(name, location, rents, mortgage); stationsList.Add(card); break; } default: { var card = new UtilityCard(name, location, rents, mortgage); utilitiesList.Add(card); break; } } } } else { throw new Exception(error); } }); }
public List <PropertyCard> GetPropertyCards() { List <PropertyCard> properties = new List <PropertyCard>(); for (int i = 1; i <= 28; i++) { PropertyCard propertyCard = new PropertyCard() { Name = "Card " + i.ToString(), Value = i }; properties.Add(propertyCard); } return(properties); }
/** * AIPlayer deciding logics. It evaluates which card is the AIPlayer most likely to want to buy. * It takes into consideration, that: * - Agency Cards are the most wanted * - Bonus Cards have 2nd highest priority * - PropertyCards of Highest (most expensive group) have higher priority than the cheaper ones * (unless they cannot afford the expensive ones) */ public Card GetTradeCard(AIPlayer player) { AgencyCard agency = WantsAgency(player); if (agency != null && agency.Cost < player.Money && WhoOwns(agency) != null) { return agency; } BonusCard bonus = WantsBonus(player); if (bonus != null && bonus.Cost < player.Money && WhoOwns(bonus) != null) { return bonus; } PropertyCard property = WantsProperty(player); if (property != null && property.Cost < player.Money && WhoOwns(property) != null) { return property; } return null; }
public IEnumerator DisplayCard(int location) { if (GameManager.Instance.Game.CurrentPlayerId == AuthenticationManager.Instance.user.Id) { _buy.SetActive(true); _abandon.SetActive(true); } if (location == 5 || location == 15 || location == 25 || location == 35) { List <StationCard> stationCards = _cardLoader.stationsList; StationCard stationCard = stationCards[0]; foreach (StationCard card in stationCards) { if (card.location == location) { stationCard = card; } } _cards.SetActive(true); GameObject stCard = _cardsList[1]; stCard.SetActive(true); stCard.transform.Find("Name").gameObject.GetComponent <TextMeshProUGUI>().text = stationCard.name; for (int i = 0; i < stationCard.rents.Length; i++) { stCard.transform.Find("Rent" + i).gameObject.GetComponent <TextMeshProUGUI>().text = stationCard.rents[i].ToString(); } stCard.transform.Find("MortgageText").gameObject.GetComponent <TextMeshProUGUI>().text = stationCard.mortgage.ToString(); } else if (location == 12) { List <UtilityCard> utilityCards = _cardLoader.utilitiesList; UtilityCard utilityCard = utilityCards[0]; _cards.SetActive(true); GameObject uCard1 = _cardsList[2]; uCard1.SetActive(true); uCard1.transform.Find("MortgageText").gameObject.GetComponent <TextMeshProUGUI>().text = utilityCard.mortgage.ToString(); } else if (location == 28) { List <UtilityCard> utilityCards = _cardLoader.utilitiesList; UtilityCard utilityCard = utilityCards[0]; _cards.SetActive(true); GameObject uCard2 = _cardsList[3]; uCard2.SetActive(true); uCard2.transform.Find("MortgageText").gameObject.GetComponent <TextMeshProUGUI>().text = utilityCard.mortgage.ToString(); } else { List <PropertyCard> propertyCards = _cardLoader.propertiesList; PropertyCard propertyCard = propertyCards[0]; foreach (PropertyCard card in propertyCards) { if (card.location == location) { propertyCard = card; } } _cards.SetActive(true); foreach (GameObject card in _cardsList) { if (card.name != "PropertyCard") { card.SetActive(false); } else { card.SetActive(true); Color color; ColorUtility.TryParseHtmlString("#" + propertyCard.color, out color); card.transform.Find("Colour").gameObject.GetComponent <Image>().color = color; card.transform.Find("Name").gameObject.GetComponent <TextMeshProUGUI>().text = propertyCard.name; for (int i = 0; i < propertyCard.rents.Length; i++) { card.transform.Find("Rent" + i).gameObject.GetComponent <TextMeshProUGUI>().text = propertyCard.rents[i].ToString(); } card.transform.Find("BookCostText").gameObject.GetComponent <TextMeshProUGUI>().text = propertyCard.houseCost.ToString(); card.transform.Find("DegreeCostText").gameObject.GetComponent <TextMeshProUGUI>().text = propertyCard.houseCost.ToString(); card.transform.Find("MortgageText").gameObject.GetComponent <TextMeshProUGUI>().text = propertyCard.mortgage.ToString(); } } } yield return(new WaitForSeconds(5f)); Abandon(); }
public void EnterPropertyHuntScreeUI(PropertyCard cardLeft, PropertyCard cardCenter, PropertyCard cardRight) { leftTitle.text = cardLeft.Title; leftAddressProp.text = cardLeft.Address; leftPriceProp.text = string.Format("{0:C}", cardLeft.Price); leftDiffProp.text = cardLeft.Difficulty.ToString(); leftPicProp.GetComponent<Image>().sprite = cardLeft.Pic; centerTitle.text = cardCenter.Title; centerAddressProp.text = cardCenter.Address; centerPriceProp.text = string.Format("{0:C}", cardCenter.Price); centerDiffProp.text = cardCenter.Difficulty.ToString(); centerPicProp.GetComponent<Image>().sprite = cardCenter.Pic; rightTitle.text = cardRight.Title; rightAddressProp.text = cardRight.Address; rightPriceProp.text = string.Format("{0:C}", cardRight.Price); rightDiffProp.text = cardRight.Difficulty.ToString(); rightPicProp.GetComponent<Image>().sprite = cardRight.Pic; }
public void SetConfirmText(PropertyCard cardChoice) { confirmPropText.text = "Are you sure you want to select the " + cardChoice.Title + " property?"; }
// Property hunt functions ------------------------------------------------ public void EnterPropertyHuntScreen (Button loanInProgressButton) { if (player.CurrentProperty != null) { loanInProgressButton.interactable = true; } else { loanInProgressButton.interactable = false; } int randLeft = Random.Range(0, cardsPropertyHunt.Count); int randCenter = Random.Range(0, cardsPropertyHunt.Count); int randRight = Random.Range(0, cardsPropertyHunt.Count); if (randLeft == randRight) { if (randRight < cardsPropertyHunt.Count) { randRight++; } else { randRight--; } } cardLeft = cardsPropertyHunt[randLeft]; cardCenter = cardsPropertyHunt[randCenter]; cardRight = cardsPropertyHunt[randRight]; while (cardLeft.Difficulty != "Easy") { randLeft = Random.Range(0, cardsPropertyHunt.Count); cardLeft = cardsPropertyHunt[randLeft]; } while (cardCenter.Difficulty != "Medium") { randCenter = Random.Range(0, cardsPropertyHunt.Count); cardCenter = cardsPropertyHunt[randCenter]; } while (cardRight.Difficulty != "Hard") { randRight = Random.Range(0, cardsPropertyHunt.Count); cardRight = cardsPropertyHunt[randRight]; } uiController.EnterPropertyHuntScreeUI(cardLeft, cardCenter, cardRight); }