Exemplo n.º 1
0
void UpdateGuildsStock()
{
    for (std::vector<CItemContainer*>::iterator iter = g_PGuildList.begin(); iter != g_PGuildList.end(); iter++)
	{
		CItemContainer* PGuild = *iter;
        for(uint8 slotid = 1; slotid <= PGuild->GetSize(); ++slotid)
        {
            CItemShop* PItem = (CItemShop*)PGuild->GetItem(slotid);

			PItem->setBasePrice(PItem->getMinPrice() + ((float)(PItem->getStackSize() - PItem->getQuantity()) / PItem->getStackSize()) * (PItem->getMaxPrice() - PItem->getMinPrice()));

            if (PItem->IsDailyIncrease())
            {
                PItem->setQuantity(PItem->getQuantity() + PItem->getDailyIncrease());
            }
        }
	}
    ShowDebug(CL_CYAN"UpdateGuildsStock is finished\n" CL_RESET);
}
Exemplo n.º 2
0
CGuildMenuSellPacket::CGuildMenuSellPacket(CCharEntity* PChar, CItemContainer* PGuild)
{
    this->type = 0x85;
    this->size = 0x7C;

    DSP_DEBUG_BREAK_IF(PChar == nullptr);
    DSP_DEBUG_BREAK_IF(PGuild == nullptr);

    uint8 ItemCount = 0;
    uint8 PacketCount = 0;

    for (uint8 SlotID = 1; SlotID <= PGuild->GetSize(); ++SlotID) 
    {
        CItemShop* PItem = (CItemShop*)PGuild->GetItem(SlotID);

        if (ItemCount == 30)
        {
            ref<uint8>(0xF4) = ItemCount;
            ref<uint8>(0xF5) = (PacketCount == 0 ? 0x40 : PacketCount);

            PChar->pushPacket(new CBasicPacket(*this));

            ItemCount = 0;
            PacketCount++;
						
            memset(data + 4, 0, PACKET_SIZE - 8);
        }
        ref<uint16>(0x08 * ItemCount + 0x04) = PItem->getID();
        ref<uint8>(0x08 * ItemCount + 0x06) = PItem->getQuantity();
        ref<uint8>(0x08 * ItemCount + 0x07) = PItem->getStackSize();
        ref<uint32>(0x08 * ItemCount + 0x08) = PItem->getSellPrice();

        ItemCount++;
    }
    ref<uint8>(0xF4) = ItemCount;
    ref<uint8>(0xF5) = PacketCount + 0x80;
}
Exemplo n.º 3
0
CGuildMenuSellPacket::CGuildMenuSellPacket(CCharEntity* PChar, CItemContainer* PGuild)
{
    this->type = 0x85;
    this->size = 0x7C;

    DSP_DEBUG_BREAK_IF(PChar == NULL);
    DSP_DEBUG_BREAK_IF(PGuild == NULL);

    uint8 ItemCount = 0;
    uint8 PacketCount = 0;

    for (uint8 SlotID = 1; SlotID <= PGuild->GetSize(); ++SlotID) 
    {
        CItemShop* PItem = (CItemShop*)PGuild->GetItem(SlotID);

        if (ItemCount == 30)
        {
            WBUFB(data,(0xF4)-4) = ItemCount;
            WBUFB(data,(0xF5)-4) = (PacketCount == 0 ? 0x40 : PacketCount);

            PChar->pushPacket(new CBasicPacket(*this));

            ItemCount = 0;
            PacketCount++;
						
            memset(data, 0, sizeof(data));
        }
        WBUFW(data,(0x08*ItemCount+0x04)-4) = PItem->getID();
        WBUFB(data,(0x08*ItemCount+0x06)-4) = PItem->getQuantity();
        WBUFB(data,(0x08*ItemCount+0x07)-4) = PItem->getStackSize();
        WBUFL(data,(0x08*ItemCount+0x08)-4) = PItem->getBasePrice();

        ItemCount++;
    }
    WBUFB(data,(0xF4)-4) = ItemCount;
    WBUFB(data,(0xF5)-4) = PacketCount + 0x80;
}
Exemplo n.º 4
0
void UpdateGuildsStock()
{
    for (std::vector<CItemContainer*>::iterator iter = g_PGuildList.begin(); iter != g_PGuildList.end(); iter++)
	{
		CItemContainer* PGuild = *iter;
        for(uint8 slotid = 1; slotid <= PGuild->GetSize(); ++slotid)
        {
            CItemShop* PItem = (CItemShop*)PGuild->GetItem(slotid);

            // TODO: сначала, анализируя текущее количество предметов, обновляем их стоимость

            if (PItem->IsDailyIncrease())
            {
                PItem->setQuantity(PItem->getQuantity() + PItem->getDailyIncrease());
            }

            //TODO: set price based on previous day stock
            PItem->setBasePrice(PItem->getMinPrice());
        }
	}
    ShowDebug(CL_CYAN"UpdateGuildsStock is finished\n" CL_RESET);
}