//filter for tasks
        private List <PlayerTask> filterTasks(List <PlayerTask> tasks, PlayerTaskType type)
        {
            List <PlayerTask> filtertTasks = new List <PlayerTask>();

            foreach (PlayerTask task in tasks)
            {
                if (task.PlayerTaskType == type)
                {
                    filtertTasks.Add(task);
                }
            }

            return(filtertTasks);
        }
Exemple #2
0
        public static bool CorrectBuggySimulation(TyState lastPlayerState, TyState lastEnemyState, POGame lastState, PlayerTask task)
        {
            PlayerTaskType taskType = task.PlayerTaskType;

            //Testing.TyDebug.LogError(task.FullPrint());

            bool corrected = false;

            if (taskType == PlayerTaskType.END_TURN)
            {
                CorrectTurnEnd(lastPlayerState, lastEnemyState, lastState, task, ref corrected);
            }

            else if (taskType == PlayerTaskType.HERO_ATTACK)
            {
                CorrectHeroAttack(lastPlayerState, lastEnemyState, lastState, task, ref corrected);
            }

            else if (taskType == PlayerTaskType.PLAY_CARD)
            {
                CorrectPlayCard(lastPlayerState, lastEnemyState, lastState, task, ref corrected);
            }

            else if (taskType == PlayerTaskType.MINION_ATTACK)
            {
                CorrectMinionAttack(lastPlayerState, lastEnemyState, lastState, task, ref corrected);
            }

            else if (taskType == PlayerTaskType.HERO_POWER)
            {
                CorrectHeroPower(lastPlayerState, lastEnemyState, lastState, task, ref corrected);
            }

            if (TyConst.LOG_UNKNOWN_CORRECTIONS && !corrected)
            {
                TyDebug.LogError("Unknown buggy PlayerTask: " + task.FullPrint());
            }

            return(corrected);
        }
Exemple #3
0
        private static unsafe int *MarshalOption(PlayerTaskType type, int *ip,
                                                 int sourcePosition = 0,
                                                 int targetPosition = 0,
                                                 int subOption      = 0,
                                                 IPlayable source   = null,
                                                 ICharacter target  = null)
        {
            *ip++ = (int)type;
            *ip++ = sourcePosition;
            *ip++ = targetPosition;
            *ip++ = subOption;
            ip++;
            byte *bp = (byte *)ip;

            *bp++ = Convert.ToByte(type == PlayerTaskType.PLAY_CARD && source.Card.Type == CardType.SPELL);

            var sb = new StringBuilder();

            switch (type)
            {
            case PlayerTaskType.MINION_ATTACK:
            case PlayerTaskType.HERO_ATTACK:
                sb.Append($"[ATTACK] {source} => {target}");
                break;

            case PlayerTaskType.HERO_POWER:
                sb.Append($"[HEROPOWER]{source}");
                if (target != null)
                {
                    sb.Append($" => {target}");
                }
                break;

            case PlayerTaskType.PLAY_CARD:
                sb.Append($"[PLAY_CARD] {source}");
                if (target != null)
                {
                    sb.Append($" => {target}");
                }
                if (source.Card.Type == CardType.MINION)
                {
                    sb.Append($"(Pos {targetPosition})");
                }
                if (subOption > 0)
                {
                    sb.Append($"(Opt {subOption}");
                }
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            var str = sb.ToString();

            ip = (int *)bp;
            *ip++ = str.Length;
            bp = (byte *)ip;

            fixed(char *chPtr = str)
            {
                Encoding.Default.GetBytes(chPtr, str.Length, bp, 1000);
            }

            return((int *)(bp + str.Length));
        }