Beispiel #1
0
  void User::SendPokemonTeam (PokemonTeam& pokemonTeam)
  {
    yap::Packet packet;
    packet.CreateFromType (yap::PacketType::ServerInfoPokemonTeam);

    // Send the number of Pokemon in the team
    int pokemonNumber = pokemonTeam.GetPokemonCount ();
    packet.Write (pokemonNumber);

    Pokemon* currentPokemon = nullptr;

    for (int i = 0; i < pokemonNumber; i++)
    {
      currentPokemon = &pokemonTeam.GetPokemon (i);

      // Write the current pokemon basic information in the packet
      packet.Write (currentPokemon->GetStaticID ());
      packet.Write (currentPokemon->GetUniqueID ());
      packet.Write (static_cast<yap::UInt8>(currentPokemon->GetGender ()));
      packet.Write (static_cast<yap::UInt8>(currentPokemon->GetStatus ()));
      packet.Write (currentPokemon->GetNickname ());
      packet.Write (currentPokemon->GetShiny ());
      packet.Write (currentPokemon->GetLoyalty ());
      packet.Write (currentPokemon->GetNatureID ());
      packet.Write (currentPokemon->GetTotalExperience ());
      packet.Write (currentPokemon->GetBoxNumber ());
      packet.Write (currentPokemon->GetBoxIndex ());
      packet.Write (currentPokemon->GetCatchDate ());
      packet.Write (currentPokemon->GetCurrentHP ());

      // Write the current Pokemon's stats
      const yap::PokemonStat& stats = currentPokemon->GetStats ();

      // Send EV
      packet.Write (stats.GetHitPoint ().GetEffortValue ());
      packet.Write (stats.GetAttack ().GetEffortValue ());
      packet.Write (stats.GetDefense ().GetEffortValue ());
      packet.Write (stats.GetSpecialAttack ().GetEffortValue ());
      packet.Write (stats.GetSpecialDefense ().GetEffortValue ());
      packet.Write (stats.GetSpeed ().GetEffortValue ());

      // Send IV
      packet.Write (stats.GetHitPoint ().GetIndividualValue ());
      packet.Write (stats.GetAttack ().GetIndividualValue ());
      packet.Write (stats.GetDefense ().GetIndividualValue ());
      packet.Write (stats.GetSpecialAttack ().GetIndividualValue ());
      packet.Write (stats.GetSpecialDefense ().GetIndividualValue ());
      packet.Write (stats.GetSpeed ().GetIndividualValue ());

      // Send Pokemon's moves
      const yap::PokemonMoveSet& moveSet =
        currentPokemon->GetMoveSet ();
      yap::UInt8 moveNumber = currentPokemon->GetMoveSet ().GetMoveNumber ();

      // Send the move number of the Pokemon
      packet.Write (moveNumber);

      for (yap::UInt8 index = 0; index < 4; index++)
      {
        if (moveSet.GetMove (index) != nullptr)
        {
          packet.Write (moveSet.GetMove (index)->GetStaticID ());
          packet.Write (index);
          packet.Write (moveSet.GetMove (index)->GetCurrentPP ());
          packet.Write (moveSet.GetMove (index)->GetMaxPP ());
        }
      }

    }

    SendPacket (packet);
  }