-
-
Notifications
You must be signed in to change notification settings - Fork 992
/
display_context.hpp
106 lines (77 loc) · 2.48 KB
/
display_context.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*
Copyright (C) 2014 by Chris Beck <render787@gmail.com>
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
*/
/**
*
* This class is an abstract base class designed to simplify the use
* of the display object.
*
**/
#ifndef DISPLAY_CONTEXT_HPP_INCLUDED
#define DISPLAY_CONTEXT_HPP_INCLUDED
#include <string>
#include <vector>
class team;
class gamemap;
class unit_map;
class unit;
struct map_location;
struct team_data
{
team_data() :
units(0),
upkeep(0),
villages(0),
expenses(0),
net_income(0),
gold(0),
teamname()
{
}
int units, upkeep, villages, expenses, net_income, gold;
std::string teamname;
};
class display_context {
public:
virtual const std::vector<team> & teams() const = 0;
virtual const gamemap & map() const = 0;
virtual const unit_map & units() const = 0;
// Helper for is_visible_to_team
/**
* Given a location and a side number, indicates whether an invisible unit of that side at that
* location would be revealed (perhaps ambushed), based on what team side_num can see.
* If see_all is true then the calculation ignores fog, and enemy ambushers.
*/
bool would_be_discovered(const map_location & loc, int side_num, bool see_all = true);
// Needed for reports
const unit * get_visible_unit(const map_location &loc, const team ¤t_team, bool see_all = false) const;
// From actions:: namespace
bool unit_can_move(const unit & u) const;
// From class team
/**
* Given the location of a village, will return the 0-based index
* of the team that currently owns it, and -1 if it is unowned.
*/
int village_owner(const map_location & loc) const;
// Accessors from unit.cpp
/** Returns the number of units of the side @a side_num. */
int side_units(int side_num) const;
/** Returns the total cost of units of side @a side_num. */
int side_units_cost(int side_num) const ;
int side_upkeep(int side_num) const ;
team_data calculate_team_data(const class team& tm, int side) const;
// Accessor from team.cpp
/// Check if we are an observer in this game
bool is_observer() const;
// Dtor
virtual ~display_context() {}
};
#endif