mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-05-11 21:17:45 +00:00
36 lines
No EOL
906 B
C++
36 lines
No EOL
906 B
C++
#include "ShopMgr.h"
|
|
|
|
#include <Framework.h>
|
|
#include <Exd/ExdDataGenerated.h>
|
|
#include <Actor/Player.h>
|
|
#include <Common.h>
|
|
|
|
extern Sapphire::Framework g_fw;
|
|
using namespace Sapphire;
|
|
|
|
bool Sapphire::World::Manager::ShopMgr::purchaseGilShopItem( Entity::Player& player, uint32_t shopId, uint16_t itemId, uint32_t quantity )
|
|
{
|
|
auto exdData = g_fw.get< Data::ExdDataGenerated >();
|
|
if( !exdData )
|
|
return false;
|
|
|
|
auto gilShopItem = exdData->get< Data::GilShopItem >( shopId, itemId );
|
|
if( !gilShopItem )
|
|
return false;
|
|
|
|
auto item = exdData->get< Data::Item >( gilShopItem->item );
|
|
if( !item )
|
|
return false;
|
|
|
|
auto price = item->priceMid * quantity;
|
|
|
|
if( player.getCurrency( Common::CurrencyType::Gil ) < price )
|
|
return false;
|
|
|
|
if( !player.addItem( gilShopItem->item, quantity ) )
|
|
return false;
|
|
|
|
player.removeCurrency( Common::CurrencyType::Gil, price );
|
|
|
|
return true;
|
|
} |