internal PBEPokemon(PBETeam team, byte id, PBEPokemonShell shell)
        {
            Team    = team;
            Id      = id;
            Species = OriginalSpecies = KnownSpecies = shell.Species;
            var pData = PBEPokemonData.GetData(Species);

            KnownType1       = Type1 = pData.Type1;
            KnownType2       = Type2 = pData.Type2;
            KnownWeight      = Weight = pData.Weight;
            Nickname         = KnownNickname = shell.Nickname;
            Level            = shell.Level;
            Friendship       = shell.Friendship;
            Shiny            = KnownShiny = shell.Shiny;
            Ability          = OriginalAbility = shell.Ability;
            KnownAbility     = PBEAbility.MAX;
            Nature           = shell.Nature;
            Gender           = KnownGender = shell.Gender;
            Item             = OriginalItem = shell.Item;
            KnownItem        = (PBEItem)ushort.MaxValue;
            EffortValues     = new PBEEffortValues(shell.EffortValues);
            IndividualValues = new PBEIndividualValues(shell.IndividualValues);
            SetStats();
            HP                   = MaxHP;
            HPPercentage         = 1D;
            OriginalMoveset      = new PBEMoveset(shell.Moveset);
            Moves                = new PBEBattleMoveset(OriginalMoveset);
            KnownMoves           = new PBEBattleMoveset(Team.Battle.Settings);
            TransformBackupMoves = new PBEBattleMoveset(Team.Battle.Settings);
            team.Party.Add(this);
        }
        // This constructor is to define a remote Pokémon
        public PBEPokemon(PBETeam team, PBEPkmnSwitchInPacket.PBESwitchInInfo info)
        {
            if (team == null)
            {
                throw new ArgumentNullException(nameof(team));
            }
            if (info == null)
            {
                throw new ArgumentNullException(nameof(info));
            }
            Team                 = team;
            Id                   = info.PokemonId;
            FieldPosition        = info.FieldPosition;
            HP                   = info.HP;
            MaxHP                = info.MaxHP;
            HPPercentage         = info.HPPercentage;
            Status1              = info.Status1;
            Level                = info.Level;
            KnownAbility         = Ability = OriginalAbility = PBEAbility.MAX;
            KnownGender          = Gender = info.Gender;
            KnownItem            = Item = OriginalItem = (PBEItem)ushort.MaxValue;
            Moves                = new PBEBattleMoveset(Team.Battle.Settings);
            KnownMoves           = new PBEBattleMoveset(Team.Battle.Settings);
            TransformBackupMoves = new PBEBattleMoveset(Team.Battle.Settings);
            KnownNickname        = Nickname = info.Nickname;
            KnownShiny           = Shiny = info.Shiny;
            KnownSpecies         = Species = OriginalSpecies = info.Species;
            var pData = PBEPokemonData.GetData(KnownSpecies);

            KnownType1  = Type1 = pData.Type1;
            KnownType2  = Type2 = pData.Type2;
            KnownWeight = Weight = pData.Weight;
            Team.Party.Add(this);
        }
        internal PBEPokemon(BinaryReader r, PBETeam team)
        {
            Team    = team;
            Id      = r.ReadByte();
            Species = OriginalSpecies = KnownSpecies = (PBESpecies)r.ReadUInt32();
            var pData = PBEPokemonData.GetData(Species);

            KnownType1       = Type1 = pData.Type1;
            KnownType2       = Type2 = pData.Type2;
            KnownWeight      = Weight = pData.Weight;
            Nickname         = KnownNickname = PBEUtils.StringFromBytes(r);
            Level            = r.ReadByte();
            Friendship       = r.ReadByte();
            Shiny            = KnownShiny = r.ReadBoolean();
            Ability          = OriginalAbility = (PBEAbility)r.ReadByte();
            KnownAbility     = PBEAbility.MAX;
            Nature           = (PBENature)r.ReadByte();
            Gender           = KnownGender = (PBEGender)r.ReadByte();
            Item             = OriginalItem = (PBEItem)r.ReadUInt16();
            KnownItem        = (PBEItem)ushort.MaxValue;
            EffortValues     = new PBEEffortValues(Team.Battle.Settings, r);
            IndividualValues = new PBEIndividualValues(Team.Battle.Settings, r);
            SetStats();
            HP                   = MaxHP;
            HPPercentage         = 1D;
            OriginalMoveset      = new PBEMoveset(Species, Level, Team.Battle.Settings, r);
            Moves                = new PBEBattleMoveset(OriginalMoveset);
            KnownMoves           = new PBEBattleMoveset(Team.Battle.Settings);
            TransformBackupMoves = new PBEBattleMoveset(Team.Battle.Settings);
            Team.Party.Add(this);
        }
