コード例 #1
0
ファイル: HarrowDeck.cs プロジェクト: kyapp69/IdleArtificer
        /*public static void _resolveAttribute(HarrowDeck deck, Suit attr) {
         *      resolveAttribute(deck, attr);
         * }*/

        private static void resolveAttribute(HarrowDeck deck, Suit attr)
        {
            //UnityEngine.Debug.Log("Resolving " + attr);
            Fortune f = deck.getAttr(attr);
            Suit    s = f.card.getSuit();
            int     n = f.card.getValue();

            //UnityEngine.Debug.Log("    " + s + n);
            switch (n)
            {
            case 0:
                switch (s)
                {
                case Suit.HAMMER_STR:
                case Suit.TOME_INT:
                    stealGive(deck, attr, 3, -1);
                    break;

                case Suit.KEY_AGL:                                 //steal 1 from all
                    stealGive(deck, attr, 1, -1);
                    stealGive(deck, attr, 2, -1);
                    stealGive(deck, attr, 3, -1);
                    break;

                case Suit.CROWN_CHA:                                 //give 1 to all
                    stealGive(deck, attr, 1, 1);
                    stealGive(deck, attr, 2, 1);
                    stealGive(deck, attr, 3, 1);
                    break;
                }
                break;

            case 1:
                stealGive(deck, attr, 1, 1);
                break;

            case 2:
                stealGive(deck, attr, 2, 1);
                break;

            case 3:
                stealGive(deck, attr, 3, 1);
                break;

            case 4:                     //steal from hammers&keys or tomes&crowns
                bool getHammerKey = false;
                switch (s)
                {
                case Suit.HAMMER_STR:
                case Suit.CROWN_CHA:
                    getHammerKey = true;
                    break;

                case Suit.TOME_INT:
                case Suit.KEY_AGL:
                    getHammerKey = false;
                    break;
                }
                for (Suit t = Suit.HAMMER_STR; t <= Suit.CROWN_CHA; t++)
                {
                    Fortune a = deck.getAttr(t);
                    Suit    d = a.card.getSuit();
                    if (d == Suit.HAMMER_STR || d == Suit.KEY_AGL)
                    {
                        if (getHammerKey)
                        {
                            a.tokens--;
                            f.tokens++;
                        }
                    }
                    else
                    {
                        if (!getHammerKey)
                        {
                            a.tokens--;
                            f.tokens++;
                        }
                    }
                }
                break;

            case 5:
                //UnityEngine.Debug.Log("    !" + attr);
                //UnityEngine.Debug.Log("    [" + deck.STR.tokens + "," + deck.AGL.tokens + "," + deck.INT.tokens + "," + deck.CHA.tokens + "]");
                List <Fortune> arr = new List <Fortune>();
                for (Suit t = Suit.HAMMER_STR; t <= Suit.CROWN_CHA; t++)
                {
                    Fortune fff = deck.getAttr(t);
                    arr.Add(fff);
                }
                arr.Sort((x, y) => x.tokens.CompareTo(y.tokens));
                bool    cont = true;
                Fortune toActOn;
                int     i = 0;
                switch (s)
                {
                case Suit.HAMMER_STR:
                case Suit.CROWN_CHA:
                    do
                    {
                        toActOn = arr[i];
                        i++;
                        if (i > 3 || (toActOn.tokens != arr[i].tokens && toActOn != f))
                        {
                            cont = false;
                        }
                        if (i <= 3 && toActOn.tokens == arr[i].tokens && toActOn != f)
                        {
                            i++;
                            if (i > 3)
                            {
                                cont = false;
                            }
                        }
                    } while(cont);
                    //UnityEngine.Debug.Log(s + ", Lowest: " + (Suit)(i-1));
                    if (s == Suit.HAMMER_STR)
                    {
                        toActOn.tokens -= 2;
                        f.tokens       += 2;
                    }
                    else
                    {
                        toActOn.tokens += 2;
                        f.tokens       -= 2;
                    }
                    break;

                case Suit.KEY_AGL:
                case Suit.TOME_INT:
                    i = 3;
                    do
                    {
                        toActOn = arr[i];
                        i--;
                        if (i > 0 || (toActOn.tokens != arr[i].tokens && toActOn != f))
                        {
                            cont = false;
                        }
                        if (i > 0 && toActOn.tokens == arr[i].tokens && toActOn != f)
                        {
                            i--;
                            if (i < 0)
                            {
                                cont = false;
                            }
                        }
                    } while(cont);
                    //UnityEngine.Debug.Log(s + ", Highest: " + (Suit)(i - 1));
                    if (s == Suit.HAMMER_STR)
                    {
                        toActOn.tokens -= 2;
                        f.tokens       += 2;
                    }
                    else
                    {
                        toActOn.tokens += 2;
                        f.tokens       -= 2;
                    }
                    break;
                }
                break;

            case 6:                     //give to hammer&key or tome&crown
                bool getHammerKey2 = false;
                switch (s)
                {
                case Suit.HAMMER_STR:
                case Suit.CROWN_CHA:
                    getHammerKey2 = true;
                    break;

                case Suit.TOME_INT:
                case Suit.KEY_AGL:
                    getHammerKey2 = false;
                    break;
                }
                for (Suit t = Suit.HAMMER_STR; t <= Suit.CROWN_CHA; t++)
                {
                    Fortune a = deck.getAttr(t);
                    Suit    d = a.card.getSuit();
                    if (d == Suit.HAMMER_STR || d == Suit.KEY_AGL)
                    {
                        if (getHammerKey2)
                        {
                            a.tokens++;
                            f.tokens--;
                        }
                    }
                    else
                    {
                        if (!getHammerKey2)
                        {
                            a.tokens++;
                            f.tokens--;
                        }
                    }
                }
                break;

            case 7:
                stealGive(deck, attr, 1, -1);
                break;

            case 8:
                stealGive(deck, attr, 2, -1);
                break;

            case 9:
                throw new NotImplementedException();
            }
        }