The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
display_context.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014 - 2016 by Chris Beck <[email protected]>
3  Part of the Battle for Wesnoth Project http://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 /**
16  *
17  * This class is an abstract base class designed to simplify the use
18  * of the display object.
19  *
20  **/
21 
22 #ifndef DISPLAY_CONTEXT_HPP_INCLUDED
23 #define DISPLAY_CONTEXT_HPP_INCLUDED
24 
25 #include <string>
26 #include <vector>
27 
28 class team;
29 class gamemap;
30 class unit_map;
31 
32 class unit;
33 struct map_location;
34 
35 struct team_data
36 {
38  units(0),
39  upkeep(0),
40  villages(0),
41  expenses(0),
42  net_income(0),
43  gold(0),
44  teamname()
45  {
46  }
47 
50 };
51 
53 public:
54  virtual const std::vector<team> & teams() const = 0;
55  virtual const gamemap & map() const = 0;
56  virtual const unit_map & units() const = 0;
57  virtual const std::vector<std::string> & hidden_label_categories() const = 0;
58  std::vector<std::string> & hidden_label_categories_ref();
59 
60  // Helper for is_visible_to_team
61 
62  /**
63  * Given a location and a side number, indicates whether an invisible unit of that side at that
64  * location would be revealed (perhaps ambushed), based on what team side_num can see.
65  * If see_all is true then the calculation ignores fog, and enemy ambushers.
66  */
67  bool would_be_discovered(const map_location & loc, int side_num, bool see_all = true);
68 
69  // Needed for reports
70 
71  const unit * get_visible_unit(const map_location &loc, const team &current_team, bool see_all = false) const;
72 
73  // From actions:: namespace
74 
75  bool unit_can_move(const unit & u) const;
76 
77  // From class team
78 
79  /**
80  * Given the location of a village, will return the 0-based index
81  * of the team that currently owns it, and -1 if it is unowned.
82  */
83  int village_owner(const map_location & loc) const;
84 
85  // Accessors from unit.cpp
86 
87  /** Returns the number of units of the side @a side_num. */
88  int side_units(int side_num) const;
89 
90  /** Returns the total cost of units of side @a side_num. */
91  int side_units_cost(int side_num) const ;
92 
93  int side_upkeep(int side_num) const ;
94 
95  team_data calculate_team_data(const class team& tm, int side) const;
96 
97  // Accessor from team.cpp
98 
99  /// Check if we are an observer in this game
100  bool is_observer() const;
101 
102  // Dtor
103 
104  virtual ~display_context() {}
105 };
106 
107 
108 #endif
int side_units(int side_num) const
Returns the number of units of the side side_num.
Definition: unit.hpp:95
std::vector< std::string > & hidden_label_categories_ref()
int village_owner(const map_location &loc) const
Given the location of a village, will return the 0-based index of the team that currently owns it...
bool unit_can_move(const unit &u) const
Will return true iff the unit u has any possible moves it can do (including attacking etc)...
virtual const gamemap & map() const =0
int side_upkeep(int side_num) const
This class stores all the data for a single 'side' (in game nomenclature).
Definition: team.hpp:50
virtual ~display_context()
Encapsulates the map of the game.
Definition: map.hpp:37
virtual const unit_map & units() const =0
Encapsulates the map of the game.
Definition: location.hpp:38
virtual const std::vector< team > & teams() const =0
int side_units_cost(int side_num) const
Returns the total cost of units of side side_num.
bool is_observer() const
Check if we are an observer in this game.
Container associating units to locations.
Definition: map.hpp:90
virtual const std::vector< std::string > & hidden_label_categories() const =0
const unit * get_visible_unit(const map_location &loc, const team &current_team, bool see_all=false) const
bool would_be_discovered(const map_location &loc, int side_num, bool see_all=true)
Given a location and a side number, indicates whether an invisible unit of that side at that location...
GLsizei const GLcharARB ** string
Definition: glew.h:4503
team_data calculate_team_data(const class team &tm, int side) const
std::string teamname