// 勝敗を判定する public ResultKind Judge(HandKind myHand, IEnumerable <HandKind> otherHands) { uint winCount = 0; uint loseCount = 0; foreach (var otherHand in otherHands) { var resultKind = Judge(myHand, otherHand); if (resultKind == Win) { winCount++; } else if (resultKind == Lose) { loseCount++; } } if (winCount * loseCount != 0 || winCount + loseCount == 0) { return(Draw); } if (winCount != 0) { return(Win); } return(Lose); }
public void setHandKind(HandKind kind) { switch(kind) { case HandKind.HandNormal: thisImage.sprite = handNormal; break; case HandKind.HandClick: thisImage.sprite = handClick; break; } }
public void setHandKind(HandKind kind) { switch (kind) { case HandKind.HandNormal: thisImage.sprite = handNormal; break; case HandKind.HandClick: thisImage.sprite = handClick; break; } }
// ResultKindを文字列へ変換 static public string HandKindToString(HandKind handKind) { switch (handKind) { case HandKind.Guu: return("グー"); case HandKind.Tyoki: return("チョキ"); default: return("パー"); } }
// 文字列をHandKindへ変換 static public HandKind?StringToHandKind(string consoleString) { int result; if (int.TryParse(consoleString, out result) == false) { return(null); } if (result < 1 || result > 3) { return(null); } var handKinds = new HandKind[] { HandKind.Guu, HandKind.Tyoki, HandKind.Paa }; return(handKinds[result - 1]); }
// 1対1の時の勝敗判定 private ResultKind Judge(HandKind myHand, HandKind otherHand) { if (myHand == otherHand) { return(Draw); } if ( (myHand == Guu && otherHand == Paa) || (myHand == Tyoki && otherHand == Guu) || (myHand == Paa && otherHand == Tyoki) ) { return(Lose); } return(Win); }
public static CompareResult Compare(HandKind kind, Hand handA, Hand handB) { return(Strategies[kind].Compare(handA, handB)); }
// ルールと出す手をセット public Human(Rule rule, HandKind hand) { this.rule = rule; this.Hand = hand; }