#include "inc_itemprop002"

void main()
{
    object oPC = GetLastUsedBy();
    int iPCLevel = GetHitDice(oPC);
    int i;
    int iLevelExceeded = 0;
    int iItemLevel;
    object oItem = GetFirstItemInInventory(oPC);
    int iNetWealth = GetGold(oPC);
    int iGold;

    //visual effects
    //location lLoc = GetLocation(OBJECT_SELF);
    //effect eEffect = EffectVisualEffect(VFX_COM_SPARKS_PARRY);
    //ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, eEffect, lLoc, 1.0);

    effect eEffect = EffectVisualEffect(VFX_IMP_CHARM);
    ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect, OBJECT_SELF, 1.0);


    SendMessageToPC(oPC, "========================================");
    SendMessageToPC(oPC, "Wealth evalution for " + GetName(oPC));

    // Inventory items
    while ( GetIsObjectValid(oItem) )
        {
        //SendMessageToPC(oPC, "Net Worth "+IntToString(iNetWealth)+" + "+GetName(oItem)+" Cost "+IntToString(GetGoldPieceValue(oItem)));
        iNetWealth += GetGoldPieceValue(oItem);
        iItemLevel = GetItemLevel(oItem);
        if (iItemLevel > iPCLevel)
            {
            SendMessageToPC(oPC, GetName(oItem) + " exceeds your level. (Item Level = " + IntToString(iItemLevel) + ")");
            iLevelExceeded = 1;
            }
        oItem = GetNextItemInInventory(oPC);
        }


    // Equipped items
    for ( i = 0; i < NUM_INVENTORY_SLOTS; i++ )
        {
        oItem = GetItemInSlot(i, oPC);
        //SendMessageToPC(oPC, "Net Worth "+IntToString(iNetWealth)+" + "+GetName(oItem)+" Cost "+IntToString(GetGoldPieceValue(oItem)));
        iNetWealth += GetGoldPieceValue(oItem);
        iItemLevel = GetItemLevel(oItem);
        if (iItemLevel > iPCLevel)
            {
            SendMessageToPC(oPC, GetName(oItem) + " exceeds your level. (Item Level = " + IntToString(iItemLevel) + ")");
            iLevelExceeded = 1;
            }
        }

    if (iLevelExceeded == 0) SendMessageToPC(oPC, "You have no items that exceed your level.");

    switch(iPCLevel)
        {
        case 1: iGold = 300; break;
        case 2: iGold = 900; break;
        case 3: iGold = 2700; break;
        case 4: iGold = 5400; break;
        case 5: iGold = 9000; break;
        case 6: iGold = 13000; break;
        case 7: iGold = 19000; break;
        case 8: iGold = 27000; break;
        case 9: iGold = 36000; break;
        case 10: iGold = 49000; break;
        case 11: iGold = 66000; break;
        case 12: iGold = 88000; break;
        case 13: iGold = 110000; break;
        case 14: iGold = 150000; break;
        case 15: iGold = 200000; break;
        case 16: iGold = 260000; break;
        case 17: iGold = 340000; break;
        case 18: iGold = 440000; break;
        case 19: iGold = 580000; break;
        case 20: iGold = 760000; break;
        case 21: iGold = 940000; break;
        case 22: iGold = 1120000; break;
        case 23: iGold = 1300000; break;
        case 24: iGold = 1480000; break;
        case 25: iGold = 1660000; break;
        case 26: iGold = 1840000; break;
        case 27: iGold = 2020000; break;
        case 28: iGold = 2200000; break;
        case 29: iGold = 2380000; break;
        case 30: iGold = 2560000; break;
        case 31: iGold = 2740000; break;
        case 32: iGold = 2920000; break;
        case 33: iGold = 3100000; break;
        case 34: iGold = 3280000; break;
        case 35: iGold = 3460000; break;
        case 36: iGold = 3640000; break;
        case 37: iGold = 3820000; break;
        case 38: iGold = 4000000; break;
        case 39: iGold = 4180000; break;
        case 40: iGold = 4360000; break;
        //default: iGold = -1;
        }

    SendMessageToPC(oPC, "Your net wealth is " + IntToString(iNetWealth));
    SendMessageToPC(oPC, "Suggested wealth for level " + IntToString(iPCLevel) + " is " + IntToString(iGold));
    if (iGold < iNetWealth)
        {
        int iDiff = iNetWealth - iGold;
        SendMessageToPC(oPC, "Your wealth is " + IntToString(iDiff) + " GP over.");
        iLevelExceeded = 1;
        }

    if (iLevelExceeded == 0)
        {
        SendMessageToPC(oPC, GetName(oPC) + " is the fairest of all.");
        PlaySound("sco_positive");
        }
    else PlaySound("as_cv_glasbreak2");

    SendMessageToPC(oPC, "========================================");
}
