using UnityEngine;

public enum ActionType
{
    //actions
    JOB_HUNT,
    BAR,
    PAID_SEX,
    BRIBE,
    LIBRARY,
    CHURCH,
    CASINO,
    GO_ON,
    //interview
    IDLE,
    CHEERY,
    STOIC,
    UNFRIENDLY,
    HUMBLE,
    JACKASS,
    SPACED,
    DILIGENT,
    MOJOPLUS,
    ANXIOUS,
    //levels
    LEVEL0 = 100,
    LEVEL1 = 101,
    LEVEL2 = 102,
    LEVEL3 = 103,
    LEVEL4 = 104,
    LEVEL5 = 105,
    LEVEL6 = 106,
    LEVEL7 = 107,
}

public static class GameAction {
    public const float bing = 1000f;
    public static float GetResult(ActionType type, float factor, ref float wealth, ref float mojo)
    {
        float ret = 0f; //return value is jobresult delta (to be added) or bing
        float wealthPlus = 0f;
        float mojoPlus = 0f;
        factor = factor / 100f;//work in percentages
        if((int) type >=100)
        {
            switch(type)
            {
                case ActionType.LEVEL0:
                    if(Random.Range(0f, 1f)<0.2f)
                    {
                        wealth += factor;
                    }
                    if(Random.Range(0f, 1f)<0.5f)
                    {
                        mojo +=-1*  factor;
                    }
                    break;

                case ActionType.LEVEL1:
                    wealth +=2 * factor;
                    mojo +=-1 * factor;
                    break;

                case ActionType.LEVEL2:
                    wealth +=2 * factor;
                    if(Random.Range(0f, 1f)<0.5f)
                    { 
                        mojo +=-1* factor;
                    }
                    break;
                case ActionType.LEVEL3:
                     wealthPlus =1f * factor;
                     mojoPlus =2f * factor;
                    if(Random.Range(0f, 1f)<0.2f)
                    {
                        wealthPlus *= 3;
                        mojoPlus *= 3;
                        ret = bing;
                    }
                    mojo += mojoPlus;
                    wealth+= wealthPlus;
                    break;

                case ActionType.LEVEL4:
                     wealthPlus =2f * factor;
                     mojoPlus =1f * factor;
                    if(Random.Range(0f, 1f)<0.2f)
                    {
                        wealthPlus *= 4f;
                        mojoPlus *= 4f;
                        ret = bing;
                    }
                    mojo += mojoPlus;
                    wealth+= wealthPlus;
                    break;

                case ActionType.LEVEL5:
                    wealth+= 3f * factor;
                    if (Random.Range(0f, 1f) < 0.5f)
                    {
                        mojo+= 1f*factor;
                    }
                    break;

                case ActionType.LEVEL6:
                     wealthPlus = 4f * factor;
                     mojoPlus = 2f * factor;
                    if (Random.Range(0f, 1f) < 0.2f)
                    {
                        wealthPlus *= 2f;
                        mojoPlus *= 2f;
                        ret = bing;
                    }
                    mojo += mojoPlus;
                    wealth += wealthPlus;
                    break;

                case ActionType.LEVEL7:
                     wealthPlus = 5f * factor;
                     mojoPlus = 3f * factor;
                    if (Random.Range(0f, 1f) < 0.2f)
                    {
                        wealthPlus *= 3f;
                        mojoPlus *= 3f;
                        ret = bing;
                    }
                    mojo += mojoPlus;
                    wealth += wealthPlus;
                    break;
            }
        }
        else
        {
            switch(type)
            {
				 case ActionType.JOB_HUNT:
                    mojo += -1 * factor;
                    break;
				 case ActionType.BAR:
                    mojo += 1 * factor;
                    if (Random.Range(0f, 1f) < 0.2f)
                    {
                        wealth += -1f * factor;
                    }
                    break;
				 case ActionType.GO_ON:
                    mojo += 1 * factor;
                    if (Random.Range(0f, 1f) < 0.5f)
                    {
                        wealth += -1f * factor;
                    }
                    break;
				 case ActionType.PAID_SEX:
                    mojo += 2 * factor;
                    wealth += -1f * factor;
                    break;
				 case ActionType.BRIBE:
                    wealth += -1f * factor;
                    mojo += -1 * factor;
                    if (Random.Range(0f, 1f) < 0.5f)
                    {
                        ret = 3*factor;
                    }
                    break;
				 case ActionType.LIBRARY:
                    if (Random.Range(0f, 1f) < 0.5f)
                    {
                        mojo +=1 * factor;
                    }
                    break;
				 case ActionType.CASINO:
                    wealth+=-1f * factor;
                    if(Random.Range(0f, 1f) < 0.2f)
                    {
                        mojo +=-1f * factor;
                    }
                    if(Random.Range(0f, 1f) < 0.1f)
                    {
                        wealth +=5f * factor;
                    }
                    break;
				 case ActionType.CHEERY:
                    mojo +=1f * factor;
                    if (Random.Range(0f, 1f) < 0.5f)
                    {
                        ret = 1f * factor;
                    }
                    break;
				 case ActionType.STOIC:
                    mojo +=1f * factor;
                    if (Random.Range(0f, 1f) < 0.5f)
                    {
                        ret = -1f * factor;
                    }
                    break;
				 case ActionType.UNFRIENDLY:
                    ret = -1f * factor;
                    break;
				 case ActionType.HUMBLE:
                    if (Random.Range(0f, 1f) < 0.2f)
                    {
                        ret = 1f * factor;
                    }
                    if (Random.Range(0f, 1f) < 0.2f)
                    {
                        mojo += 1f*factor;
                    }
                    break;
				 case ActionType.JACKASS:
                    ret = -2 * factor;
                    if (Random.Range(0f, 1f) < 0.5f)
                    {
                        mojo += 2 * factor;
                    }
                    break;
				 case ActionType.SPACED:
                    ret = -1 * factor;
                    if (Random.Range(0f, 1f) < 0.2f)
                    {
                        mojo += 1f*factor;
                    }
                    break;
                case ActionType.DILIGENT:
                    ret = 1 * factor;
                    if (Random.Range(0f, 1f) < 0.5f)
                    {
                        mojo += -1f*factor;
                    }

                    break;
				 case ActionType.MOJOPLUS:
                    if (Random.Range(0f, 1f) < 0.5f)
                    {
                        mojo += 1f * factor;
                    }
                    break;

				 case ActionType.ANXIOUS:
                    if (Random.Range(0f, 1f) < 0.5f)
                    {
                        ret = 1f * factor;
                    }
                    if (Random.Range(0f, 1f) < 0.5f)
                    {
                        mojo += 1f * factor;
                    }

                    break;
            }
        }
        return ret;
    }
}
