private void displayBattleCards(Card card1, Card card2) { _sb.Append("<br/>Battle Cards:"); _sb.Append(card1.Kind); _sb.Append("of"); _sb.Append(card1.Suit); _sb.Append("versus"); _sb.Append(card2.Kind); _sb.Append("of"); _sb.Append(card2.Suit); }
private void performEvaluation(Player player1, Player player2, Card card1, Card card2) { displayBattleCards(card1, card2); if (card1.CardValue() == card2.CardValue()) war(player1, player2); if (card1.CardValue() > card2.CardValue()) awardWinner(player1); else awardWinner(player2); }
public void GetCards() { List<Card> Cards = new List<Card>(); string[] filePath = Directory.GetFiles(HttpContext.Current.Server.MapPath("/Cards"), "*.png"); int i = 0; while (i < filePath.Count()) { foreach (var path in filePath) { Card card = new Card(); Cards.Add(card); Cards[i].file = path; //Here indexFRom is returning -1 int indexFrom = path.LastIndexOf("_"); int indexTo = path.LastIndexOf(".png"); Cards[i].suit = path.Substring(indexFrom+1, indexTo- indexFrom -1); i++; } } }
protected List<Card> GetCards() { List<Card> tmpCards = new List<Card>(); string[] filePath = Directory.GetFiles(HttpContext.Current.Server.MapPath("/Cards"), "*.png"); int i = 0; while (i < filePath.Count()) { foreach (var path in filePath) { Card card = new Card(); var shortPath = path.Substring(path.LastIndexOf("\\") + 1); TextInfo textInfo = new CultureInfo("en-US", false).TextInfo; tmpCards.Add(card); tmpCards[i].file = path; string[] delimiters = { "_", ".png" }; string[] cardIdArray = shortPath.Split(delimiters, StringSplitOptions.RemoveEmptyEntries); tmpCards[i].suit = textInfo.ToTitleCase(cardIdArray[2]); tmpCards[i].name = textInfo.ToTitleCase(cardIdArray[0]) + " " + cardIdArray[1] + " " + tmpCards[i].suit; try { tmpCards[i].value = Int32.Parse(cardIdArray[0]); } catch { switch (cardIdArray[0].ToLower()) { case "ace": tmpCards[i].value = 14; break; case "king": tmpCards[i].value = 13; break; case "queen": tmpCards[i].value = 12; break; case "jack": tmpCards[i].value = 11; break; } } i++; } } return tmpCards; }