-
-
Notifications
You must be signed in to change notification settings - Fork 994
/
move.hpp
127 lines (85 loc) · 3.32 KB
/
move.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*
Copyright (C) 2003 - 2015 by David White <dave@whitevine.net>
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.
*/
/**
* @file
* Various functions related to moving units.
*/
#ifndef ACTIONS_MOVE_H_INCLUDED
#define ACTIONS_MOVE_H_INCLUDED
struct map_location;
class replay;
class unit;
#include "../unit_map.hpp"
#include <vector>
namespace actions {
class undo_list;
class move_unit_spectator {
public:
/** add a location of a seen friend */
void add_seen_friend(const unit_map::const_iterator &u);
/** add the location of new seen enemy */
void add_seen_enemy(const unit_map::const_iterator &u);
/** get the location of an ambusher */
const unit_map::const_iterator& get_ambusher() const;
/** get the location of a failed teleport */
const unit_map::const_iterator& get_failed_teleport() const;
/** get the locations of seen enemies */
const std::vector<unit_map::const_iterator>& get_seen_enemies() const;
/** get the locations of seen friends */
const std::vector<unit_map::const_iterator>& get_seen_friends() const;
/** get new location of moved unit */
const unit_map::const_iterator& get_unit() const;
/** constructor */
move_unit_spectator(const unit_map &units);
/** destructor */
virtual ~move_unit_spectator();
/** reset all locations to empty values*/
void reset(const unit_map &units);
/** set the location of an ambusher */
void set_ambusher(const unit_map::const_iterator &u);
/** set the location of a failed teleport */
void set_failed_teleport(const unit_map::const_iterator &u);
/** set the iterator to moved unit*/
void set_unit(const unit_map::const_iterator &u);
private:
unit_map::const_iterator ambusher_;
unit_map::const_iterator failed_teleport_;
std::vector<unit_map::const_iterator> seen_enemies_;
std::vector<unit_map::const_iterator> seen_friends_;
unit_map::const_iterator unit_;
};
/**
* Makes it so the village at the given location is owned by the given side.
* Returns true if getting the village triggered a mutating event.
*/
bool get_village(const map_location& loc, int side, int *time_bonus = NULL, bool fire_event = true);
/// Moves a unit across the board.
/// And enters the synced context.
size_t move_unit_and_record(const std::vector<map_location> &steps,
undo_list* undo_stack,
bool continued_move = false,
bool show_move = true,
bool* interrupted = NULL,
move_unit_spectator* move_spectator = NULL);
/// Moves a unit across the board.
/// to be called from replay when we are already in the synced context.
size_t move_unit_from_replay(const std::vector<map_location> &steps,
undo_list* undo_stack,
bool continued_move, bool skip_ally_sighted,
bool show_move = true);
/**
* Will return true iff the unit @a u has any possible moves
* it can do (including attacking etc).
*/
bool unit_can_move(const unit &u);
}//namespace actions
#endif