示例#1
0
        public override TaskState Process()
        {
            for (int i = 0; i < _amount; ++i)
            {
                if (Controller.BoardZone.IsFull)
                {
                    if (Card == null && Playables.Count > 0)
                    {
                        var m = Playables[0] as Minion;
                        if (m.Zone == null && m.GetNativeGameTag(GameTag.ZONE) != 0)
                        {
                            Playables[0].Controller.GraveyardZone.Add(Playables[0]);
                        }
                    }
                    return(TaskState.STOP);
                }

                Minion summonEntity = null;
                if (Card != null)
                {
                    summonEntity = Entity.FromCard(Controller, Card,
                                                   new EntityData.Data
                    {
                        { GameTag.ZONE, (int)Zone.PLAY },
                        { GameTag.DISPLAYED_CREATOR, Source.Id }
                    }) as Minion;
                    if (_addToStack)
                    {
                        Playables.Add(summonEntity);
                    }
                }
                else if (Playables.Count > 0)
                {
                    summonEntity = Playables[0] as Minion;
                    if (RemoveFromStack)
                    {
                        Playables.Remove(summonEntity);
                    }
                }

                if (summonEntity == null)
                {
                    return(TaskState.STOP);
                }

                int summonPosition = -1;
                switch (Side)
                {
                case SummonSide.LEFT:
                    if (Source.Zone.Type == Enums.Zone.PLAY)
                    {
                        summonPosition = ((Minion)Source).ZonePosition;
                    }
                    else
                    {
                        summonPosition = ((Minion)Source).LastBoardPosition;
                    }
                    break;

                case SummonSide.RIGHT:
                    if (Source.Zone.Type == Enums.Zone.PLAY)
                    {
                        summonPosition = ((Minion)Source).ZonePosition + 1;
                    }
                    else
                    {
                        summonPosition = ((Minion)Source).LastBoardPosition;
                    }
                    break;

                case SummonSide.DEATHRATTLE:
                    if (Source is Minion m)
                    {
                        summonPosition = m.LastBoardPosition;
                    }
                    else if
                    (Source is Enchantment e)
                    {
                        summonPosition = ((Minion)e.Target).LastBoardPosition;
                    }
                    break;

                case SummonSide.NUMBER:
                    summonPosition = Number - 1;
                    break;

                case SummonSide.SPELL:
                    summonPosition = -1;
                    break;

                case SummonSide.DEFAULT:
                    summonPosition = -1;
                    break;
                }

                if (summonPosition > Controller.BoardZone.Count)
                {
                    summonPosition = Controller.BoardZone.Count;
                }

                bool success = Generic.SummonBlock.Invoke(Controller, summonEntity, summonPosition);
            }

            return(TaskState.COMPLETE);
        }
示例#2
0
        public override TaskState Process()
        {
            Minion summonEntity = null;

            if (Controller.BoardZone.IsFull)
            {
                return(TaskState.STOP);
            }

            if (RecruitFromStack)
            {
                List <Minion> playableMinions = new List <Minion>();
                foreach (var entity in Playables)
                {
                    if (entity.Zone.Type == Zone.DECK && entity is Minion)
                    {
                        playableMinions.Add((Minion)entity);
                    }
                }
                if (playableMinions.Count > 0)
                {
                    summonEntity = Util.Choose(playableMinions);
                    if (RemoveFromStack)
                    {
                        Playables.Remove(summonEntity);
                    }
                }
            }
            else
            {
                List <Minion> playableMinions = new List <Minion>();
                foreach (var entity in Controller.DeckZone)
                {
                    if (entity.Zone.Type == Zone.DECK && entity is Minion)
                    {
                        playableMinions.Add((Minion)entity);
                    }
                }
                if (playableMinions.Count > 0)
                {
                    summonEntity = Util.Choose(playableMinions);
                }
            }

            if (summonEntity == null)
            {
                return(TaskState.STOP);
            }

            Generic.RemoveFromZone.Invoke(summonEntity.Controller, summonEntity);

            int summonPosition = -1;

            switch (Side)
            {
            case SummonSide.LEFT:
                if (Source.Zone.Type == Enums.Zone.PLAY)
                {
                    summonPosition = ((Minion)Source).ZonePosition;
                }
                else
                {
                    summonPosition = ((Minion)Source).LastBoardPosition;
                }
                break;

            case SummonSide.RIGHT:
                if (Source.Zone.Type == Enums.Zone.PLAY)
                {
                    summonPosition = ((Minion)Source).ZonePosition + 1;
                }
                else
                {
                    summonPosition = ((Minion)Source).LastBoardPosition;
                }
                break;

            case SummonSide.DEATHRATTLE:
                summonPosition = ((Minion)Source).LastBoardPosition;
                break;

            case SummonSide.NUMBER:
                summonPosition = Number - 1;
                break;

            case SummonSide.SPELL:
                summonPosition = -1;
                break;

            case SummonSide.DEFAULT:
                summonPosition = -1;
                break;
            }

            if (summonPosition > Controller.BoardZone.Count)
            {
                summonPosition = Controller.BoardZone.Count;
            }

            bool success = Generic.SummonBlock.Invoke(Controller, summonEntity, summonPosition);

            return(TaskState.COMPLETE);
        }