Esempio n. 4
0
 public void UpdateFromBattle(PBEBattleMoveset moves)
 {
     for (int i = 0; i < _slots.Length; i++)
     {
         _slots[i].UpdateFromBattle(moves[i]);
     }
 }
 /// <summary>Transforms into <paramref name="target"/> and sets <see cref="PBEStatus2.Transformed"/>.</summary>
 /// <param name="target">The Pokémon to transform into.</param>
 /// <remarks>Frees the Pokémon of its <see cref="ChoiceLockedMove"/>.</remarks>
 public void Transform(PBEPokemon target)
 {
     if (target == null)
     {
         throw new ArgumentNullException(nameof(target));
     }
     if (Team != target.Team)
     {
         KnownAbility = target.KnownAbility = Ability = target.Ability;
         KnownType1   = target.KnownType1 = Type1 = target.Type1;
         KnownType2   = target.KnownType2 = Type2 = target.Type2;
         KnownWeight  = target.KnownWeight = Weight = target.Weight;
     }
     else
     {
         Ability      = target.Ability;
         KnownAbility = target.KnownAbility;
         Type1        = target.Type1;
         KnownType1   = target.KnownType1;
         Type2        = target.Type2;
         KnownType2   = target.KnownType2;
         Weight       = target.Weight;
         KnownWeight  = target.KnownWeight;
     }
     KnownGender     = target.KnownGender = target.Gender;
     KnownShiny      = target.KnownShiny = target.Shiny;
     KnownSpecies    = target.KnownSpecies = Species = target.Species;
     Attack          = target.Attack;
     Defense         = target.Defense;
     SpAttack        = target.SpAttack;
     SpDefense       = target.SpDefense;
     Speed           = target.Speed;
     AttackChange    = target.AttackChange;
     DefenseChange   = target.DefenseChange;
     SpAttackChange  = target.SpAttackChange;
     SpDefenseChange = target.SpDefenseChange;
     SpeedChange     = target.SpeedChange;
     AccuracyChange  = target.AccuracyChange;
     EvasionChange   = target.EvasionChange;
     TransformBackupMoves.Reset(Moves);
     PBEBattleMoveset.DoTransform(this, target);
     if (!Moves.Contains(ChoiceLockedMove))
     {
         ChoiceLockedMove = PBEMove.None;
     }
     Status2 |= PBEStatus2.Transformed;
 }
Esempio n. 6
0
 private void CreateMoveChoices()
 {
     if (_moveChoices is null)
     {
         PBEBattleMoveset moves       = _pkmn.Moves;
         PBEMove[]        usableMoves = _pkmn.GetUsableMoves();
         _moveChoices = new TextGUIChoices(0.75f, 0.75f, bottomAlign: true, backCommand: SetCallbacksForAllChoices,
                                           font: Font.Default, fontColors: Font.DefaultWhite_I, selectedColors: Font.DefaultYellow_O, disabledColors: Font.DefaultDisabled);
         for (int i = 0; i < PkmnConstants.NumMoves; i++)
         {
             PBEBattleMoveset.PBEBattleMovesetSlot slot = moves[i];
             PBEMove m       = slot.Move;
             string  text    = PBEDataProvider.Instance.GetMoveName(m).English;
             bool    enabled = Array.IndexOf(usableMoves, m) != -1;
             Action  command = enabled ? () => SelectMoveForTurn(m) : null;
             _moveChoices.Add(new TextGUIChoice(text, command, isEnabled: enabled));
         }
     }
 }
