int ddReturn(int selector)
    {
        if (selector == 0)
        {
            NPCData.Jobs job = NPCCharList.CharRetainers [idxCL].cityJobs;
            switch (job)
            {
            case NPCData.Jobs.CastleRest: return(0);

            case NPCData.Jobs.CastleDomestic: return(1);

            case NPCData.Jobs.CastleCook: return(2);

            case NPCData.Jobs.CastleHealer: return(3);

            case NPCData.Jobs.CastleHunter: return(4);

            case NPCData.Jobs.CastleEntertainer: return(5);

            case NPCData.Jobs.CastleArtisan: return(6);

            case NPCData.Jobs.CastleFarmhand: return(7);

            case NPCData.Jobs.CastleScribe: return(8);

            case NPCData.Jobs.CastleProstitute: return(9);

            case NPCData.Jobs.CastleAccountant: return(10);

            case NPCData.Jobs.CastleSlaveMaster: return(11);

            case NPCData.Jobs.CastleGuard: return(12);

            case NPCData.Jobs.CastleCaptain: return(13);

            case NPCData.Jobs.CastleCourtier: return(14);

            case NPCData.Jobs.CastleCounselor: return(15);

            default: return(0);
            }
        }
        else if (selector == 1)
        {
            fileRulesNPC.Wages wages = RulesNPC.savedRules[idxRN].wage;
            switch (wages)
            {
            case fileRulesNPC.Wages.None: return(0);

            case fileRulesNPC.Wages.Low: return(1);

            case fileRulesNPC.Wages.Average: return(2);

            case fileRulesNPC.Wages.Good: return(3);

            case fileRulesNPC.Wages.High: return(4);

            case fileRulesNPC.Wages.Exorbitant: return(5);

            default: return(0);
            }
        }
        else if (selector == 2)
        {
            fileRulesNPC.Sleeping sleeping = RulesNPC.savedRules[idxRN].sleeping;
            switch (sleeping)
            {
            case fileRulesNPC.Sleeping.Ground: return(0);

            case fileRulesNPC.Sleeping.Barracks: return(1);

            case fileRulesNPC.Sleeping.PrivateRoom: return(2);

            case fileRulesNPC.Sleeping.Boudoir: return(3);

            case fileRulesNPC.Sleeping.MCRoom: return(4);

            case fileRulesNPC.Sleeping.Dungeon: return(5);

            default: return(0);
            }
        }
        else
        {
            fileRulesNPC.Diet diet = RulesNPC.savedRules[idxRN].diet;
            switch (diet)
            {
            case fileRulesNPC.Diet.RancidFood: return(0);

            case fileRulesNPC.Diet.CheapFood: return(1);

            case fileRulesNPC.Diet.FreshFood: return(2);

            case fileRulesNPC.Diet.LeftOvers: return(3);

            case fileRulesNPC.Diet.BeastsCum: return(4);

            default: return(0);
            }
        }
    }
    static string updateDiet(fileRulesNPC.Diet diet, bool aphrodisiac, int idx)
    {
        Random.InitState(WorldControl.day * System.DateTime.Now.Millisecond + 15);
        if (aphrodisiac && CastleController.castleSupplies > 5)
        {
            CastleController.castleSupplies--;
            NPCCharList.CharRetainers [idx].currentArousal += Random.Range(4, 15);
        }

        if (NPCCharList.CharRetainers [idx].isSlave)
        {
            switch (diet)
            {
            case fileRulesNPC.Diet.RancidFood:
                if ((int)NPCCharList.CharRetainers [idx].bgUpbring >= 3)
                {
                    NPCCharList.CharRetainers [idx].attHappiness -= Random.Range(1f, 3f);
                }
                NPCCharList.CharRetainers [idx].attHappiness -= Random.Range(0, 3);
                return("");

            case fileRulesNPC.Diet.CheapFood:
                if (CastleController.castleSupplies >= 1)
                {
                    CastleController.castleSupplies--;
                    if ((int)NPCCharList.CharRetainers [idx].bgUpbring >= 3)
                    {
                        NPCCharList.CharRetainers [idx].attHappiness -= Random.Range(0.5f, 1.5f) - CastleController.castleFoodQuality;
                    }
                    return("");
                }
                else
                {
                    if ((int)NPCCharList.CharRetainers [idx].bgUpbring >= 3)
                    {
                        NPCCharList.CharRetainers [idx].attHappiness -= Random.Range(1f, 3f);
                    }
                    NPCCharList.CharRetainers [idx].attHappiness -= Random.Range(0, 3);
                    return("\n\nYou don't have enough supplies for food! You forced " + NPCCharList.CharRetainers [idx].charName + " to eat rancid food!");
                }

            case fileRulesNPC.Diet.FreshFood:
                if (CastleController.castleSupplies >= 2)
                {
                    CastleController.castleSupplies -= 2;
                    NPCCharList.CharRetainers [idx].attHappiness += Random.Range(1.5f, 3.5f) * CastleController.castleFoodQuality;
                    return("");
                }
                else
                {
                    if ((int)NPCCharList.CharRetainers [idx].bgUpbring >= 3)
                    {
                        NPCCharList.CharRetainers [idx].attHappiness -= Random.Range(1f, 3f);
                    }
                    NPCCharList.CharRetainers [idx].attHappiness -= Random.Range(0, 3);
                    return("\n\nYou don't have enough supplies for food! You forced " + NPCCharList.CharRetainers [idx].charName + " to eat rancid food!");
                }

            case fileRulesNPC.Diet.LeftOvers:
                if (CastleController.castleSupplies >= 2)
                {
                    CastleController.castleSupplies -= 2;
                    NPCCharList.CharRetainers [idx].attHappiness += Random.Range(2f, 4.5f) * CastleController.castleFoodQuality;
                    return("");
                }
                else
                {
                    if ((int)NPCCharList.CharRetainers [idx].bgUpbring >= 3)
                    {
                        NPCCharList.CharRetainers [idx].attHappiness -= Random.Range(1f, 3f);
                    }
                    NPCCharList.CharRetainers [idx].attHappiness -= Random.Range(0, 3);
                    return("\n\nYou don't have enough supplies for food! You forced " + NPCCharList.CharRetainers [idx].charName + " to eat rancid food!");
                }

            case fileRulesNPC.Diet.BeastsCum:
                if (NPCCharList.CharRetainers [idx].charCorruption < 60)
                {
                    NPCCharList.CharRetainers [idx].attHappiness -= Random.Range(4, 8);
                }
                else if (NPCCharList.CharRetainers [idx].charCorruption < 80)
                {
                    NPCCharList.CharRetainers [idx].attHappiness -= Random.Range(2, 4);
                }
                else
                {
                    NPCCharList.CharRetainers [idx].attHappiness += Random.Range(1, 3);
                }
                return("");
            }
        }
        else
        {
            switch (diet)
            {
            case fileRulesNPC.Diet.RancidFood:
                if ((int)NPCCharList.CharRetainers [idx].bgUpbring >= 3)
                {
                    NPCCharList.CharRetainers [idx].attHappiness -= Random.Range(1f, 3f);
                }
                NPCCharList.CharRetainers [idx].attHappiness -= Random.Range(2, 5);
                return("");

            case fileRulesNPC.Diet.CheapFood:
                if (CastleController.castleSupplies >= 1)
                {
                    CastleController.castleSupplies -= 1;
                    if ((int)NPCCharList.CharRetainers [idx].bgUpbring >= 3)
                    {
                        NPCCharList.CharRetainers [idx].attHappiness -= Random.Range(0f, 1f) - CastleController.castleFoodQuality;
                    }
                    NPCCharList.CharRetainers [idx].attHappiness -= Random.Range(0f, 1f) - CastleController.castleFoodQuality;
                    return("");
                }
                else
                {
                    if ((int)NPCCharList.CharRetainers [idx].bgUpbring >= 3)
                    {
                        NPCCharList.CharRetainers [idx].attHappiness -= Random.Range(1f, 3f);
                    }
                    NPCCharList.CharRetainers [idx].attHappiness -= Random.Range(2, 5);
                    return("\n\nYou don't have enough supplies for food! You forced " + NPCCharList.CharRetainers [idx].charName + " to eat rancid food!");
                }

            case fileRulesNPC.Diet.FreshFood:
                if (CastleController.castleSupplies >= 2)
                {
                    CastleController.castleSupplies -= 2;
                    NPCCharList.CharRetainers [idx].attHappiness += Random.Range(1f, 2.5f) * CastleController.castleFoodQuality;
                    return("");
                }
                else
                {
                    if ((int)NPCCharList.CharRetainers [idx].bgUpbring >= 3)
                    {
                        NPCCharList.CharRetainers [idx].attHappiness -= Random.Range(1f, 3f);
                    }
                    NPCCharList.CharRetainers [idx].attHappiness -= Random.Range(2, 5);
                    return("\n\nYou don't have enough supplies for food! You forced " + NPCCharList.CharRetainers [idx].charName + " to eat rancid food!");
                }

            case fileRulesNPC.Diet.LeftOvers:
                if (CastleController.castleSupplies >= 2)
                {
                    CastleController.castleSupplies -= 2;
                    NPCCharList.CharRetainers [idx].attHappiness += Random.Range(2f, 4f) * CastleController.castleFoodQuality;
                    return("");
                }
                else
                {
                    if ((int)NPCCharList.CharRetainers [idx].bgUpbring >= 3)
                    {
                        NPCCharList.CharRetainers [idx].attHappiness -= Random.Range(1f, 3f);
                    }
                    NPCCharList.CharRetainers [idx].attHappiness -= Random.Range(2, 5);
                    return("\n\nYou don't have enough supplies for food! You forced " + NPCCharList.CharRetainers [idx].charName + " to eat rancid food!");
                }

            case fileRulesNPC.Diet.BeastsCum:
                if (NPCCharList.CharRetainers [idx].charCorruption < 60)
                {
                    NPCCharList.CharRetainers [idx].attHappiness -= Random.Range(5, 10);
                }
                else if (NPCCharList.CharRetainers [idx].charCorruption < 80)
                {
                    NPCCharList.CharRetainers [idx].attHappiness -= Random.Range(2.5f, 5);
                }
                else
                {
                    NPCCharList.CharRetainers [idx].attHappiness += Random.Range(1, 3);
                }
                return("");
            }
        }
        return("bug in CastleLivingConditionsUpdate.updateDiet");
    }