示例#3
0
        public override TaskState Process()
        {
            var result = new List <IPlayable>();

            switch (Type)
            {
            case EntityType.TARGET:
                var target = Target as IPlayable;
                if (target == null)
                {
                    return(TaskState.STOP);
                }
                for (var i = 0; i < Amount; i++)
                {
                    result.Add(Opposite ?
                               Entity.FromCard(target.Controller.Opponent, Cards.FromId(target.Card.Id)) :
                               Entity.FromCard(Controller, Cards.FromId(target.Card.Id)));
                }
                break;

            case EntityType.SOURCE:
                var source = Source as IPlayable;
                if (source == null)
                {
                    return(TaskState.STOP);
                }
                for (var i = 0; i < Amount; i++)
                {
                    result.Add(Opposite ?
                               Entity.FromCard(source.Controller.Opponent, Cards.FromId(source.Card.Id)) :
                               Entity.FromCard(Controller, Cards.FromId(source.Card.Id)));
                }
                break;

            case EntityType.STACK:
                if (Playables.Count < 1)
                {
                    return(TaskState.STOP);
                }
                Playables.ForEach(p =>
                {
                    for (var i = 0; i < Amount; i++)
                    {
                        result.Add(Opposite ?
                                   Entity.FromCard(p.Controller.Opponent, Cards.FromId(p.Card.Id)) :
                                   Entity.FromCard(Controller, Cards.FromId(p.Card.Id)));
                    }
                });
                break;

            case EntityType.OP_HERO_POWER:
                result.Add(Entity.FromCard(Controller, Cards.FromId(Controller.Opponent.Hero.Power.Card.Id)));
                break;

            default:
                throw new NotImplementedException();
            }

            Playables = result;
            return(TaskState.COMPLETE);
        }
示例#4
0
        public override TaskState Process()
        {
            if (true)
            {
                Game.Log(LogLevel.INFO, BlockType.PLAY, "LogTask", $"Log task is beeing processed!");
                Game.Log(LogLevel.INFO, BlockType.PLAY, "LogTask", $"Flag: {Flag}, Number: {Number}");
                Game.Log(LogLevel.INFO, BlockType.PLAY, "LogTask", $"Controller: {Controller?.Name}, Source: {Source}, Target: {Target}!");
                Game.Log(LogLevel.INFO, BlockType.PLAY, "LogTask", $"Playables: {string.Join(",", Playables.Select(x => x.Card))} [{Playables.Count}]");
            }

            if (CardTextPrint)
            {
                Game.Log(LogLevel.INFO, BlockType.PLAY, "LogTask", $"{Source.Card.Text}");
            }
            return(TaskState.COMPLETE);
        }
