-
-
Notifications
You must be signed in to change notification settings - Fork 988
/
playcampaign.hpp
88 lines (77 loc) · 2.31 KB
/
playcampaign.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
/*
Copyright (C) 2003-2005 by David White <dave@whitevine.net>
Copyright (C) 2005 - 2017 by Philippe Plantier <ayin@anathas.org>
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 */
#pragma once
#include "game_end_exceptions.hpp"
#include <memory>
#include <sstream>
#include <set>
#include <string>
class CVideo;
class saved_game;
class terrain_type_data;
class team;
class playsingle_controller;
typedef std::shared_ptr<terrain_type_data> ter_data_cache;
class config;
class wesnothd_connection;
struct mp_campaign_info
{
mp_campaign_info(wesnothd_connection& wdc)
: connected_players()
, is_host()
, current_turn(0)
, skip_replay(false)
, skip_replay_blindfolded(false)
, connection(wdc)
{
}
/// players and observers
std::set<std::string> connected_players;
bool is_host;
unsigned current_turn;
bool skip_replay;
bool skip_replay_blindfolded;
wesnothd_connection& connection;
};
class campaign_controller
{
saved_game& state_;
const config& game_config_;
const ter_data_cache & tdata_;
const bool is_unit_test_;
bool is_replay_;
mp_campaign_info* mp_info_;
public:
campaign_controller(saved_game& state, const config& game_config, const ter_data_cache & tdata, bool is_unit_test = false)
: state_(state)
, game_config_(game_config)
, tdata_(tdata)
, is_unit_test_(is_unit_test)
, is_replay_(false)
, mp_info_(nullptr)
{
}
LEVEL_RESULT play_game();
LEVEL_RESULT play_replay()
{
is_replay_ = true;
return play_game();
}
void set_mp_info(mp_campaign_info* mp_info) { mp_info_ = mp_info; }
private:
LEVEL_RESULT playsingle_scenario(end_level_data &end_level);
LEVEL_RESULT playmp_scenario(end_level_data &end_level);
void show_carryover_message(playsingle_controller& playcontroller, const end_level_data& end_level, LEVEL_RESULT res);
static void report_victory(std::ostringstream &report, team& t, int finishing_bonus_per_turn, int turns_left, int finishing_bonus);
};