1 /* Copyright 2016-2017 Joaquin M Lopez Munoz.
2 * Distributed under the Boost Software License, Version 1.0.
3 * (See accompanying file LICENSE_1_0.txt or copy at
4 * http://www.boost.org/LICENSE_1_0.txt)
6 * See http://www.boost.org/libs/poly_collection for library home page.
9 #ifndef BOOST_POLY_COLLECTION_EXAMPLE_ROLEGAME_HPP
10 #define BOOST_POLY_COLLECTION_EXAMPLE_ROLEGAME_HPP
16 /* entities of a purported role game used in the examples */
25 sprite(int id):id{id}{}
26 virtual ~sprite()=default;
27 virtual void render(std::ostream& os)const=0;
37 warrior(std::string rank,int id):sprite{id},rank{std::move(rank)}{}
39 void render(std::ostream& os)const override{os<<rank<<" "<<id;}
41 std::string rank="warrior";
44 struct juggernaut:warrior
46 juggernaut(int id):warrior{"juggernaut",id}{}
52 void render(std::ostream& os)const override{os<<"goblin "<<id;}
59 window(std::string caption):caption{std::move(caption)}{}
61 void display(std::ostream& os)const{os<<"["<<caption<<"]";}
71 elf(const elf&)=delete; // not copyable
72 elf(elf&&)=default; // but moveable
73 void render(std::ostream& os)const override{os<<"elf "<<id;}