示例#5
0
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member

        public override TaskState Process()
        {
            if (Controller.BoardZone.IsFull)
            {
                return(TaskState.STOP);
            }

            IList <IPlayable> entities = IncludeTask.GetEntities(Type, Controller, Source, Target, Playables).ToList();

            if (entities.Count < 1)
            {
                return(TaskState.STOP);
            }

            // shuffle list randomly if needed
            entities = RandomFlag ? entities.OrderBy(x => Util.Random.Next()).ToList() : entities;

            if (RandomFlag)
            {
                Game.OnRandomHappened(true);
            }

            int space = Controller.BoardZone.MaxSize - Controller.BoardZone.Count;

            space = entities.Count > space ? space : entities.Count;

            if (entities[0].Zone == null || entities[0].Zone.Type != Enums.Zone.PLAY)
            {
                for (int i = 0; i < space; i++)
                {
                    // clone task here
                    var task = new SummonTask(_side, entities[i].Card)
                    {
                        Game       = Controller.Game,
                        Controller = Controller,
                        Source     = Source as IPlayable,
                        Target     = Target as IPlayable
                    };

                    Controller.Game.TaskQueue.Enqueue(task);
                }
            }
            else
            {
                for (int i = 0; i < entities.Count; i++)
                {
                    if (Controller.BoardZone.IsFull)
                    {
                        break;
                    }

                    Minion target = (Minion)entities[i];

                    var tags = new EntityData.Data((EntityData.Data)target.NativeTags);

                    if (target.Controller != Controller)
                    {
                        tags[GameTag.CONTROLLER] = Controller.PlayerId;
                    }

                    IPlayable copy = Entity.FromCard(Controller, target.Card, tags, Controller.BoardZone);

                    target.AppliedEnchantments?.ForEach(e =>
                    {
                        Enchantment instance = Enchantment.GetInstance(Controller, copy, copy, e.Card);
                        if (e[GameTag.TAG_SCRIPT_DATA_NUM_1] > 0)
                        {
                            instance[GameTag.TAG_SCRIPT_DATA_NUM_1] = e[GameTag.TAG_SCRIPT_DATA_NUM_1];
                            if (e[GameTag.TAG_SCRIPT_DATA_NUM_2] > 0)
                            {
                                instance[GameTag.TAG_SCRIPT_DATA_NUM_2] = e[GameTag.TAG_SCRIPT_DATA_NUM_2];
                            }
                        }
                    });

                    if (target.OngoingEffect != null && copy.OngoingEffect == null)
                    {
                        target.OngoingEffect.Clone(copy);
                    }

                    if (_addToStack)
                    {
                        Playables.Add(copy);
                    }
                }
            }



            return(TaskState.COMPLETE);
        }
示例#6
0
        public override TaskState Process()
        {
            if (Controller.BoardZone.IsFull)
            {
                if (Playables.Count > 0)
                {
                    var m = Playables[0] as Minion;
                    if (m.Zone == null && m.GetNativeGameTag(Enums.GameTag.ZONE) != 0)
                    {
                        Playables[0].Controller.GraveyardZone.Add(Playables[0]);
                    }
                }
                return(TaskState.STOP);
            }

            Minion summonEntity = null;

            if (Card != null)
            {
                summonEntity = Entity.FromCard(Controller, Card) as Minion;
            }
            else if (Playables.Count > 0)
            {
                summonEntity = Playables[0] as Minion;
                if (RemoveFromStack)
                {
                    Playables.Remove(summonEntity);
                }
            }

            if (summonEntity == null)
            {
                return(TaskState.STOP);
            }

            int summonPosition = -1;

            switch (Side)
            {
            case SummonSide.LEFT:
                if (Source.Zone.Type == Enums.Zone.PLAY)
                {
                    summonPosition = ((Minion)Source).ZonePosition;
                }
                else
                {
                    summonPosition = ((Minion)Source).LastBoardPosition;
                }
                break;

            case SummonSide.RIGHT:
                if (Source.Zone.Type == Enums.Zone.PLAY)
                {
                    summonPosition = ((Minion)Source).ZonePosition + 1;
                }
                else
                {
                    summonPosition = ((Minion)Source).LastBoardPosition;
                }
                break;

            case SummonSide.DEATHRATTLE:
                summonPosition = ((Minion)Source).LastBoardPosition;
                break;

            case SummonSide.NUMBER:
                summonPosition = Number - 1;
                break;

            case SummonSide.SPELL:
                summonPosition = -1;
                break;

            case SummonSide.DEFAULT:
                summonPosition = -1;
                break;
            }

            if (summonPosition > Controller.BoardZone.Count)
            {
                summonPosition = Controller.BoardZone.Count;
            }

            bool success = Generic.SummonBlock.Invoke(Controller, summonEntity, summonPosition);

            return(TaskState.COMPLETE);
        }
