Mana
Loading...
Searching...
No Matches
shopitem.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 "item.h"
25
26#include <stack>
27
32class ShopItem : public Item
33{
34 public:
43 ShopItem(int inventoryIndex, int id, int quantity, int price);
44
45 ~ShopItem() override;
46
53 void addDuplicate(int inventoryIndex, int quantity);
54
61 {
62 return mDuplicates.empty() ? 0 : mDuplicates.top().quantity;
63 }
64
71 {
72 return mDuplicates.empty() ? mInvIndex :
73 mDuplicates.top().inventoryIndex;
74 }
75
87 int sellCurrentDuplicate(int quantity);
88
94 int getPrice() const
95 { return mPrice; }
96
102 const std::string &getDisplayName() const
103 { return mDisplayName; }
104
105 protected:
107 std::string mDisplayName;
108
113 {
116 };
117 std::stack<DuplicateItem> mDuplicates;
118};
Represents one or more instances of a certain item type.
Definition item.h:35
int mInvIndex
Inventory index.
Definition item.h:110
Represents an item in a shop inventory.
Definition shopitem.h:33
int getCurrentQuantity() const
Gets the quantity of the currently topmost duplicate.
Definition shopitem.h:60
~ShopItem() override
int getCurrentInvIndex() const
Gets the inventory index of the currently topmost duplicate.
Definition shopitem.h:70
void addDuplicate(int inventoryIndex, int quantity)
Add a duplicate.
Definition shopitem.cpp:41
std::string mDisplayName
Definition shopitem.h:107
int sellCurrentDuplicate(int quantity)
Reduces the quantity of the topmost duplicate by the specified amount.
Definition shopitem.cpp:49
int mPrice
Definition shopitem.h:106
const std::string & getDisplayName() const
Gets the display name for the item in the shop list.
Definition shopitem.h:102
std::stack< DuplicateItem > mDuplicates
Definition shopitem.h:117
int getPrice() const
Gets the price of the item.
Definition shopitem.h:94
Struct to keep track of duplicates.
Definition shopitem.h:113