Example #1
0
        // 勝敗を判定する
        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);
        }
Example #2
0
 public void setHandKind(HandKind kind)
 {
     switch(kind) {
         case HandKind.HandNormal:
             thisImage.sprite = handNormal;
             break;
         case HandKind.HandClick:
             thisImage.sprite = handClick;
             break;
     }
 }
Example #3
0
    public void setHandKind(HandKind kind)
    {
        switch (kind)
        {
        case HandKind.HandNormal:
            thisImage.sprite = handNormal;
            break;

        case HandKind.HandClick:
            thisImage.sprite = handClick;
            break;
        }
    }
Example #4
0
        // ResultKindを文字列へ変換
        static public string HandKindToString(HandKind handKind)
        {
            switch (handKind)
            {
            case HandKind.Guu:
                return("グー");

            case HandKind.Tyoki:
                return("チョキ");

            default:
                return("パー");
            }
        }
Example #5
0
        // 文字列を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]);
        }
Example #6
0
 // 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);
 }
Example #7
0
 public static CompareResult Compare(HandKind kind, Hand handA, Hand handB)
 {
     return(Strategies[kind].Compare(handA, handB));
 }
Example #8
0
 // ルールと出す手をセット
 public Human(Rule rule, HandKind hand)
 {
     this.rule = rule;
     this.Hand = hand;
 }