YAPOG  0.0.1
Yet Another Pokemon Online Game
PokemonMoveSelectRequest.cpp
Go to the documentation of this file.
6 
9 
10 namespace yse
11 {
13  : databaseManager_ (dm)
14  {
15  }
16 
17  /*
18  bool PokemonMoveSelectRequest::Select (PokemonMoveTable& pokemonTable)
19  {
20  yap::String queryString =
21  "SELECT "
22  "account_id, "
23  "pokemon_static_id, "
24  "pokemon_experience, "
25  "pokemon_gender, "
26  "pokemon_nickname, "
27  "pokemon_level, "
28  "pokemon_shiny, "
29  "pokemon_loyalty, "
30  "pokemon_nature, "
31  "pokemon_trading_number, "
32  "pokemon_trader_account_id, "
33  "pokemon_box_number, "
34  "pokemon_box_index, "
35  "pokemon_catch_date "
36  "FROM pokemon "
37  "WHERE pokemon_id = :pokemonID";
38 
39  yap::DatabaseStream select (
40  queryString,
41  databaseManager_.GetConnection ());
42 
43  select.Write (pokemonTable.GetID ());
44 
45  if (select.EndOfStream ())
46  throw yap::DatabaseException ("This pokemon doesn't exist !");
47 
48  pokemonTable.SetAccountID (select.ReadID ());
49  pokemonTable.SetStaticID (select.ReadID ());
50  pokemonTable.SetExperience (select.ReadUInt ());
51  pokemonTable.SetGender (select.ReadUInt ());
52  pokemonTable.SetNickname (select.ReadString ());
53  pokemonTable.SetLevel (select.ReadUInt ());
54  pokemonTable.SetShiny (select.ReadBool ());
55  pokemonTable.SetLoyalty (select.ReadInt ());
56  pokemonTable.SetNature (select.ReadID ());
57  pokemonTable.SetTradingNumber (select.ReadUInt ());
58  pokemonTable.SetTraderAccountID (select.ReadID ());
59  pokemonTable.SetBoxNumber (select.ReadUInt ());
60  pokemonTable.SetBoxIndex (select.ReadID ());
61  pokemonTable.SetCatchDate (select.ReadString ());
62 
63  if (!select.EndOfStream ())
64  throw yap::DatabaseException ("Pokemon information loading error !");
65 
66  return false;
67  }
68  */
69 
71  const yap::ID& pokemonID)
72  {
73  yap::String queryString =
74  "SELECT "
75  "pokemon_move_static_id, "
76  "pokemon_move_index, "
77  "pokemon_move_pp, "
78  "pokemon_move_max_pp "
79  "FROM pokemon_move "
80  "WHERE pokemon_id = :pokemonID";
81 
82  yap::DatabaseStream select (
83  queryString,
85 
86  select.Write (pokemonID);
87 
88  if (select.EndOfStream ())
89  throw yap::DatabaseException ("This pokemon's moves doesn't exist !");
90 
92 
93  for (int i = 0; i < yap::Pokemon::MAX_POKEMON_MOVE_NUMBER; i++)
94  {
95  yap::ID moveID = select.ReadID ();
96 
97  if (moveID != yap::ID (0))
98  {
99  yap::PokemonMove* move = new yap::PokemonMove (moveID);
100  yap::UInt16 index = select.ReadUInt16 ();
101  move->SetPP (select.ReadUInt16 ());
102  move->SetMaxPP (select.ReadUInt16 ());
103 
104  moves->AddMove (move, index);
105  }
106  else
107  {
108  select.ReadUInt16 ();
109  select.ReadUInt16 ();
110  select.ReadUInt16 ();
111  }
112  }
113 
114  if (!select.EndOfStream ())
115  throw yap::DatabaseException ("Pokemon move information loading error !");
116 
117  return moves;
118  }
119 
120 } // namespace yse