本文整理汇总了C#中model.GetHand方法的典型用法代码示例。如果您正苦于以下问题:C# model.GetHand方法的具体用法?C# model.GetHand怎么用?C# model.GetHand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model
的用法示例。
在下文中一共展示了model.GetHand方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoHit
public bool DoHit(model.Player a_dealer)
{
if(a_dealer.CalcScore() < g_hitLimit)
{
return true;
}
//checks to see if the amount of ace is atleast of half the dealers cards to make sure the dealer doesnt hit at a hard 17. Example ace + 6 + 10
else if (a_dealer.GetHand().Count(x => x.GetValue() == Card.Value.Ace)*2 >= a_dealer.GetHand().Count() && a_dealer.CalcScore() <= g_hitLimit)
{
return true;
}
return false;
}
示例2: DoHit
public bool DoHit(model.Player a_dealer)
{
if (a_dealer.CalcScore() == g_hitLimit)
{
int otherValue = 0;
bool aceFound = false;
int[] cardScores = new int[(int)model.Card.Value.Count] { 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 11 };
foreach (Card card in a_dealer.GetHand())
{
if (card.GetValue() == Card.Value.Ace && !aceFound)
{
aceFound = true;
} else {
otherValue += cardScores[(int)card.GetValue()];
if (otherValue > 6)
{
return false;
}
}
}
if (otherValue == 6 && aceFound)
{
return true;
}
}
return a_dealer.CalcScore() < g_hitLimit;
}
示例3: DoHit
public bool DoHit(model.Player a_dealer)
{
int[] cardScores = a_dealer.getCardScoreArray();
total = 0;
if (a_dealer.CalcScore() < 17)
{
return true;
}
if (a_dealer.CalcScore() == 17){
foreach (Card c in a_dealer.GetHand())
{
if (c.GetValue() != Card.Value.Ace)
{
total += cardScores[(int)c.GetValue()];
}
}
//if this is true a soft 17 is active.
if (total <= 6)
{
return true;
}
}
return false;
}
示例4: DoHit
public bool DoHit(model.Player a_dealer)
{
int[] cardScores = new int[] { 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 11 };
var score = 0;
var cards = a_dealer.GetHand();
var numberOfAces = 0;
foreach (var c in cards)
{
if (c.GetValue() != Card.Value.Hidden)
{
score += cardScores[(int)c.GetValue()];
if (c.GetValue() == Card.Value.Ace)
{
numberOfAces++;
}
}
}
while ((score == g_hitLimit || score > 21) && numberOfAces > 0)
{
numberOfAces--;
score -= 10;
}
return score < g_hitLimit;
}
示例5: DoHit
public bool DoHit(model.Player a_dealer)
{
var cards = a_dealer.GetHand();
// Check if limit has reached....
if (a_dealer.CalcScore() == g_hitLimit)
{
foreach (var card in cards)
{
// Must hit if ace in hand. Because score IS 17!
//Ace turns into 1 score instead
if (card.GetValue() == Card.Value.Ace)
{
return true;
}
}
}
// No special circumstances....
if (a_dealer.CalcScore() < g_hitLimit)
{
return true;
}
else
{
return false;
}
}
示例6: DoHit
public bool DoHit(model.Player a_dealer)
{
int score = a_dealer.CalcScore();
if (score < g_hitLimit)
{
return true;
}
if (score == g_hitLimit)
{
foreach (Card c in a_dealer.GetHand())
{
//If Ace is in the hand, checks if score without Ace is 6
if ((c.GetValue() == Card.Value.Ace) && (score - 11 == 6))
{
score -= 10;
}
}
return score < g_hitLimit;
}
return false;
}
示例7: DoHit
public bool DoHit(model.Player a_dealer)
{
if(a_dealer.CalcScore() == g_hitLimit)
{
IEnumerable<Card> aces = a_dealer.GetHand().Where(c => c.GetValue() == Card.Value.Ace); //get all aces from hand
IEnumerable<Card> handWithoutAces = a_dealer.GetHand().Where(c => c.GetValue() != Card.Value.Ace); //get all other cards from hand
int score = a_dealer.CalcCardsScore(handWithoutAces); //calc score of hand without aces
return aces.Count() > 0 && score == 6; //return if there is aces and score of other cards is 6
}
else
{
return a_dealer.CalcScore() < g_hitLimit;
}
}
示例8: DoHit
public bool DoHit(model.Player a_dealer)
{
if (a_dealer.CalcScore() == g_hitLimit)
{
return DealerHasAce(a_dealer.GetHand());
}
return a_dealer.CalcScore() < g_hitLimit;
}
示例9: DoHit
public bool DoHit(model.Player a_dealer)
{
int a = a_dealer.CalcScore();
if (a == 17)
{
foreach (Card c in a_dealer.GetHand())
{
if (c.GetValue() == Card.Value.Ace)
{
return true;
}
}
}
return a_dealer.CalcScore() < g_hitLimit;
}
示例10: DoHit
public bool DoHit(model.Player a_dealer)
{
bool hasAce = false;
foreach (Card c in a_dealer.GetHand())
{
if (c.GetValue() == Card.Value.Ace)
{
hasAce = true;
break;
}
}
int score = a_dealer.CalcScore();
return (score < g_hitLimit ||
(score == g_hitLimit && hasAce));
}
开发者ID:of222au,项目名称:1DV607-Objektorienterad-analys-och-design-med-UML,代码行数:16,代码来源:Soft17HitStrategy.cs
示例11: DoHit
public bool DoHit(model.Player a_dealer)
{
int score = a_dealer.CalcScore(false); // parameter false means don't calcScore using Ace as 1 but only 11
if (score == g_hitLimit)
{
foreach (Card c in a_dealer.GetHand())
{
if (c.GetValue() == Card.Value.Ace)
{
return true;
}
}
}
return a_dealer.CalcScore() < g_hitLimit;
}
示例12: DoHit
public bool DoHit(model.Player a_dealer)
{
int score = a_dealer.CalcScore();
if(score == g_hitLimit){
foreach(Card c in a_dealer.GetHand()){
if(c.GetValue() == Card.Value.Ace && (score - 11) == 6){
score -= 10;
}
}
return score < g_hitLimit;
}
else if(score < g_hitLimit){
return true;
}
return false;
}
示例13: DoHit
//Hit if score is 17 or less
public bool DoHit(model.Player a_dealer)
{
var cards = a_dealer.GetHand();
if(a_dealer.CalcScore() == g_hitLimit)
{
foreach(Card card in cards)
{
if (card.GetValue() == Card.Value.Ace && a_dealer.CalcScore() - 11 == 6)
{
return true;
}
}
}
return a_dealer.CalcScore() < g_hitLimit;
}
示例14: DoHit
public bool DoHit(model.Player a_dealer)
{
int[] cardScore = a_dealer.getCardArrayValues();
int total = 0;
if (a_dealer.CalcScore() == g_hitLimit)
{
foreach (Card card in a_dealer.GetHand())
{
if (card.GetValue() != Card.Value.Ace)
{
total += cardScore[(int)card.GetValue()];
}
}
return total <= 6;
}
return a_dealer.CalcScore() < g_hitLimit;
}
示例15: PlayGame
public bool PlayGame(view.Console a_view, model.Dealer a_dealer, model.Player a_player)
{
a_view.PresentInstructions();
a_view.DisplayHands(a_dealer.GetHand(), a_player.GetHand());
view.Console.Event e;
e = a_view.GetEvent();
if (e == view.Console.Event.Quit)
{
return false;
}
if (e == view.Console.Event.Start)
{
a_dealer.StartNewRound(a_player);
}
return true;
}