示例#7
0
        public override TaskState Process()
        {
            Minion summonEntity = null;

            if (Controller.BoardZone.IsFull)
            {
                return(TaskState.STOP);
            }

            if (_conditions != null)
            {
                IPlayable[] candidates = Controller.DeckZone.GetAll(p =>
                {
                    if (!(p is Minion))
                    {
                        return(false);
                    }

                    bool flag = true;
                    for (int i = 0; i < _conditions.Length; i++)
                    {
                        flag &= _conditions[i].Eval(p);
                    }
                    return(flag);
                });

                if (candidates.Length == 0)
                {
                    return(TaskState.STOP);
                }

                summonEntity = (Minion)Util.Choose(candidates);
            }
            else if (RecruitFromStack)
            {
                List <Minion> playableMinions = new List <Minion>();
                foreach (var entity in Playables)
                {
                    if (entity.Zone.Type == Zone.DECK && entity is Minion)
                    {
                        playableMinions.Add((Minion)entity);
                    }
                }
                if (playableMinions.Count > 0)
                {
                    summonEntity = Util.Choose(playableMinions);
                    if (RemoveFromStack)
                    {
                        Playables.Remove(summonEntity);
                    }
                }
            }
            else
            {
                List <Minion> playableMinions = new List <Minion>();
                foreach (var entity in Controller.DeckZone)
                {
                    if (entity.Zone.Type == Zone.DECK && entity is Minion)
                    {
                        playableMinions.Add((Minion)entity);
                    }
                }
                if (playableMinions.Count > 0)
                {
                    summonEntity = Util.Choose(playableMinions);
                }
            }

            if (summonEntity == null)
            {
                return(TaskState.STOP);
            }

            Generic.RemoveFromZone.Invoke(summonEntity.Controller, summonEntity);

            int summonPosition = -1;

            switch (Side)
            {
            case SummonSide.LEFT:
                if (Source.Zone.Type == Enums.Zone.PLAY)
                {
                    summonPosition = ((Minion)Source).ZonePosition;
                }
                else
                {
                    summonPosition = ((Minion)Source).LastBoardPosition;
                }
                break;

            case SummonSide.RIGHT:
                if (Source.Zone.Type == Enums.Zone.PLAY)
                {
                    summonPosition = ((Minion)Source).ZonePosition + 1;
                }
                else
                {
                    summonPosition = ((Minion)Source).LastBoardPosition;
                }
                break;

            case SummonSide.DEATHRATTLE:
                if (Source.Zone.Type != Zone.GRAVEYARD)
                {
                    goto case SummonSide.RIGHT;
                }
                summonPosition = ((Minion)Source).LastBoardPosition;
                break;

            case SummonSide.NUMBER:
                summonPosition = Number - 1;
                break;

            case SummonSide.SPELL:
                summonPosition = -1;
                break;

            case SummonSide.DEFAULT:
                summonPosition = -1;
                break;
            }

            if (summonPosition > Controller.BoardZone.Count)
            {
                summonPosition = Controller.BoardZone.Count;
            }

            bool success = Generic.SummonBlock.Invoke(Controller, summonEntity, summonPosition);

            Game.OnRandomHappened(true);

            return(TaskState.COMPLETE);
        }