From: Daniel Karbach Date: Thu, 9 Aug 2012 13:56:04 +0000 (+0200) Subject: added Item data structure X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=2d08482879cca41a03c5812dde9690ff3e07b474;p=l2e.git added Item data structure --- diff --git a/Debug/makefile b/Debug/makefile index 2000ebc..571f839 100644 --- a/Debug/makefile +++ b/Debug/makefile @@ -10,6 +10,7 @@ RM := rm -rf -include sources.mk -include src/sdl/subdir.mk -include src/graphics/subdir.mk +-include src/common/subdir.mk -include src/battle/states/subdir.mk -include src/battle/subdir.mk -include src/app/subdir.mk diff --git a/Debug/sources.mk b/Debug/sources.mk index cd96090..a9593d6 100644 --- a/Debug/sources.mk +++ b/Debug/sources.mk @@ -26,6 +26,7 @@ SUBDIRS := \ src/sdl \ src \ src/graphics \ +src/common \ src/battle/states \ src/battle \ src/app \ diff --git a/Debug/src/common/subdir.mk b/Debug/src/common/subdir.mk new file mode 100644 index 0000000..44a8678 --- /dev/null +++ b/Debug/src/common/subdir.mk @@ -0,0 +1,24 @@ +################################################################################ +# Automatically-generated file. Do not edit! +################################################################################ + +# Add inputs and outputs from these tool invocations to the build variables +CPP_SRCS += \ +../src/common/Item.cpp + +OBJS += \ +./src/common/Item.o + +CPP_DEPS += \ +./src/common/Item.d + + +# Each subdirectory must supply rules for building sources it contributes +src/common/%.o: ../src/common/%.cpp + @echo 'Building file: $<' + @echo 'Invoking: GCC C++ Compiler' + g++ -I/usr/include/SDL -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<" + @echo 'Finished building: $<' + @echo ' ' + + diff --git a/Release/makefile b/Release/makefile index 2000ebc..571f839 100644 --- a/Release/makefile +++ b/Release/makefile @@ -10,6 +10,7 @@ RM := rm -rf -include sources.mk -include src/sdl/subdir.mk -include src/graphics/subdir.mk +-include src/common/subdir.mk -include src/battle/states/subdir.mk -include src/battle/subdir.mk -include src/app/subdir.mk diff --git a/Release/sources.mk b/Release/sources.mk index cd96090..a9593d6 100644 --- a/Release/sources.mk +++ b/Release/sources.mk @@ -26,6 +26,7 @@ SUBDIRS := \ src/sdl \ src \ src/graphics \ +src/common \ src/battle/states \ src/battle \ src/app \ diff --git a/Release/src/common/subdir.mk b/Release/src/common/subdir.mk new file mode 100644 index 0000000..f4da71e --- /dev/null +++ b/Release/src/common/subdir.mk @@ -0,0 +1,24 @@ +################################################################################ +# Automatically-generated file. Do not edit! +################################################################################ + +# Add inputs and outputs from these tool invocations to the build variables +CPP_SRCS += \ +../src/common/Item.cpp + +OBJS += \ +./src/common/Item.o + +CPP_DEPS += \ +./src/common/Item.d + + +# Each subdirectory must supply rules for building sources it contributes +src/common/%.o: ../src/common/%.cpp + @echo 'Building file: $<' + @echo 'Invoking: GCC C++ Compiler' + g++ -I/usr/include/SDL -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<" + @echo 'Finished building: $<' + @echo ' ' + + diff --git a/src/common/Item.cpp b/src/common/Item.cpp new file mode 100644 index 0000000..65df4c8 --- /dev/null +++ b/src/common/Item.cpp @@ -0,0 +1,26 @@ +/* + * Item.cpp + * + * Created on: Aug 9, 2012 + * Author: holy + */ + +#include "Item.h" + +namespace common { + +Item::Item() +: menuIcon(0) +, chestIcon(0) + +, value(0) +, properties(0) + +, usability(0) +, targettingMode(0) +, equipable(0) +, equipableBy(0) { + +} + +} diff --git a/src/common/Item.h b/src/common/Item.h new file mode 100644 index 0000000..cdb106d --- /dev/null +++ b/src/common/Item.h @@ -0,0 +1,149 @@ +/* + * Item.h + * + * Created on: Aug 9, 2012 + * Author: holy + */ + +#ifndef COMMON_ITEM_H_ +#define COMMON_ITEM_H_ + +#include + +namespace graphics { class Sprite; } + +namespace common { + +class Item { + +public: + Item(); + +public: + bool IsMostUseful() const { return usability & USABILITY_MOST_USEFUL; } + bool IsEquipable() const { return usability & USABILITY_EQUIPABLE; } + bool IsCursed() const { return usability & USABILITY_CURSED; } + bool IsFruit() const { return usability & USABILITY_FRUIT; } + bool IsScenario() const { return usability & USABILITY_SCENARIO; } + bool CanSell() const { return !IsScenario(); } + bool CanDrop() const { return !IsScenario(); } + bool CanUseOnStatusScreen() const { return usability & USABILITY_STATUS; } + bool CanUseInBattle() const { return usability & USABILITY_BATTLE; } + + bool TargetEnemy() const { return targettingMode & TARGETTING_MODE_ENEMY; } + bool TargetAlly() const { return !TargetEnemy(); } + bool TargetAll() const { return (targettingMode & TARGETTING_MODE_COUNT_MASK) == TARGETTING_MODE_ALL; } + bool TargetMultiple() const { return (targettingMode & TARGETTING_MODE_COUNT_MASK) == TARGETTING_MODE_MULTIPLE; } + bool TargetOne() const { return (targettingMode & TARGETTING_MODE_COUNT_MASK) == TARGETTING_MODE_ONE; } + + bool HasMenuIcon() const { return menuIcon; } + const graphics::Sprite *MenuIcon() const { return menuIcon; } + bool HasChestIcon() const { return chestIcon; } + const graphics::Sprite *ChestIcon() const { return chestIcon; } + + Uint16 Value() const { return value; } + + bool CanEquipWeapon() const { return equipable & EQUIPPABLE_WEAPON; } + bool CanEquipArmor() const { return equipable & EQUIPPABLE_ARMOR; } + bool CanEquipShield() const { return equipable & EQUIPPABLE_SHIELD; } + bool CanEquipHelmet() const { return equipable & EQUIPPABLE_HELMET; } + bool CanEquipRing() const { return equipable & EQUIPPABLE_RING; } + bool CanEquipJewel() const { return equipable & EQUIPPABLE_JEWEL; } + + bool EquipableByMaxim() const { return equipableBy & EQUIPABLE_BY_MAXIM; } + bool EquipableBySelan() const { return equipableBy & EQUIPABLE_BY_SELAN; } + bool EquipableByGuy() const { return equipableBy & EQUIPABLE_BY_GUY; } + bool EquipableByArtea() const { return equipableBy & EQUIPABLE_BY_ARTEA; } + bool EquipableByTia() const { return equipableBy & EQUIPABLE_BY_TIA; } + bool EquipableByDekar() const { return equipableBy & EQUIPABLE_BY_DEKAR; } + bool EquipableByLexis() const { return equipableBy & EQUIPABLE_BY_LEXIS; } + + bool HasItemEffectOnStatusScreen() const { return properties & PROPERTY_HAS_ITEM_EFFECT_STATUS; } + bool HasItemEffectInBattle() const { return properties & PROPERTY_HAS_ITEM_EFFECT_BATTLE; } + bool HasWeaponEffect() const { return properties & PROPERTY_HAS_WEAPON_EFFECT; } + bool HasArmorEffect() const { return properties & PROPERTY_HAS_ARMOR_EFFECT; } + bool IncreasesATP() const { return properties & PROPERTY_INCREASE_ATP; } + bool IncreasesDFP() const { return properties & PROPERTY_INCREASE_DFP; } + bool IncreasesSTR() const { return properties & PROPERTY_INCREASE_STR; } + bool IncreasesAGL() const { return properties & PROPERTY_INCREASE_AGL; } + bool IncreasesINT() const { return properties & PROPERTY_INCREASE_INT; } + bool IncreasesGUT() const { return properties & PROPERTY_INCREASE_GUT; } + bool IncreasesMGR() const { return properties & PROPERTY_INCREASE_MGR; } + bool HasBattleAnimation() const { return properties & PROPERTY_HAS_BATTLE_ANIMATION; } + bool HasIkariEffect() const { return properties & PROPERTY_HAS_IKARI_EFFECT; } + +private: + enum Usability { + USABILITY_MOST_USEFUL = 1, + USABILITY_EQUIPABLE = 2, + // USABILITY_UNUSED = 4, + USABILITY_CURSED = 8, + USABILITY_FRUIT = 16, + USABILITY_SCENARIO = 32, + USABILITY_STATUS = 64, + USABILITY_BATTLE = 128, + }; + enum TargettingMode { + TARGETTING_MODE_ALL = 0, + TARGETTING_MODE_ALLY = 0, + TARGETTING_MODE_MULTIPLE = 1, + TARGETTING_MODE_ONE = 2, + TARGETTING_MODE_COUNT_MASK = 127, + TARGETTING_MODE_ENEMY = 128, + TARGETTING_MODE_FACTION_MASK = 128, + }; + enum Equipable { + EQUIPPABLE_NONE = 0, + EQUIPPABLE_WEAPON = 1, + EQUIPPABLE_ARMOR = 2, + EQUIPPABLE_SHIELD = 4, + EQUIPPABLE_HELMET = 8, + EQUIPPABLE_RING = 16, + EQUIPPABLE_JEWEL = 32, + }; + enum EquipableBy { + EQUIPABLE_BY_NOBODY = 0, + EQUIPABLE_BY_MAXIM = 1, + EQUIPABLE_BY_SELAN = 2, + EQUIPABLE_BY_GUY = 4, + EQUIPABLE_BY_ARTEA = 8, + EQUIPABLE_BY_TIA = 16, + EQUIPABLE_BY_DEKAR = 32, + EQUIPABLE_BY_LEXIS = 64, + }; + enum Property { + PROPERTY_HAS_ITEM_EFFECT_STATUS = 1, + PROPERTY_HAS_ITEM_EFFECT_BATTLE = 2, + PROPERTY_HAS_WEAPON_EFFECT = 4, + PROPERTY_HAS_ARMOR_EFFECT = 8, + PROPERTY_INCREASE_ATP = 16, + PROPERTY_INCREASE_DFP = 32, + PROPERTY_INCREASE_STR = 64, + PROPERTY_INCREASE_AGL = 128, + PROPERTY_INCREASE_INT = 256, + PROPERTY_INCREASE_GUT = 512, + PROPERTY_INCREASE_MGR = 1024, + // PROPERTY_UNUSED = 2048, + // PROPERTY_UNUSED = 4096, + PROPERTY_HAS_BATTLE_ANIMATION = 8192, + // PROPERTY_UNKNOWN = 16384, + PROPERTY_HAS_IKARI_EFFECT = 32768, + }; + +private: + graphics::Sprite *menuIcon; + graphics::Sprite *chestIcon; + + Uint16 value; + Uint16 properties; + + Uint8 usability; + Uint8 targettingMode; + Uint8 equipable; + Uint8 equipableBy; + +}; + +} + +#endif /* COMMON_ITEM_H_ */