1 // Copyright (C) 2008, 2009, 2014 Ben Asselstine 2 // 3 // This program is free software; you can redistribute it and/or modify 4 // it under the terms of the GNU General Public License as published by 5 // the Free Software Foundation; either version 3 of the License, or 6 // (at your option) any later version. 7 // 8 // This program is distributed in the hope that it will be useful, 9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 // GNU Library General Public License for more details. 12 // 13 // You should have received a copy of the GNU General Public License 14 // along with this program; if not, write to the Free Software 15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 16 // 02110-1301, USA. 17 18 #pragma once 19 #ifndef OWNABLE_H 20 #define OWNABLE_H 21 22 23 class Player; 24 class XML_Helper; 25 26 //! A game object that has an owner. 27 /** 28 * An Ownable is a map object that can be owned by a Player. 29 */ 30 31 class Ownable 32 { 33 public: 34 35 //! Default constructor. 36 Ownable(Player *owner); 37 38 //! Copy constructor. 39 Ownable(const Ownable&); 40 41 //! Loading constructor. 42 Ownable(XML_Helper* helper); 43 44 //! Destructor. ~Ownable()45 virtual ~Ownable() {}; 46 47 // Get Methods 48 49 //! Return a pointer to the Player who owns an object. getOwner()50 Player *getOwner() const {return d_owner;} 51 52 //! Return true if the player parameter matches the owner. 53 bool isFriend (Player *player) const; 54 55 // Set Methods 56 57 //! Set the Player who owns an object. setOwner(Player * player)58 void setOwner(Player *player){d_owner = player;} 59 60 // Statics 61 62 //! Callback for loading an Ownable object from an opened saved-game file. 63 static Ownable load(XML_Helper *helper); 64 65 protected: 66 67 // A pointer to the player owning this object. 68 Player *d_owner; 69 }; 70 71 #endif 72