The Battle for Wesnoth  1.13.10+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 - 2017 by Philippe Plantier <ayin@anathas.org>
4  Part of the Battle for Wesnoth Project http://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 {
62  const bool is_unit_test_;
63  bool is_replay_;
65 public:
66  campaign_controller(saved_game& state, const config& game_config, const ter_data_cache & tdata, bool is_unit_test = false)
67  : state_(state)
68  , game_config_(game_config)
69  , tdata_(tdata)
70  , is_unit_test_(is_unit_test)
71  , is_replay_(false)
72  , mp_info_(nullptr)
73  {
74  }
75  LEVEL_RESULT play_game();
76  LEVEL_RESULT play_replay()
77  {
78  is_replay_ = true;
79  return play_game();
80  }
81  void set_mp_info(mp_campaign_info* mp_info) { mp_info_ = mp_info; }
82 private:
83  LEVEL_RESULT playsingle_scenario(end_level_data &end_level);
84  LEVEL_RESULT playmp_scenario(end_level_data &end_level);
85  void show_carryover_message(playsingle_controller& playcontroller, const end_level_data& end_level, LEVEL_RESULT res);
86  static void report_victory(std::ostringstream &report, team& t, int finishing_bonus_per_turn, int turns_left, int finishing_bonus);
87 };
LEVEL_RESULT play_replay()
LEVEL_RESULT play_game()
bool skip_replay_blindfolded
mp_campaign_info * mp_info_
void set_mp_info(mp_campaign_info *mp_info)
const config & game_config_
static void report_victory(std::ostringstream &report, team &t, int finishing_bonus_per_turn, int turns_left, int finishing_bonus)
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...
LEVEL_RESULT playmp_scenario(end_level_data &end_level)
This class stores all the data for a single 'side' (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
LEVEL_RESULT playsingle_scenario(end_level_data &end_level)
campaign_controller(saved_game &state, const config &game_config, const ter_data_cache &tdata, bool is_unit_test=false)
void show_carryover_message(playsingle_controller &playcontroller, const end_level_data &end_level, LEVEL_RESULT res)
const bool is_unit_test_
Game configuration data as global variables.
Definition: build_info.cpp:53
Additional information on the game outcome which can be provided by WML.
double t
Definition: astarsearch.cpp:64
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:93
int turns_left
Definition: pathfind.cpp:161
std::shared_ptr< terrain_type_data > ter_data_cache