Esempio n. 7
0
        private void FightChoice()
        {
            PBEBattlePokemon pkmn = _pkmn.Pkmn;
            // Check if there's a move we must use
            bool auto = false;

            if (pkmn.IsForcedToStruggle())
            {
                pkmn.TurnAction = new PBETurnAction(pkmn, PBEMove.Struggle, PBEBattleUtils.GetPossibleTargets(pkmn, pkmn.GetMoveTargets(PBEMove.Struggle))[0]);
                auto            = true;
            }
            else if (pkmn.TempLockedMove != PBEMove.None)
            {
                pkmn.TurnAction = new PBETurnAction(pkmn, pkmn.TempLockedMove, pkmn.TempLockedTargets);
                auto            = true;
            }
            if (auto)
            {
                _parent.ActionsLoop(false);
                return;
            }

            // Create move choices if it's not already created
            if (_moveChoices is null)
            {
                PBEBattleMoveset moves       = pkmn.Moves;
                PBEMove[]        usableMoves = pkmn.GetUsableMoves();
                _moveChoices = new GUIChoices(0.8f, 0.7f, 0.06f, backCommand: () => _isShowingMoves = false,
                                              font: Font.Default, fontColors: Font.DefaultWhite, selectedColors: Font.DefaultSelected, disabledColors: Font.DefaultDisabled);
                for (int i = 0; i < PBESettings.DefaultNumMoves; i++)
                {
                    PBEBattleMoveset.PBEBattleMovesetSlot slot = moves[i];
                    PBEMove m       = slot.Move;
                    string  text    = PBELocalizedString.GetMoveName(m).English;
                    bool    enabled = Array.IndexOf(usableMoves, m) != -1;
                    Action  command = enabled ? () => SelectMoveForTurn(m) : (Action)null;
                    _moveChoices.Add(new GUIChoice(text, command, isEnabled: enabled));
                }
            }

            // Show moves
            _isShowingMoves = true;
        }
 public void UpdateKnownPP(PBEMove move, int amountReduced)
 {
     if (move == PBEMove.None || move >= PBEMove.MAX || !Enum.IsDefined(typeof(PBEMove), move))
     {
         throw new ArgumentOutOfRangeException(nameof(move));
     }
     PBEBattleMoveset.PBEBattleMovesetSlot knownSlot = KnownMoves[move];
     knownSlot.PP += amountReduced;
     if (knownSlot.MaxPP == 0)
     {
         if (Status2.HasFlag(PBEStatus2.Transformed))
         {
             knownSlot.MaxPP = PBEBattleMoveset.GetTransformPP(Team.Battle.Settings, move);
         }
         else if (Team.Battle.Settings.MaxPPUps == 0 || knownSlot.PP > PBEBattleMoveset.GetNonTransformPP(Team.Battle.Settings, move, (byte)(Team.Battle.Settings.MaxPPUps - 1)))
         {
             knownSlot.MaxPP = PBEBattleMoveset.GetNonTransformPP(Team.Battle.Settings, move, Team.Battle.Settings.MaxPPUps);
         }
     }
 }
