123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- #include "BasicTool.h"
- BasicToolItem::BasicToolItem(int itemTypeId, const char *name)
- : Item(itemTypeId, name)
- {
- hp = 10.f;
- maxHp = 10.f;
- durability = 10.f;
- maxDurability = 10.f;
- usable = 1;
- }
- void BasicToolItem::updateBasedOnUsedMaterial() {
- float basicDurability = 10.f;
- float headDurabilityModifier = 1.f;
- float rodDurabilityModifier = 1.f;
- // TODO: adjust durability modifier based on material
- float currentDurability = durability / maxDurability;
- maxDurability
- = basicDurability * headDurabilityModifier * rodDurabilityModifier;
- durability = currentDurability * maxDurability;
- }
- void BasicToolItem::setHeadMaterial(int headMaterial)
- {
- this->headMaterial = headMaterial;
- }
- void BasicToolItem::setRodMaterial(int rodMaterial)
- {
- this->rodMaterial = rodMaterial;
- }
- BasicToolItemType::BasicToolItemType(int id,
- const char* name,
- ItemSkillLevelUpRule* levelUpRule,
- int brokenTypeId,
- ModelInfo model)
- : ItemType(id, name, levelUpRule, brokenTypeId, model)
- {}
- void BasicToolItemType::loadSuperItem(
- Item* zItem, Framework::StreamReader* zReader) const
- {
- ItemType::loadSuperItem(zItem, zReader);
- BasicToolItem* item = dynamic_cast<BasicToolItem*>(zItem);
- zReader->lese((char*)&item->headMaterial, 4);
- zReader->lese((char*)&item->rodMaterial, 4);
- }
- void BasicToolItemType::saveSuperItem(
- const Item* zItem, Framework::StreamWriter* zWriter) const
- {
- ItemType::saveSuperItem(zItem, zWriter);
- const BasicToolItem* item = dynamic_cast<const BasicToolItem*>(zItem);
- zWriter->schreibe((char*)&item->headMaterial, 4);
- zWriter->schreibe((char*)&item->rodMaterial, 4);
- }
|