Skip to content

Commit

Permalink
define display_context interface, implement in game_board
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeck88 committed Jun 10, 2014
1 parent 13fca9a commit d9b3289
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 5 deletions.
40 changes: 40 additions & 0 deletions src/display_context.hpp
@@ -0,0 +1,40 @@
/*
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<vector>

class team;
class gamemap;
class unit_map;

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;

virtual ~display_context() {}
};

#endif
12 changes: 7 additions & 5 deletions src/game_board.hpp
Expand Up @@ -17,6 +17,7 @@

#include "global.hpp"

#include "display_context.hpp"
#include "map.hpp"
#include "team.hpp"
#include "unit_map.hpp"
Expand Down Expand Up @@ -46,7 +47,7 @@ namespace events {
*
**/

class game_board {
class game_board : public display_context {

std::vector<team> teams_;

Expand Down Expand Up @@ -82,13 +83,14 @@ class game_board {

public:

// Constructors and const accessors
// Constructors, trivial dtor, and const accessors

game_board(const config & game_config, const config & level) : teams_(), map_(game_config, level), units_() {}
virtual ~game_board() {}

const std::vector<team> & teams() const { return teams_; }
const gamemap & map() const { return map_; }
const unit_map & units() const { return units_; }
virtual const std::vector<team> & teams() const { return teams_; }
virtual const gamemap & map() const { return map_; }
virtual const unit_map & units() const { return units_; }

// Saving

Expand Down

0 comments on commit d9b3289

Please sign in to comment.