/// <summary>
        /// logic is as follows
        /// this actions kills someone
        /// otherwise try to get to the weakest target and attack
        /// will move the smallest distance possible for attacks
        /// othersise move towards closest target
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public int CompareTo(object obj)
        {
            AiMove objMove = (AiMove)obj;

            if (objMove != null)
            {
                int returnInt = scoredKill.CompareTo(objMove.scoredKill);
                if (returnInt != 0)
                {
                    return(-returnInt);
                }
                returnInt = targetScore.CompareTo(objMove.targetScore);
                if (returnInt != 0)
                {
                    return(returnInt);
                }

                returnInt = movementScore.CompareTo(objMove.movementScore);
                if (returnInt != 0)
                {
                    return(returnInt);
                }

                returnInt = movementCost.CompareTo(objMove.movementCost);
                return(returnInt);
            }
            else
            {
                return(0);
            }
        }
        public void ExecuteTurnHelper(Action callBack, BoardEntity ragedBy = null)
        {
            this.callBack = callBack;
            List <Move>   moves   = characterBoardEntity.MoveSet();
            Skill         skill   = characterBoardEntity.BasicAttack;
            List <AiMove> aiMoves = new List <AiMove>();
            Dictionary <Move, List <BoardEntity> > moveToTargets = new Dictionary <Move, List <BoardEntity> >();

            moves.Add(new Move {
                destination = characterBoardEntity.GetTile()
            });

            foreach (Move m in moves)
            {
                List <Tile> tiles = new List <Tile>();
                if (skill.IsActive())
                {
                    tiles = skill.TileSetClickable(m.destination.Position);
                }

                List <BoardEntity> entities = new List <BoardEntity>();

                // raged target must be the 'nearest' boardentity
                Position targetPosition;
                if (ragedBy != null)
                {
                    targetPosition = ragedBy.GetTile().Position;
                }
                else
                {
                    BoardEntity nearest = tileManager.NearestBoardEntity(m.destination.Position, Team.Player);
                    if (nearest == null)
                    {
                        callBack();
                        return;
                    }
                    targetPosition = nearest.GetTile().Position;
                }

                float distance = targetPosition.GetDistance(m.destination.Position);

                int movementScore = m.path.Count;

                AiMove aiMove = new AiMove(int.MaxValue, (int)distance);
                if (m.destination != characterBoardEntity.GetTile())
                {
                    aiMove.AddMoveAction(characterBoardEntity, m, DoNextAction);
                }

                aiMoves.Add(aiMove);
                foreach (Tile t in tiles)
                {
                    if (t.BoardEntity != null)
                    {
                        // must attack the raged target if there is one
                        if ((ragedBy == null || ragedBy == t.BoardEntity) && !((CharacterBoardEntity)t.BoardEntity).IsStealthed())
                        {
                            aiMove = new AiMove(targetScore(t.BoardEntity), 0);
                            if (m.destination != characterBoardEntity.GetTile())
                            {
                                aiMove.AddMoveAction(characterBoardEntity, m, DoNextAction);
                            }
                            aiMove.AddAttackAction(skill, t, (() => DoNextAction(false)));
                            aiMoves.Add(aiMove);
                        }
                    }
                }
                moveToTargets[m] = entities;
            }

            aiMoves.RemoveAll((a) => a.ApCost > characterBoardEntity.Stats.GetMutableStat(AttributeStats.StatType.AP).Value);
            aiMoves.Sort();

            actionQueue = aiMoves[0].Actions;
            DoNextAction(false);
        }