/// <summary> /// Functionality to buy a card from the market /// </summary> /// <param name="costOfCard"></param> public void Buy(int costOfCard) { if (activeHand.CardSelected == false) { //check for adequate gold and Action points if (GoldManager.instance.canBuy(costOfCard) && apm.GetActionPointsAvailable() > 0) { //make a copy of the gameobject and store it in newcard so that we can edit on the fly if needed GameObject newCard = gameObject; //deals with the deck card (face down card) if (costOfCard == costOfDeckCard) { //ensure the new card isn't a passive that is in play newCard = market.DealRandomCardUniquePassives(); //passiveHand.HandleCard(newCard); market.AssignMarketCardTag(newCard); gameObject.tag = newCard.tag; } //check for an open slot in the respective hand if (gameObject.tag == "Card_Active") { HandleHand("Hand_Active", costOfCard, newCard); } else if (gameObject.tag == "Card_Passive") { HandleHand("Hand_Passive", costOfCard, newCard); } if (GoldManager.instance.GetGoldAmount() <= 5) { ActionPointManager.instance.SetEndTurnButton(true, Color.red, Color.red); } } else { //tell user they can't afford this card or don't have enough AP if (GoldManager.instance.GetGoldAmount() < costOfCard) { Console.instance.WriteToConsole("Not enough gold"); } else if (ActionPointManager.instance.GetActionPointsAvailable() <= 0) { Console.instance.WriteToConsole("Not enough AP"); } } } }