Esempio n. 1
0
    protected virtual void DrawCardEffect(string cardName, bool byController, Action conpleteEffect)
    {
        Vector3    pos    = Vector3.zero;
        GameObject prefab = null;
        Card       info   = CardData.Instance.GetCard(cardName, false);

        Card.Type type = info.type;

        if (type == Card.Type.bonus)
        {
            pos    = bonusPilePos.position;
            prefab = bonusCardPrefab;
        }
        else if (type == Card.Type.mogi)
        {
            pos    = mogisPilePos.position;
            prefab = mogisCardPrefab;
        }

        GameObject cardObj = Instantiate(prefab, pos, Quaternion.identity);

        CardEntity entity = cardObj.GetComponent <CardEntity>();

        CardDisplay display = cardObj.GetComponent <CardDisplay>();

        display.Init(cardName);
        cardObj.name = cardName;
        CardMotion motion = cardObj.GetComponent <CardMotion>();

        motion.Init(entity);
        entity.Init(info, display, motion, byController);

        motion.PileToHand(conpleteEffect);
    }
Esempio n. 2
0
    public static List <Card.SubType> getCardSubtypes(Card.Type type)
    {
        List <Card.SubType> typeList = new List <Card.SubType>();

        switch (type)
        {
        case Card.Type.Mortal:
            typeList.Add(Card.SubType.Work);
            typeList.Add(Card.SubType.BandTogether);
            break;

        case Card.Type.Magic:
            typeList.Add(Card.SubType.Alter);
            typeList.Add(Card.SubType.RiseAbove);
            break;

        case Card.Type.Patience:
            typeList.Add(Card.SubType.Understand);
            typeList.Add(Card.SubType.Master);
            break;

        case Card.Type.Luck:
            typeList.Add(Card.SubType.Guess);
            typeList.Add(Card.SubType.Friends);
            break;
        }

        if (typeList.Count <= 0)
        {
            Debug.Log("Could not retrieve card subtypes.");
        }

        return(typeList);
    }
Esempio n. 3
0
        public void TestDeskCheckError()
        {
            Desk tempDesk1 = new Desk();
            int  coloum = 0, row = 0;

            for (Card.Type type = Card.Type.Diamonds; type <= Card.Type.Club; type++)
            {
                for (int i = 1; i <= 13; i++)
                {
                    tempDesk1.AddNewCardInColoum(coloum, new Card(type, (Card.Number)i));
                    coloum++;
                    if (coloum == tempDesk1.AllCardOnDesk.ColoumCard.GetLength(0))
                    {
                        row++;
                        coloum = 0;
                    }
                }
            }
            tempDesk1.CheckError();

            Card tempCard = tempDesk1.RemoveLastCardInColoum(0);

            try
            {
                tempDesk1.CheckError();
                throw new Exception("Test failed");
            }
            catch (ErrorInDeskException)
            {
            }
            tempDesk1.AllCardOnDesk.FreeCard[0] = tempCard;
            tempDesk1.CheckError();

            Desk tempDesk2 = new Desk();

            for (Card.Type type = Card.Type.Diamonds; type <= Card.Type.Spade; type++)
            {
                for (int i = 1; i <= 13; i++)
                {
                    tempDesk2.AddNewCardInColoum(coloum, new Card(type, (Card.Number)i));
                    coloum++;
                    if (coloum == tempDesk2.AllCardOnDesk.ColoumCard.GetLength(0))
                    {
                        row++;
                        coloum = 0;
                    }
                }
            }
            for (Card.Number i = Card.Number.Arch; i <= Card.Number.King; i++)
            {
                tempDesk2.AddNewCardInSortedCard(new Card(Card.Type.Club, i), true);
            }

            tempDesk2.CheckError();
        }
Esempio n. 4
0
    public string GetCard(string cardName)
    {
        Card.Type cardType = CardData.Instance.GetCard(cardName, false).type;
        string    card     = null;

        if (cardType == Card.Type.bonus)
        {
            card = player.piles.bonusPile.ForceDrawCard(cardName);
        }
        else
        {
            card = player.piles.mogiPile.ForceDrawCard(cardName);
        }
        return(card);
    }
Esempio n. 5
0
        public string GenerateSampleDeskJson()
        {
            Desk sampleDesk = new Desk();
            int  coloum = 0, row = 0;

            for (Card.Type type = Card.Type.Diamonds; type <= Card.Type.Club; type++)
            {
                for (int i = 1; i <= 13; i++)
                {
                    sampleDesk.AddNewCardInColoum(coloum, new Card(type, (Card.Number)i));
                    coloum++;
                    if (coloum == sampleDesk.AllCardOnDesk.ColoumCard.GetLength(0))
                    {
                        row++;
                        coloum = 0;
                    }
                }
            }
            Console.WriteLine(sampleDesk.Pretty());
            return(sampleDesk.GetJson());
        }
 public void AddNewCardInColoum(int coloum, Card.Type type, Card.Number number)
 {
     AddNewCardInColoum(coloum, new Card(type, number));
 }
 public void AddNewCardInColoum(int coloum, Card.Type type, int numberInt)
 {
     Card.Number number = (Card.Number)numberInt;
     AddNewCardInColoum(coloum, new Card(type, number));
 }
 public FriendlyDmbBonus(Card.Type type, int dmg) : base()
 {
     this.dmg  = dmg;
     this.type = type;
 }
