Exemple #1
0
KAWARD_ITEM*  KAwardMgr::AwardRandomOne(KPlayer* pPlayer, DWORD dwAwardTableID)
{
    BOOL            bRetCode        = false;
    IItem*          pItem           = NULL;
    KAwardTable*    pAwardTable     = NULL;
    KAWARD_ITEM*    pAwardItem      = NULL;
    int             nValuePoint = 0;

    assert(pPlayer);

    bRetCode = HasEnoughBagToAwardRandomOne(pPlayer, dwAwardTableID);
    KGLOG_PROCESS_ERROR(bRetCode);

    pAwardTable = GetAwardTable(dwAwardTableID);
    KGLOG_PROCESS_ERROR(pAwardTable);

    pAwardItem = pAwardTable->GetRandomAward();
    if (pAwardItem)
    {
        if (pAwardItem->dwTabType == ittOther || pAwardItem->dwTabType == ittEquip)
        {
            bRetCode = GetAwardItemValuePoint(pAwardItem, nValuePoint);
            KGLOG_PROCESS_ERROR(bRetCode);

            pItem = pPlayer->AddItem(pAwardItem->dwTabType, pAwardItem->dwIndex, pAwardItem->nStackNum, nValuePoint);
            if (pItem)
            {
                PLAYER_LOG(
                    pPlayer, "item,additem,%u-%u,%d,%d,%d,%s,%d",
                    pAwardItem->dwTabType, pAwardItem->dwIndex, pAwardItem->nStackNum, nValuePoint, pItem->GetQuality(),
                    "useitem", pPlayer->m_dwMapID
                );
            }
        }
        else if (pAwardItem->dwTabType == ittFashion)
        {
            bRetCode = pPlayer->m_Wardrobe.AddFashion(pAwardItem->dwIndex);
            KGLOG_CHECK_ERROR(bRetCode);
        }
        else if (pAwardItem->dwTabType == ittCheerleading)
        {
            KGCheerleadingInfo* pCheerleadingInfo = g_pSO3World->m_ItemHouse.GetCheerleadingInfo(pAwardItem->dwIndex);
            KGLOG_PROCESS_ERROR(pCheerleadingInfo);

            bRetCode = pPlayer->m_CheerleadingMgr.AddCheerleading(pCheerleadingInfo->dwID);
            KGLOG_PROCESS_ERROR(bRetCode);
        }
        else if (pAwardItem->dwTabType == ittTeamLogo)
        {
            KTEAM_LOGO_INFO*    pTeamLogoInfo = NULL;

            pTeamLogoInfo = g_pSO3World->m_ItemHouse.GetTeamLogoInfo(pAwardItem->dwIndex);
            KGLOG_PROCESS_ERROR(pTeamLogoInfo);

            bRetCode = pPlayer->AddTeamLogo((WORD)pTeamLogoInfo->nID);
            KGLOG_PROCESS_ERROR(bRetCode);
        }
        else if (pAwardItem->nMoney > 0)
        {
            bRetCode = pPlayer->m_MoneyMgr.AddMoney(pAwardItem->eMoneyType, pAwardItem->nMoney);
            KGLOG_PROCESS_ERROR(bRetCode);
            PLAYER_LOG(pPlayer, "money,addmoney,%d,%s,%d-%d,%d,%d", pAwardItem->eMoneyType, "useitem", 0, 0, 0, pAwardItem->nMoney);
        }
    }

Exit0:
    return pAwardItem;
}
Exemple #2
0
BOOL KAwardMgr::AwardAll(KPlayer* pPlayer, DWORD dwAwardTableID, const char szWayID[])
{
    BOOL bResult = false;
    BOOL bRetCode = false;
    KAwardTable* pAwardTable = NULL;
    int nValuePoint = 0;

    assert(szWayID);

    KGLOG_PROCESS_ERROR(pPlayer);
    KGLOG_PROCESS_ERROR(dwAwardTableID);

    pAwardTable = GetAwardTable(dwAwardTableID);
    KGLOG_PROCESS_ERROR(pAwardTable);

    bRetCode = HasEnoughBagToAwardAll(pPlayer, dwAwardTableID);
    KGLOG_PROCESS_ERROR(bRetCode);

    for (KAWARD_ITEM_MAP::iterator it = pAwardTable->m_mapAwardItem.begin(); it != pAwardTable->m_mapAwardItem.end(); ++it)
    {
        KAWARD_ITEM* pAwardItem = &it->second;
        if (pAwardItem->dwTabType == ittOther || pAwardItem->dwTabType == ittEquip)
        {
			IItem* pItem = NULL;

            bRetCode = GetAwardItemValuePoint(pAwardItem, nValuePoint);
            KGLOG_PROCESS_ERROR(bRetCode);

            pItem = pPlayer->AddItem(pAwardItem->dwTabType, pAwardItem->dwIndex, pAwardItem->nStackNum, nValuePoint);
            if (pItem)
            {
                PLAYER_LOG(
                    pPlayer, "item,additem,%u-%u,%d,%d,%d,%s,%d",
                    pAwardItem->dwTabType, pAwardItem->dwIndex, pAwardItem->nStackNum, nValuePoint, pItem->GetQuality(),
                    szWayID, pPlayer->m_dwMapID
                );
            }
        }
        else if (pAwardItem->dwTabType == ittFashion)
        {
            bRetCode = pPlayer->m_Wardrobe.AddFashion(pAwardItem->dwIndex);
            KGLOG_CHECK_ERROR(bRetCode);
        }
        else if (pAwardItem->dwTabType == ittCheerleading)
        {
            KGCheerleadingInfo* pCheerleadingInfo = g_pSO3World->m_ItemHouse.GetCheerleadingInfo(pAwardItem->dwIndex);
            KGLOG_PROCESS_ERROR(pCheerleadingInfo);

            bRetCode = pPlayer->m_CheerleadingMgr.AddCheerleading(pCheerleadingInfo->dwID);
            KGLOG_PROCESS_ERROR(bRetCode);
        }
        else if (pAwardItem->dwTabType == ittTeamLogo)
        {
            KTEAM_LOGO_INFO*    pTeamLogoInfo = NULL;

            pTeamLogoInfo = g_pSO3World->m_ItemHouse.GetTeamLogoInfo(pAwardItem->dwIndex);
            KGLOG_PROCESS_ERROR(pTeamLogoInfo);

            bRetCode = pPlayer->AddTeamLogo((WORD)pTeamLogoInfo->nID);
            KGLOG_PROCESS_ERROR(bRetCode);
        }
        else if (pAwardItem->nMoney > 0)
        {
            bRetCode = pPlayer->m_MoneyMgr.AddMoney(pAwardItem->eMoneyType, pAwardItem->nMoney);
            KGLOG_PROCESS_ERROR(bRetCode);

            PLAYER_LOG(pPlayer, "money,addmoney,%d,%s,%d-%d,%d,%d", pAwardItem->eMoneyType, szWayID, 0, 0, 0, pAwardItem->nMoney);
        }
    }

    bResult = true;
Exit0:
    return bResult;
}