Example #1
0
    public void RunAction(Actor source, Actor target, Card card, BattleContext manager)
    {
        if (target is PlayerInstance)
        {
            PlayerInstance player = (PlayerInstance)target;

            ListenableList <ElementCardInstance> handheldList = player.HandheldSet;
            List <ElementCardInstance>           changeList   = new List <ElementCardInstance>();

            // if drop count greater than 0
            if (_count > 0)
            {
                for (int cnt = 0; cnt < _count; cnt++)
                {
                    changeList.Add(handheldList.Get(cnt));
                }

                //if drop count smaller than 0, drop all
            }
            else if (_count < 0)
            {
                changeList.AddRange(handheldList.GetAll());
            }

            //move card from handheld to graveard
            foreach (ElementCardInstance item in changeList)
            {
                handheldList.RemoveItem(item);
            }
            player.Graveyard.AddItems(changeList);
        }
    }
Example #2
0
    public void RunAction(Actor source, Actor target, Card card, BattleContext manager)
    {
        if (target is PlayerInstance)
        {
            PlayerInstance player = (PlayerInstance)target;
            ListenableList <ElementCardInstance> handheldSet = player.HandheldSet;
            ListenableList <ElementCardInstance> cardDeck    = player.CardDeck;

            List <ElementCardInstance> filteredList = null;

            // filter
            if (null != _element)
            {
                filteredList = cardDeck.GetAll().FindAll(item => item.Element.Equals(_element));
            }
            else
            {
                filteredList = cardDeck.GetAll();
            }

            // random
            List <ElementCardInstance> drawList = new List <ElementCardInstance>();
            if (filteredList.Count > 0)
            {
                for (int cnt = 0; cnt < _drawCount; cnt++)
                {
                    int random = Random.Range(0, filteredList.Count - 1);
                    drawList.Add(filteredList[random]);
                    filteredList.RemoveAt(random);
                }
            }

            // update
            foreach (ElementCardInstance instance in drawList)
            {
                cardDeck.RemoveItem(instance);
                handheldSet.AddItem(instance);
            }
        }
    }