The Battle for Wesnoth  1.15.0-dev
playcampaign.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003-2005 by David White <dave@whitevine.net>
3  Copyright (C) 2005 - 2018 by Philippe Plantier <ayin@anathas.org>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 /** @file */
17 
18 #pragma once
19 
20 #include "game_end_exceptions.hpp"
21 
22 #include <memory>
23 #include <sstream>
24 #include <set>
25 #include <string>
26 
27 class saved_game;
28 class terrain_type_data;
29 class team;
31 typedef std::shared_ptr<terrain_type_data> ter_data_cache;
32 
33 class config;
34 
37 {
40  , is_host()
41  , current_turn(0)
42  , skip_replay(false)
44  , connection(wdc)
45  {
46 
47  }
48  /// players and observers
49  std::set<std::string> connected_players;
50  bool is_host;
51  unsigned current_turn;
55 };
56 
58 {
61  const bool is_unit_test_;
62  bool is_replay_;
64 public:
65  campaign_controller(saved_game& state, const ter_data_cache & tdata, bool is_unit_test = false)
66  : state_(state)
67  , tdata_(tdata)
68  , is_unit_test_(is_unit_test)
69  , is_replay_(false)
70  , mp_info_(nullptr)
71  {
72  }
73  LEVEL_RESULT play_game();
74  LEVEL_RESULT play_replay()
75  {
76  is_replay_ = true;
77  return play_game();
78  }
79  void set_mp_info(mp_campaign_info* mp_info) { mp_info_ = mp_info; }
80 private:
81  LEVEL_RESULT playsingle_scenario(end_level_data &end_level);
82  LEVEL_RESULT playmp_scenario(end_level_data &end_level);
83  void show_carryover_message(playsingle_controller& playcontroller, const end_level_data& end_level, LEVEL_RESULT res);
84  static void report_victory(std::ostringstream &report, team& t, int finishing_bonus_per_turn, int turns_left, int finishing_bonus);
85 };
LEVEL_RESULT play_replay()
bool skip_replay_blindfolded
mp_campaign_info * mp_info_
void set_mp_info(mp_campaign_info *mp_info)
std::set< std::string > connected_players
players and observers
saved_game & state_
Contains the exception interfaces used to signal completion of a scenario, campaign or turn...
This class stores all the data for a single &#39;side&#39; (in game nomenclature).
Definition: team.hpp:44
const ter_data_cache & tdata_
A class that represents a TCP/IP connection to the wesnothd server.
unsigned current_turn
const bool is_unit_test_
Additional information on the game outcome which can be provided by WML.
campaign_controller(saved_game &state, const ter_data_cache &tdata, bool is_unit_test=false)
double t
Definition: astarsearch.cpp:63
wesnothd_connection & connection
mp_campaign_info(wesnothd_connection &wdc)
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:68
int turns_left
Definition: pathfind.cpp:161
std::shared_ptr< terrain_type_data > ter_data_cache