예제 #1
0
        //private static int _pos;
        public static async Task <List <BattleAction> > GetActions(ISession sessison, long serverMs, PokemonData attacker, PokemonData defender, int energy)
        {
            Random rnd = new Random();
            List <BattleAction> actions = new List <BattleAction>();
            DateTime            now     = DateTimeFromUnixTimestampMillis(serverMs);
            //Logger.Write($"AttackGym Count: {_pos}");

            var inventory = sessison.Inventory;

            if (attacker != null && defender != null)
            {
                var move1 = PokemonMoveMetaRegistry.GetMeta(attacker.Move1);
                var move2 = PokemonMoveMetaRegistry.GetMeta(attacker.Move2);
                //  Logger.Write($"Retrieved Move Metadata, Move1: {move1.GetTime()} - Move2: {move2.GetTime()}");

                var moveSetting = await inventory.GetMoveSetting(attacker.Move1);

                var specialMove = await inventory.GetMoveSetting(attacker.Move2);

                BattleAction action2 = new BattleAction();
                now                     = now.AddMilliseconds(specialMove.DurationMs);
                action2.Type            = Math.Abs(specialMove.EnergyDelta) < energy? BattleActionType.ActionSpecialAttack : BattleActionType.ActionAttack;
                action2.DurationMs      = specialMove.DurationMs;
                action2.ActionStartMs   = now.ToUnixTime();
                action2.TargetIndex     = -1;
                action2.ActivePokemonId = attacker.Id;

                action2.DamageWindowsStartTimestampMs = specialMove.DamageWindowStartMs;
                action2.DamageWindowsEndTimestampMs   = specialMove.DamageWindowEndMs;
                actions.Add(action2);

                return(actions);
            }
            BattleAction action1 = new BattleAction();

            now                   = now.AddMilliseconds(500);
            action1.Type          = BattleActionType.ActionAttack;
            action1.DurationMs    = 500;
            action1.ActionStartMs = now.ToUnixTime();
            action1.TargetIndex   = -1;
            if (defender != null)
            {
                action1.ActivePokemonId = attacker.Id;
            }

            actions.Add(action1);

            return(actions);
        }
예제 #2
0
        public static List <BattleAction> GetActions(long serverMs, PokemonData attacker, int energy)
        {
            Random rnd = new Random();
            List <BattleAction> actions = new List <BattleAction>();
            DateTime            now     = DateTimeFromUnixTimestampMillis(serverMs);

            Logger.Write($"AttackGym Count: {_pos}");

            if (attacker != null)
            {
                var move1 = PokemonMoveMetaRegistry.GetMeta(attacker.Move1);
                var move2 = PokemonMoveMetaRegistry.GetMeta(attacker.Move2);
                Logger.Write($"Retrieved Move Metadata, Move1: {move1.GetTime()} - Move2: {move2.GetTime()}");

                switch (_pos)
                {
                case 0:
                    for (int x = 0; x < 3; x++)
                    {
                        BattleAction action = new BattleAction();
                        now                    = now.AddMilliseconds(move1.GetTime());
                        action.Type            = BattleActionType.ActionAttack;
                        action.DurationMs      = move1.GetTime();
                        action.ActionStartMs   = now.ToUnixTime();
                        action.TargetIndex     = -1;
                        action.ActivePokemonId = attacker.Id;
                        // action.DamageWindowsStartTimestampMss = now.ToUnixTime() - 200;
                        //action.DamageWindowsEndTimestampMss = now.ToUnixTime();
                        actions.Add(action);
                    }
                    _pos++;
                    break;

                case 1:
                    _pos++;
                    break;

                default:
                    for (int x = 0; x < 3; x++)
                    {
                        BattleAction action = new BattleAction();

                        //if (x == 2 && currentAttackerEnergy > move2.GetEnergy())
                        //{
                        //    // Special Attack
                        //    now = now.AddMilliseconds(move2.GetTime());
                        //    action.Type = BattleActionType.ActionSpecialAttack;
                        //    action.DurationMs = move2.GetTime();
                        //}
                        //else
                        //{
                        //    // Basic Attack
                        //    now = now.AddMilliseconds(move1.GetTime());
                        //    action.Type = BattleActionType.ActionAttack;
                        //    action.DurationMs = move1.GetTime();
                        //}

                        // Basic Attack
                        now               = now.AddMilliseconds(move1.GetTime());
                        action.Type       = BattleActionType.ActionAttack;
                        action.DurationMs = move1.GetTime();

                        action.ActionStartMs   = now.ToUnixTime();
                        action.TargetIndex     = -1;
                        action.ActivePokemonId = attacker.Id;
                        //action.DamageWindowsStartTimestampMss = now.ToUnixTime() - 200;
                        //action.DamageWindowsEndTimestampMss = now.ToUnixTime();

                        //
                        actions.Add(action);
                    }
                    _pos++;
                    break;
                }
            }



            return(actions);
        }