// use a card from hand public async Task handCall(TextBlock tb, InGame iG, TextBlock usrScr) { //can only use a card if the card is still there if (this.Stndng == false && this.IsTrn && !tb.Text.Equals("")) { //grab the value of the card from the selected card's textBlock int val = Convert.ToInt16(tb.Text); Card crd = null; //searching hand array to find User's selected card, //place that card on the table, mark as used for (int i = 0; i < this.Hand.Length; i++) { if (this.Hand[i].Val == (val)) { //found card crd = this.Hand[i]; this.Hand[i].IsUsed = true; break; } } //play the hand card playCard(crd, false, usrScr); iG.printHandCard(TrnCnt, crd.Val, this); //checking score, user will automatically stand or bust if score is 20 or more after a hand card autoBust(iG); //no need for that pesky card value to stay on screen anymore tb.Text = ""; } }
//take card from deck, animate to table private async Task deckDeal(InGame iG, Queue<Card> deck) { Card c = deck.Dequeue(); prcesCrd(c); await(iG.srchGrid(this)); iG.txtCardVal(c.Val, this); }
//take card from deck, animate to table private async Task deckDeal(InGame iG, Queue <Card> deck) { Card c = deck.Dequeue(); prcesCrd(c); await(iG.srchGrid(this)); iG.txtCardVal(c.Val, this); }
//process a card from the hand, make it dissapear from side, and appear on table private async Task handDeal(int hndNum, InGame iG) { if (this.Hand[hndNum].IsUsed == false) { prcesCrd(this.Hand[hndNum]); //animate hand card await iG.srchGrid(this); setHnd(hndNum); iG.printHandCard(this.TrnCnt, Hand[hndNum].Val, this); } }
//user gets card from deck public async void deckCall(Boolean b, TextBlock usrScr, InGame iG, Queue<Card> deck) { //the top card is taken from the deck Card crd = deck.Dequeue(); //that card is played playCard(crd, b, usrScr); //card is then animated to the screen await iG.srchGrid(this); //value of card is displayed in the image of the card iG.txtCardVal(crd.Val, this); }
//user gets card from deck public async void deckCall(Boolean b, TextBlock usrScr, InGame iG, Queue <Card> deck) { //the top card is taken from the deck Card crd = deck.Dequeue(); //that card is played playCard(crd, b, usrScr); //card is then animated to the screen await iG.srchGrid(this); //value of card is displayed in the image of the card iG.txtCardVal(crd.Val, this); }
public async Task mkMove(User u, TextBlock enScr, InGame iG, Queue <Card> deck) { //not the user's turn right now u.IsTrn = false; u.GotDk = false; if (TrnCnt < 9 && Stndng == false && IsBust == false) { await deckDeal(iG, deck); ScrTypePair currMv = decideMove(this.CurrScr); //refactor this, logic seems off if (currMv.CrdType != 0 && currMv.Score > App.gmDifficulty) { //move is good, make move, then ponder future later await handDeal(currMv.CrdType - 1, iG); //simulate how the next turn could go ScrTypePair futMv = decideMove(this.CurrScr); //enemy will stand if its score is winning, and is as close to 20 as the difficulty allows //will adjust and play more aggressively if for example the user is on 19, and the enemy is on 18 //enemy will play to win and try its hardest to get a higher score than the user if (futMv.Score < App.gmDifficulty && futMv.CrdType == 0 && u.CurrScr <= this.CurrScr) { //if the future dosnt look good for the AI, it will stick this.Stndng = true; } } //if score is above 20, AI has bust if (this.CurrScr > 20) { this.IsBust = true; } //AI will stand if it evaluates to true else if ((currMv.Score < App.gmDifficulty || (this.CurrScr > u.CurrScr && u.Stndng && u.IsBust == false)) || this.CurrScr == 20) { this.Stndng = true; } } enScr.Text = this.CurrScr.ToString(); u.IsTrn = true; }
public async Task mkMove(User u, TextBlock enScr, InGame iG, Queue<Card> deck) { //not the user's turn right now u.IsTrn = false; u.GotDk = false; if (TrnCnt < 9 && Stndng == false && IsBust==false) { await deckDeal(iG, deck); ScrTypePair currMv = decideMove(this.CurrScr); //refactor this, logic seems off if (currMv.CrdType != 0&&currMv.Score>App.gmDifficulty) { //move is good, make move, then ponder future later await handDeal(currMv.CrdType - 1, iG); //simulate how the next turn could go ScrTypePair futMv = decideMove(this.CurrScr); //enemy will stand if its score is winning, and is as close to 20 as the difficulty allows //will adjust and play more aggressively if for example the user is on 19, and the enemy is on 18 //enemy will play to win and try its hardest to get a higher score than the user if (futMv.Score < App.gmDifficulty&&futMv.CrdType==0&&u.CurrScr<=this.CurrScr) { //if the future dosnt look good for the AI, it will stick this.Stndng = true; } } //if score is above 20, AI has bust if(this.CurrScr>20) { this.IsBust = true; } //AI will stand if it evaluates to true else if((currMv.Score < App.gmDifficulty || (this.CurrScr > u.CurrScr&&u.Stndng&&u.IsBust==false)) || this.CurrScr == 20) { this.Stndng = true; } } enScr.Text = this.CurrScr.ToString(); u.IsTrn = true; }
public Boolean autoBust(InGame iG) { if (this.CurrScr > 19) { //if the user has a score of 20, user's score is set //game auto sets user to standing if (this.CurrScr == 20) { this.Stndng = true; this.IsBust = false; } //if score is above 20, then the user has bust else { this.IsBust = true; this.Stndng = false; } return(true); } return(false); }
//method that keeps track of the game loop public void rndWn(Player p, InGame ig) { //the game is reset once the amount of rounds won by the current player is above 2 if (this.rndsWn < 2) { this.rndsWn++; } else { ResourceCandidate rc; rc = ResourceManager.Current.MainResourceMap.GetValue("Resources/newGm", ResourceContext.GetForCurrentView()); string newGm = rc.ValueAsString; this.rndsWn++; ig.status = newGm; this.gmsWn++; //HighScore h = new HighScore(this.gmsWn, p.gmsWn); //h.readScores(); //h.writeScores(); } }
public Boolean autoBust(InGame iG) { if (this.CurrScr > 19) { //if the user has a score of 20, user's score is set //game auto sets user to standing if (this.CurrScr == 20) { this.Stndng = true; this.IsBust = false; } //if score is above 20, then the user has bust else { this.IsBust = true; this.Stndng = false; } return true; } return false; }
//method that keeps track of the game loop public void rndWn(Player p, InGame ig) { //the game is reset once the amount of rounds won by the current player is above 2 if (this.rndsWn<2) { this.rndsWn++; } else { ResourceCandidate rc; rc = ResourceManager.Current.MainResourceMap.GetValue("Resources/newGm", ResourceContext.GetForCurrentView()); string newGm = rc.ValueAsString; this.rndsWn++; ig.status = newGm; this.gmsWn++; //HighScore h = new HighScore(this.gmsWn, p.gmsWn); //h.readScores(); //h.writeScores(); } }