@ -90,6 +90,7 @@ void ItemInfo::InitializeItems(){
auto ReadItems = [ & ] ( datafile & data ) {
for ( auto & [ key , value ] : data . GetKeys ( ) ) {
if ( key = = " " ) ERR ( " Failed to read an item block ,no name specified! " ) ;
std : : string imgPath = " assets/ " + " item_img_directory " _S + key + " .png " ;
Renderable & img = GFX [ " item_img_directory " _S + key + " .png " ] ;
img . Load ( imgPath ) ;
@ -188,7 +189,8 @@ void ItemInfo::InitializeItems(){
Menu : : inventoryListeners . SetInitialized ( ) ;
for ( auto & [ name , info ] : ITEM_DATA ) {
if ( info . description . length ( ) = = 0 ) ERR ( " WARNING! Item " < < info . name < < " does not have a description! " ) ;
Item tempItem { 1 , name } ;
if ( tempItem . Description ( ) . length ( ) = = 0 ) ERR ( " WARNING! Item " < < info . name < < " does not have a description! " ) ;
}
std : : cout < < ITEM_DATA . size ( ) < < " items have been loaded. " < < std : : endl ;
@ -372,12 +374,37 @@ uint32_t Item::Amt(){
return amt ;
} ;
std : : string Item : : Name ( ) {
return it - > Name ( ) ;
std : : string name = it - > Name ( ) ;
if ( IsEquippable ( ) & & EnhancementLevel ( ) > 0 ) {
name + = " [+ " + std : : to_string ( EnhancementLevel ( ) ) + " ] " ;
}
return name ;
} ;
bool Item : : IsEquippable ( ) const {
return Category ( ) = = " Equipment " | | Category ( ) = = " Accessories " ;
}
std : : string Item : : Description ( ) {
return it - > Description ( ) ;
std : : string description = it - > Description ( ) ;
if ( IsEquippable ( ) ) {
description + = ' \n ' ;
description + = GetStats ( ) . GetStatsString ( ) ;
if ( ItemSet ( ) ) {
const : : ItemSet * const set = ItemSet ( ) . value ( ) ;
description + = " \n " + set - > GetSetName ( ) + " Set - " ;
const std : : map < : : ItemSet , int > & itemSetCounts = Inventory : : GetEquippedItemSets ( ) ;
for ( bool first = true ; const auto & [ pieceCount , bonuses ] : set - > GetSetBonusBreakpoints ( ) ) {
if ( itemSetCounts . count ( * set ) & & pieceCount < = itemSetCounts . at ( * set ) ) {
description + = " #56E346 " ;
}
if ( ! first ) description + = " " ;
description + = " ( " + std : : to_string ( pieceCount ) + " ): " + bonuses . GetStatsString ( ) + " #FFFFFF " ;
first = false ;
}
}
}
return description ;
} ;
ITCategory Item : : Category ( ) {
const ITCategory Item : : Category ( ) const {
return it - > Category ( ) ;
} ;
Decal * Item : : Decal ( ) {
@ -496,6 +523,7 @@ void ItemSet::AddSetBonus(std::string setName,int pieceCount,Stats&bonuses){
for ( int i = pieceCount ; i < sets [ setName ] . setBonuses . size ( ) ; i + + ) {
sets [ setName ] . setBonuses [ i ] + = bonuses ;
}
sets [ setName ] . setBonusBreakpoints . push_back ( { pieceCount , bonuses } ) ;
}
void Inventory : : EquipItem ( Item & it , EquipSlot slot ) {
@ -560,7 +588,7 @@ Stats ItemInfo::GetStats(int enhancementLevel){
return enhancement [ enhancementLevel ] ;
}
Stats Item : : GetStats ( ) const {
const Stats Item : : GetStats ( ) const {
if ( it = = nullptr ) return { } ;
return it - > GetStats ( enhancementLevel ) ;
} ;
@ -569,6 +597,43 @@ const size_t EnhancementInfo::size()const{
return enhancementStats . size ( ) ;
} ;
const const const std : : optional < const const const ItemSet const const const * const const const > Item : : ItemSet ( ) const const const { //I was bored, okay?
const const const std : : optional < const const const ItemSet const const const * const const const > & Item : : ItemSet ( ) const const const { //I was bored, okay?
return it - > ItemSet ( ) ;
} ;
uint8_t Item : : EnhancementLevel ( ) const {
return enhancementLevel ;
} ;
void Item : : EnhanceItem ( ) {
if ( enhancementLevel + 1 > " Item.Item Max Enhancement Level " _I ) ERR ( " WARNING! Attempted to enhance " < < Name ( ) < < " beyond the cap of " < < " Item.Item Max Enhancement Level " _I ) ;
enhancementLevel + + ;
} ;
const std : : vector < std : : pair < int , Stats > > & ItemSet : : GetSetBonusBreakpoints ( ) const {
return setBonusBreakpoints ;
} ;
const std : : map < ItemSet , int > Inventory : : GetEquippedItemSets ( ) {
std : : map < ItemSet , int > setCounts ;
for ( int i = int ( EquipSlot : : HELMET ) ; i < = int ( EquipSlot : : RING2 ) ; i < < = 1 ) {
EquipSlot slot = EquipSlot ( i ) ;
Item * equip = Inventory : : GetEquip ( slot ) ;
if ( equip - > IsBlank ( ) ) continue ;
if ( equip - > ItemSet ( ) ) {
setCounts [ * equip - > ItemSet ( ) . value ( ) ] + + ;
}
}
return setCounts ;
}
const std : : string Stats : : GetStatsString ( ) const {
std : : string description = " " ;
for ( bool first = true ; const auto & [ attr , val ] : attributes ) {
if ( ! first ) {
description + = " " ;
}
description + = ItemAttributable : : GetAttributeName ( attr ) + " : " + std : : to_string ( val ) + ( ItemAttributable : : GetDisplayInfo ( attr ) . displayAsPercent ? " % " : " " ) ;
first = false ;
}
return description ;
}