Mana
Loading...
Searching...
No Matches
equipment.h
Go to the documentation of this file.
1/*
2 * The Mana Client
3 * Copyright (C) 2004-2009 The Mana World Development Team
4 * Copyright (C) 2009-2012 The Mana Developers
5 *
6 * This file is part of The Mana Client.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#pragma once
23
24#include <string>
25
26class Item;
27
29{
30 public:
31 class Backend {
32 public:
33 virtual Item *getEquipment(int slotIndex) const = 0;
34 virtual std::string getSlotName(int slotIndex) const
35 { return std::string(); }
36
37 virtual void clear() = 0;
38 virtual ~Backend() { }
39 virtual int getSlotNumber() const = 0;
40 virtual void triggerUnequip(int slotIndex) const = 0;
41 private:
42 virtual void readEquipFile()
43 {}
44 };
45
47 : mBackend(backend)
48 {}
49
53 Item *getEquipment(int slotIndex) const
54 { return mBackend ? mBackend->getEquipment(slotIndex) : nullptr; }
55
56 std::string getSlotName(int slotIndex) const
57 { return mBackend ? mBackend->getSlotName(slotIndex) : std::string(); }
58
59 int getSlotNumber() const
60 { return mBackend ? mBackend->getSlotNumber() : 0; }
61
62 void triggerUnequip(int slotIndex) const
63 { if (mBackend) mBackend->triggerUnequip(slotIndex); }
64
68 void clear()
69 { if (mBackend) mBackend->clear(); }
70
71 private:
73};
virtual Item * getEquipment(int slotIndex) const =0
virtual void clear()=0
virtual std::string getSlotName(int slotIndex) const
Definition equipment.h:34
virtual int getSlotNumber() const =0
virtual ~Backend()
Definition equipment.h:38
virtual void readEquipFile()
Definition equipment.h:42
virtual void triggerUnequip(int slotIndex) const =0
void triggerUnequip(int slotIndex) const
Definition equipment.h:62
Equipment(Backend *backend)
Definition equipment.h:46
void clear()
Clears equipment.
Definition equipment.h:68
Item * getEquipment(int slotIndex) const
Get equipment at the given slot.
Definition equipment.h:53
int getSlotNumber() const
Definition equipment.h:59
Backend * mBackend
Definition equipment.h:72
std::string getSlotName(int slotIndex) const
Definition equipment.h:56
Represents one or more instances of a certain item type.
Definition item.h:35