YAPOG  0.0.1
Yet Another Pokemon Online Game
BattleScreen.cpp
Go to the documentation of this file.
5 
7 #include "Game.hpp"
8 #include "Battle/WildBattle.hpp"
10 #include "Pokemon/Pokemon.hpp"
11 #include "Pokemon/PokemonTeam.hpp"
12 #include "Battle/PokemonFighter.hpp"
13 #include "Battle/PokemonFighterTeam.hpp"
14 #include "Client/Session.hpp"
15 #include "Battle/PlayerTrainer.hpp"
17 
18 namespace ycl
19 {
21 
23  : BaseScreen (DEFAULT_NAME, context)
24  , battle_ (nullptr)
25  , battleInterface_ (nullptr)
26  {
27  }
28 
30  {
31  }
32 
34  {
36 
38 
40  }
41 
43  const yap::Time& dt,
44  yap::IDrawingContext& context)
45  {
46  context.SetMode ("Battle");
47 
48  battle_->Update (dt);
49  battle_->Draw (context);
50 
51  context.SetDefaultCamera ();
52 
53  BaseScreen::HandleRun (dt, context);
54  }
55 
57  {
58  BattleParameters& parameters =
60 
61  // Create a PokemonTeamFighter from the player's PokemonTeam
62  PokemonTeam& playerTeam = session_.GetUser ().GetTrainer ().GetTeam ();
63 
64  PokemonFighterTeam* playerFighterTeam = new PokemonFighterTeam ();
65  playerFighterTeam->LoadFromPokemonTeam (playerTeam, false);
66 
67  switch (parameters.GetBattleType ())
68  {
70 
72 
73  battle_->SetPlayerTeam (playerFighterTeam);
74  battle_->SetOpponent (&parameters.GetOpponent ());
75  battle_->Init ();
76 
78  [&] (const yap::Battle& sender, const yap::EmptyEventArgs& args)
79  {
81  nextScreen_ = "Gameplay";
82  };
83 
84  // Team Manager Widget
85  PokemonTeamWidget* pokemonTeamWidget = new PokemonTeamWidget (
87  battleInterface_->AddBattleWidget ("PokemonTeam", pokemonTeamWidget);
88 
89  yap::AudioManager::Instance ().PlayMusic ("BGM/WildPokemonBattleShort.ogg");
90  }
91  }
92 
94  {
96  }
97 
99  {
100  battle_ = value;
101  }
102 } // namespace ycl