Esempio n. 9
0
        private unsafe void DrawMovesPage(uint *bmpAddress, int bmpWidth, int bmpHeight)
        {
            const float winX         = 0.08f;
            const float winY         = 0.15f;
            const float winW         = 0.75f - winX;
            const float winH         = 0.9f - winY;
            const float moveColX     = winX + 0.03f;
            const float moveTextX    = moveColX + 0.02f;
            const float moveColW     = 0.69f - winX;
            const float itemSpacingY = winH / (PkmnConstants.NumMoves + 0.75f);
            const float moveX        = 0.21f;
            const float moveY        = 0.03f;
            const float ppX          = 0.12f;
            const float ppNumX       = 0.35f;
            const float ppY          = itemSpacingY / 2;
            const float cancelY      = winY + moveY + (PkmnConstants.NumMoves * itemSpacingY);

            RenderUtils.FillRoundedRectangle(bmpAddress, bmpWidth, bmpHeight, winX, winY, winX + winW, winY + winH, 15, RenderUtils.Color(250, 128, 120, 255));

            Font moveFont = Font.Default;

            uint[] moveColors = Font.DefaultWhite_DarkerOutline_I;
            uint[] ppColors   = Font.DefaultBlack_I;

            void Place(int i, PBEMove move, int pp, int maxPP)
            {
                PBEMoveData mData = PBEMoveData.Data[move];
                float       x     = moveTextX;
                float       y     = winY + moveY + (i * itemSpacingY);
                string      str   = PBELocalizedString.GetTypeName(mData.Type).English;

                moveFont.DrawString(bmpAddress, bmpWidth, bmpHeight, x, y, str, moveColors);
                x  += moveX;
                str = PBELocalizedString.GetMoveName(move).English;
                moveFont.DrawString(bmpAddress, bmpWidth, bmpHeight, x, y, str, moveColors);
                x   = moveTextX + ppX;
                y  += ppY;
                str = "PP";
                moveFont.DrawString(bmpAddress, bmpWidth, bmpHeight, x, y, str, ppColors);
                x   = moveTextX + ppNumX;
                str = string.Format("{0}/{1}", pp, maxPP);
                moveFont.MeasureString(str, out int strW, out _);
                moveFont.DrawString(bmpAddress, bmpWidth, bmpHeight, RenderUtils.GetCoordinatesForCentering(bmpWidth, strW, x), (int)(bmpHeight * y), str, ppColors);

                DrawSelection(i);
            }

            void DrawSelection(int i)
            {
                if (_selectingMove != i)
                {
                    return;
                }
                float x = moveColX;
                float y = winY + moveY + (i * itemSpacingY);
                float w = moveColW;
                float h = i == PkmnConstants.NumMoves ? itemSpacingY / 2 : itemSpacingY;

                RenderUtils.DrawRoundedRectangle(bmpAddress, bmpWidth, bmpHeight, x, y, x + w, y + h, 5, RenderUtils.Color(48, 180, 255, 200));
            }

            // Moves
            if (_pPkmn is not null)
            {
                Moveset moves = _pPkmn.Moveset;
                for (int m = 0; m < PkmnConstants.NumMoves; m++)
                {
                    Moveset.MovesetSlot slot = moves[m];
                    PBEMove             move = slot.Move;
                    if (move == PBEMove.None)
                    {
                        continue;
                    }
                    int pp    = slot.PP;
                    int maxPP = PBEDataUtils.CalcMaxPP(move, slot.PPUps, PkmnConstants.PBESettings);
                    Place(m, move, pp, maxPP);
                }
            }
            else if (_pcPkmn is not null)
            {
                BoxMoveset moves = _pcPkmn.Moveset;
                for (int m = 0; m < PkmnConstants.NumMoves; m++)
                {
                    BoxMoveset.BoxMovesetSlot slot = moves[m];
                    PBEMove move = slot.Move;
                    if (move == PBEMove.None)
                    {
                        continue;
                    }
                    int maxPP = PBEDataUtils.CalcMaxPP(move, slot.PPUps, PkmnConstants.PBESettings);
                    Place(m, move, maxPP, maxPP);
                }
            }
            else
            {
                PBEBattlePokemon bPkmn = _bPkmn.Pkmn;
                PBEBattleMoveset moves = bPkmn.Status2.HasFlag(PBEStatus2.Transformed) ? bPkmn.TransformBackupMoves : bPkmn.Moves;
                for (int m = 0; m < PkmnConstants.NumMoves; m++)
                {
                    PBEBattleMoveset.PBEBattleMovesetSlot slot = moves[m];
                    PBEMove move = slot.Move;
                    if (move == PBEMove.None)
                    {
                        continue;
                    }
                    int pp    = slot.PP;
                    int maxPP = slot.MaxPP;
                    Place(m, move, pp, maxPP);
                }
            }

            // Cancel or new move
            if (_learningMove != PBEMove.None)
            {
                uint[]      learnColors = Font.DefaultBlue_I;
                PBEMoveData mData       = PBEMoveData.Data[_learningMove];
                float       x           = moveTextX;
                string      str         = PBELocalizedString.GetTypeName(mData.Type).English;
                moveFont.DrawString(bmpAddress, bmpWidth, bmpHeight, x, cancelY, str, learnColors);
                x  += moveX;
                str = PBELocalizedString.GetMoveName(_learningMove).English;
                moveFont.DrawString(bmpAddress, bmpWidth, bmpHeight, x, cancelY, str, learnColors);
                DrawSelection(PkmnConstants.NumMoves);
            }
            else
            {
                if (_selectingMove != -1)
                {
                    string str = "Cancel";
                    moveFont.DrawString(bmpAddress, bmpWidth, bmpHeight, moveTextX, cancelY, str, moveColors);
                    DrawSelection(PkmnConstants.NumMoves);
                }
            }
        }