|
|
@ -24,6 +24,7 @@ void ItemInfo::InitializeItems(){ |
|
|
|
|
|
|
|
|
|
|
|
for(auto&key:DATA["ItemCategory"].GetKeys()){ |
|
|
|
for(auto&key:DATA["ItemCategory"].GetKeys()){ |
|
|
|
ITEM_CATEGORIES[key.first]; |
|
|
|
ITEM_CATEGORIES[key.first]; |
|
|
|
|
|
|
|
Inventory::sortedInv[key.first]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for(auto&key:DATA["ItemDatabase"].GetKeys()){ |
|
|
|
for(auto&key:DATA["ItemDatabase"].GetKeys()){ |
|
|
@ -137,6 +138,7 @@ uint32_t Inventory::GetItemCount(IT it){ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Inventory::UseItem(IT it,uint32_t amt){ |
|
|
|
void Inventory::UseItem(IT it,uint32_t amt){ |
|
|
|
|
|
|
|
if(!_inventory.count(it))return; |
|
|
|
//There are two places to manipulate items in (Both the sorted inventory and the actual inventory)
|
|
|
|
//There are two places to manipulate items in (Both the sorted inventory and the actual inventory)
|
|
|
|
for(int i=0;i<amt;i++){ |
|
|
|
for(int i=0;i<amt;i++){ |
|
|
|
if(ExecuteAction(it)){ |
|
|
|
if(ExecuteAction(it)){ |
|
|
@ -185,6 +187,11 @@ bool Inventory::SwapItems(IT it,IT it2){ |
|
|
|
std::vector<IT>inv=sortedInv.at(category); |
|
|
|
std::vector<IT>inv=sortedInv.at(category); |
|
|
|
auto index1=std::find(inv.begin(),inv.end(),it); |
|
|
|
auto index1=std::find(inv.begin(),inv.end(),it); |
|
|
|
auto index2=std::find(inv.begin(),inv.end(),it2); |
|
|
|
auto index2=std::find(inv.begin(),inv.end(),it2); |
|
|
|
|
|
|
|
int largestSlot=std::max(index1-inv.begin(),index2-inv.begin()); |
|
|
|
|
|
|
|
if(inv.size()<largestSlot){ |
|
|
|
|
|
|
|
//The inventory is too small, so expand out blank slots to accomodate.
|
|
|
|
|
|
|
|
inv.resize(largestSlot+size_t(1)); |
|
|
|
|
|
|
|
} |
|
|
|
std::swap(*index1,*index2); |
|
|
|
std::swap(*index1,*index2); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|