// Analyze an individual card. private void PostAnalyzeCard(int cardIndex) { UpCard card = (UpCard)_cards[cardIndex]; if (card.RenderAsMenu) { // If the card is the last card, and has only // one anchor that can be mapped to a softkey, // ignore the if (card.AnchorCount == 1 && cardIndex == _cards.Count - 1 && card.SoftkeysUsed == 1) { card.RenderAsMenu = false; } // If the card has a lot of static content followed by // a number of links, don't render it as a menu card, // because the card would scroll off the static content // to get to the menu. else if (card.StaticItemsWeight >= 3 * _screenWidth) { card.RenderAsMenu = false; } } }
private void RenderCardOpening(int cardIndex) { UpCard card = (UpCard)_cards[cardIndex]; if (card.RenderAsMenu) { } else { // Render softkeys if (card.HasNonStaticElements) { for (int i = 0; i < card.SoftkeysUsed; i++) { RenderSoftkey(i == 0 ? "accept" : "options", card.Softkeys[i]); } } else if (cardIndex == _cards.Count - 1) { // Render the last card with an extra <do>, so that // it overrides the default function of the OK button, // which is to go back a screen. //EnsureLayout(); Write("<do type=\"accept\"><noop /></do>"); } } }
private UpCard AllocateNewCard() { UpCard card = new UpCard(); card.Softkeys = new UpSoftkey[NumberOfSoftkeys]; _cards.Add(card); return(card); }
private void DisplayCards() { Card1.DisplayCard(game.PlayerHand[0].CardName); Card2.DisplayCard(game.PlayerHand[1].CardName); Card3.DisplayCard(game.PlayerHand[2].CardName); Card4.DisplayCard(game.PlayerHand[3].CardName); Card5.DisplayCard(game.PlayerHand[4].CardName); Card6.DisplayCard(game.PlayerHand[5].CardName); Card7.DisplayCard(game.PlayerHand[6].CardName); Card8.DisplayCard(game.PlayerHand[7].CardName); UpCard.DisplayCard(game.upFacedCard.CardName); BackCard.DisplayCard("DC"); }
private void BeginNextCard() { if (AnalyzeMode) { // Add a softkey on the current card, to go to the new card. String nextCardId = "card" + (_currentCardIndex + 1).ToString(CultureInfo.InvariantCulture); UpHyperlinkSoftkey softkey = new UpHyperlinkSoftkey(); softkey.TargetUrl = "#" + nextCardId; softkey.EncodeUrl = false; softkey.Label = "OK"; SetPrimarySoftkey(softkey); CurrentCard.AnchorCount = _currentCardAnchorCount; UpCard card = AllocateNewCard(); card.Id = nextCardId; _currentCardIndex++; } else { RenderCardClosing(_currentCardIndex); CloseParagraph(); WriteEndTag("card"); WriteLine(); _currentCardIndex++; _lastAlignment = Alignment.Left; _lastWrapping = Wrapping.NoWrap; WriteBeginTag("card"); WriteAttribute("id", CurrentCard.Id); String formTitle = CurrentForm.Title; if (formTitle != null && formTitle.Length > 0) { WriteTextEncodedAttribute("title", formTitle); } WriteLine(">"); RenderCardOpening(_currentCardIndex); } _currentCardAnchorCount = 0; _currentCardPostBacks = 0; _currentCardSubmits = 0; }
private void RenderCardClosing(int cardIndex) { UpCard card = (UpCard)_cards[cardIndex]; if (cardIndex < _cards.Count - 1 && !card.NoOKLink) { // Add a link to go to the next card. UpCard nextCard = (UpCard)_cards[cardIndex + 1]; String OkLabel = SR.GetString(SR.WmlMobileTextWriterOKLabel); RenderBeginHyperlink("#" + nextCard.Id, false, OkLabel, true, true); RenderText(OkLabel); RenderEndHyperlink(true); } if (card.RenderAsMenu) { CloseMenu(); } }
//Sets Computer card private async Task ComputerTurnAsync() { Moves.Text = "COMPUTER IS CHOOSING"; await Task.Delay(1000); game.SetComputerCard(); UpCard.DisplayCard(game.upFacedCard.CardName); whosTurn = WhosTurn.Player; if (game.ComputerSelection.CardNumber == "1" || game.ComputerSelection.CardNumber == "8") { whosTurn = WhosTurn.Computer; await ComputerTurnAsync(); } else { whosTurn = WhosTurn.Player; } }
/// <include file='doc\UpWmlMobileTextWriter.uex' path='docs/doc[@for="UpWmlMobileTextWriter.PostAnalyzeForm"]/*' /> protected override void PostAnalyzeForm() { base.PostAnalyzeForm(); for (int i = 0; i < _cards.Count; i++) { PostAnalyzeCard(i); } // If the last card ends with an input element and an anchor // then use the anchor as a do tag to submit the form, and // don't render as a separate anchor (otherwise, the user would // see an extra screen at the end with a single anchor) UpCard lastCard = CurrentCard; if (lastCard.HasInputElements && _currentCardAnchorCount >= 1 && _currentCardAnchorCount <= Device.DefaultSubmitButtonLimit) { lastCard.UsesDefaultSubmit = true; } }
private UpCard AllocateNewCard() { UpCard card = new UpCard(); card.Softkeys = new UpSoftkey[NumberOfSoftkeys]; _cards.Add(card); return card; }
private async System.Threading.Tasks.Task AfterTap(object sender, int index) { BackCard.IsEnabled = false; Moves.Text = ""; Moves.Foreground = new SolidColorBrush(Colors.White); if (index == 9)//9 = Draw from Deck { game.Draw(); UpCard.DisplayCard(game.upFacedCard.CardName); if (game.upFacedCard.CardNumber == "1") { Moves.Text = "YOU DREW AN ACE! COMPUTER TURN SKIPPED, GO AGAIN."; whosTurn = WhosTurn.Player; } else if (game.upFacedCard.CardNumber == "8") { Moves.Text = "YOU DREW A WILDCARD! CHOOSE A NEW CARD WITH A DESIRED SUIT!"; whosTurn = WhosTurn.Player; } else { whosTurn = WhosTurn.Computer; } } else { if (whosTurn == WhosTurn.Player) { //Checks if players card is valid or not if (game.ValidatePlay(game.PlayerHand[index]) == 0) { Moves.Text = "YOU CANNOT CHOOSE THIS CARD"; Moves.Foreground = new SolidColorBrush(Colors.Maroon); await Task.Delay(700); Moves.Text = ""; } else { //If valid checks for special cards if (game.ValidatePlay(game.PlayerHand[index]) == 8)//Card is eight { Moves.Text = "WILDCARD! CHOOSE A NEW CARD WITH A DESIRED SUIT!"; whosTurn = WhosTurn.Player; } else if (game.ValidatePlay(game.PlayerHand[index]) == 2)//Card is one { Moves.Text = "COMPUTER TURN SKIPPED, GO AGAIN."; whosTurn = WhosTurn.Player; } else if (game.ValidatePlay(game.PlayerHand[index]) == 1)// Card is regular { whosTurn = WhosTurn.Computer; } userCardsChosen += 1; //Keep count of player cards chosen game.SetUserCard(game.PlayerHand[index]); // CHANGES THE UPFACED CARD TO USER CARD UpCard.DisplayCard(game.upFacedCard.CardName); PlayingCards cardUsed = (PlayingCards)sender; cardUsed.DisplayCard("BC"); cardUsed.IsEnabled = false; //Makes the chosen card unclickable if (userCardsChosen == 8) // if player plays all eight cards they win { game.GameOver("PLAYER"); } } } } // Computer's turn if (whosTurn == WhosTurn.Computer && userCardsChosen != 8) { await ComputerTurnAsync(); Moves.Text = game.ComputerMoves; } BackCard.IsEnabled = true; //Displays winner if there is one if (game.Winner != null) { DisableCards(); Moves.Text = game.Winner; Moves.Foreground = new SolidColorBrush(Colors.Gold); } }