1 /* 2 * The ManaPlus Client 3 * Copyright (C) 2004-2009 The Mana World Development Team 4 * Copyright (C) 2009-2010 The Mana Developers 5 * Copyright (C) 2011-2019 The ManaPlus Developers 6 * Copyright (C) 2019-2021 Andrei Karas 7 * 8 * This file is part of The ManaPlus Client. 9 * 10 * This program is free software; you can redistribute it and/or modify 11 * it under the terms of the GNU General Public License as published by 12 * the Free Software Foundation; either version 2 of the License, or 13 * any later version. 14 * 15 * This program is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU General Public License for more details. 19 * 20 * You should have received a copy of the GNU General Public License 21 * along with this program. If not, see <http://www.gnu.org/licenses/>. 22 */ 23 24 #ifndef BEING_FLOORITEM_H 25 #define BEING_FLOORITEM_H 26 27 #include "const/resources/item/cards.h" 28 29 #include "enums/resources/cursor.h" 30 31 #include "enums/resources/item/itemtype.h" 32 33 #include "enums/simpletypes/damaged.h" 34 #include "enums/simpletypes/identified.h" 35 #include "enums/simpletypes/itemcolor.h" 36 37 #include "being/actorsprite.h" 38 39 class ItemInfo; 40 41 /** 42 * An item lying on the floor. 43 */ 44 class FloorItem final : public ActorSprite 45 { 46 public: 47 /** 48 * Constructor. 49 * 50 * @param id the unique ID of this item instance 51 * @param itemId the item ID 52 * @param x the x position in tiles 53 * @param y the y position in tiles 54 * @param amount the item amount 55 * @param color the item color 56 */ 57 FloorItem(const BeingId id, 58 const int itemId, 59 const int x, const int y, 60 const ItemTypeT itemType, 61 const int amount, 62 const int refine, 63 const ItemColor color, 64 const Identified identified, 65 const Damaged damaged, 66 const int *const cards); 67 68 A_DELETE_COPY(FloorItem) 69 70 void postInit(Map *const map, int subX, int subY); 71 getType()72 ActorTypeT getType() const noexcept2 override final A_WARN_UNUSED 73 { return ActorType::FloorItem; } 74 75 void draw(Graphics *const graphics, 76 const int offsetX, const int offsetY) 77 const override final A_NONNULL(2); 78 79 /** 80 * Returns the item ID. 81 */ getItemId()82 int getItemId() const noexcept2 A_WARN_UNUSED 83 { return mItemId; } 84 85 /** 86 * Returns the item info for this floor item. Useful for adding an item 87 * link for the floor item to chat. 88 */ 89 const ItemInfo &getInfo() const A_WARN_UNUSED; 90 91 std::string getName() const A_WARN_UNUSED; 92 getTileX()93 int getTileX() const override final A_WARN_UNUSED 94 { return mX; } 95 getTileY()96 int getTileY() const override final A_WARN_UNUSED 97 { return mY; } 98 incrementPickup()99 void incrementPickup() noexcept2 100 { mPickupCount ++; } 101 getPickupCount()102 unsigned getPickupCount() const noexcept2 A_WARN_UNUSED 103 { return mPickupCount; } 104 getColor()105 ItemColor getColor() const noexcept2 A_WARN_UNUSED 106 { return mColor; } 107 getShowMsg()108 bool getShowMsg() const noexcept2 A_WARN_UNUSED 109 { return mShowMsg; } 110 setShowMsg(const bool n)111 void setShowMsg(const bool n) noexcept2 112 { mShowMsg = n; } 113 disableHightlight()114 void disableHightlight() noexcept2 115 { mHighlight = false; } 116 getHoverCursor()117 CursorT getHoverCursor() const noexcept2 A_WARN_UNUSED 118 { return mCursor; } 119 120 void setCards(const int *const cards, int sz); 121 122 int getCard(const int index) const; 123 getRefine()124 int getRefine() const noexcept2 A_WARN_UNUSED 125 { return mRefine; } 126 getItemType()127 ItemTypeT getItemType() const noexcept2 A_WARN_UNUSED 128 { return mItemType; } 129 getIdentified()130 Identified getIdentified() const noexcept2 A_WARN_UNUSED 131 { return mIdentified; } 132 getDamaged()133 Damaged getDamaged() const noexcept2 A_WARN_UNUSED 134 { return mDamaged; } 135 136 private: 137 int mCards[maxCards]; 138 int mItemId; 139 int mX, mY; 140 time_t mDropTime; 141 int mAmount; 142 int mRefine; 143 int mHeightPosDiff; 144 ItemTypeT mItemType; 145 unsigned int mPickupCount; 146 CursorT mCursor; 147 ItemColor mColor; 148 Identified mIdentified; 149 Damaged mDamaged; 150 bool mShowMsg; 151 bool mHighlight; 152 }; 153 154 #endif // BEING_FLOORITEM_H 155