Esempio n. 9
0
 public DeadCard(string card, bool gold, Card.Type type)
 {
     this.type = type;
     this.card = card;
     this.gold = gold;
 }
 public BuffFromDeath(int dmg, int hp, Card.Type type)
 {
     this.dmg  = dmg;
     this.hp   = hp;
     this.type = type;
 }
 public Juggler(int times, Card.Type type)
 {
     this.type  = type;
     this.times = times;
 }
 public DeathTypeBuff(int buff, Card.Type type)
 {
     this.type = type;
     this.buff = buff;
 }
Esempio n. 13
0
    //to inherit
    public async void DrawCard(bool byController, int numberInQueue, bool getByTurn, Card.Type type, Action complete = null)
    {
        if (!MotionManager.running)
        {
            //Pull out a series of cards at the same time
            List <string> cardToDraws = null;

            if (byController)
            {
                if (type == Card.Type.bonus)
                {
                    cardToDraws = Game.Instance.controller.activity.GetBonusCard(numberInQueue, getByTurn);
                }
                else if (type == Card.Type.mogi)
                {
                    cardToDraws = Game.Instance.controller.activity.GetMogiCard(numberInQueue, getByTurn);
                }
                else //random
                {
                    int drawMogi = 0;

                    if (numberInQueue == 1)
                    {
                        drawMogi = UnityEngine.Random.Range(0, 2);
                    }
                    else
                    {
                        drawMogi = Mathf.CeilToInt(numberInQueue / 2f);//50% is mogi
                    }

                    cardToDraws = Game.Instance.controller.activity.GetMogiCard(drawMogi, getByTurn);
                    int drawBonus = numberInQueue - cardToDraws.Count;
                    cardToDraws.AddRange(Game.Instance.controller.activity.GetBonusCard(drawBonus, getByTurn));
                }
            }
            else
            {
                if (type == Card.Type.bonus)
                {
                    cardToDraws = Game.Instance.opponent.activity.GetBonusCard(numberInQueue, getByTurn);
                }
                else if (type == Card.Type.mogi)
                {
                    cardToDraws = Game.Instance.opponent.activity.GetMogiCard(numberInQueue, getByTurn);
                }
                else //random
                {
                    int drawMogi = 0;

                    if (numberInQueue == 1)
                    {
                        if (HandUI.Instance.MogisInHand(false).Count == 0 && BoardUI.Instance.MogiInBoard(false).Count == 0)
                        {
                            drawMogi = 1;
                        }
                        else
                        {
                            drawMogi = UnityEngine.Random.Range(0, 2);
                        }
                    }
                    else
                    {
                        drawMogi = Mathf.CeilToInt(numberInQueue / 2f);//50% is mogi
                    }

                    cardToDraws = Game.Instance.opponent.activity.GetMogiCard(drawMogi, getByTurn);
                    int drawBonus = numberInQueue - cardToDraws.Count;
                    cardToDraws.AddRange(Game.Instance.opponent.activity.GetBonusCard(drawBonus, getByTurn));
                }
            }

            if (cardToDraws.Count > 0)
            {
                while (cardToDraws.Count > 0)
                {
                    bool effectComplete = false;
                    DrawCardEffect(cardToDraws[0], byController, () => { effectComplete = true; });
                    cardToDraws.RemoveAt(0);
                    await new WaitUntil(() => effectComplete == true);
                }

                complete?.Invoke();
            }
            else
            {
                complete?.Invoke();
            }
        }
    }
Esempio n. 14
0
        public void GainCardByCost(int cost, bool exactCost, bool optional, Kingdom myKingdom, Deck.State state = Deck.State.discardPile, Card.Type type = 0)
        {
            ClearIndex(myKingdom);
            bool done  = false;
            int  index = 1;

            foreach (Deck deck in myKingdom.KingdomSupply)
            {
                if (deck.Cards.Count > 0)
                {
                    if ((deck.Cards[0].cost <= cost && !exactCost) || (deck.Cards[0].cost == cost && exactCost))
                    {
                        if (type == 0 || deck.Cards[0].types.Contains(type))
                        {
                            deck.Cards[0].index = index++;
                        }
                    }
                }
            }
            myKingdom.PrintKingdom();
            string optionalText = "";

            if (optional)
            {
                optionalText = " Or, press [n] to gain no card.";
            }
            if (exactCost)
            {
                Console.WriteLine("\r\nChoose a card from the kingdom to gain costing exactly " + cost + "." + optionalText);
            }
            else
            {
                Console.WriteLine("\r\nChoose a card from the kingdom to gain costing up to " + cost + "." + optionalText);
            }

            do
            {
                string buyInput    = Console.ReadLine().ToLower();
                int    intBuyInput = -1;
                if (Int32.TryParse(buyInput, out intBuyInput))
                {
                    if (intBuyInput > 0 && intBuyInput < index)
                    {
                        foreach (Deck deck in myKingdom.KingdomSupply)
                        {
                            if (deck.Cards[0].index == intBuyInput)
                            {
                                Card cardToGain = deck.Cards[deck.Cards.Count - 1];
                                GainCard(cardToGain, deck, state);
                                done = true;
                            }
                        }
                    }
                    else
                    {
                        Console.WriteLine("Invalid Input.");
                    }
                }
                else if (optional && buyInput == "n")
                {
                    done = true;
                }
                else
                {
                    Console.WriteLine("Invalid Input");
                }
            } while (!done);
        }
 public SpawnBuffEffect(Card.Type type, int dmg, int hp) : base()
 {
     this.dmg  = dmg;
     this.hp   = hp;
     this.type = type;
 }