Exemple #1
0
    private string VerifyInstructions(string instruct)
    {
        string      _otherResponse   = "other";
        List <Plot> plots            = FindPlots();
        String      toFormat         = "";
        var         temporaryHarvest = 0;

        if (!OptionsAndResponses.ContainsKey(instruct))
        {
            return(OptionsAndResponses[_otherResponse]);
        }
        else if (plots.Capacity == 0 && instruct != "help" && instruct != "wait" && instruct != "sacrifice")
        {
            return(OptionsAndResponses[_otherResponse]);
        }
        else
        {
            switch (instruct)
            {
            case "help":
                return(OptionsAndResponses[instruct]);

            case "plant":
                foreach (Plot p in plots)
                {
                    p.Plant();
                }
                toFormat = OptionsAndResponses[instruct];
                return(String.Format(toFormat, plots.Count));

            case "water":
                foreach (Plot p in plots)
                {
                    p.Water();
                }
                toFormat = OptionsAndResponses[instruct];
                return(String.Format(toFormat, plots.Count));

            case "feed":
                toFormat = OptionsAndResponses[instruct];
                return(String.Format(toFormat, plots.Count));

            case "harvest":
                foreach (Plot p in plots)
                {
                    var worked = p.Harvested();
                    if (worked)
                    {
                        temporaryHarvest++;
                        _harvested++;
                    }
                }

                toFormat = OptionsAndResponses[instruct];
                return(String.Format(toFormat, temporaryHarvest));

            case "sacrifice":
                _sacrificed = _sacrificed + _harvested;
                if (_sacrificed >= _limit)
                {
                    _limit = _limit + 9;
                    rain.IncreaseRain();
                }
                if (_sacrificed > _ending - 10)
                {
                    BeginTheEnd();
                }
                if (_sacrificed > _ending)
                {
                    GameOver.Instance.InitiateGameOver(_days);
                    Restart();
                }
                toFormat = OptionsAndResponses[instruct];
                var toReturn = String.Format(toFormat, _harvested);
                _harvested = 0;
                return(toReturn);

            case "wait":
                SkipTime();
                DayPass();
                return(OptionsAndResponses[instruct]);

            default:
                return(OptionsAndResponses[_otherResponse]);
            }
        }
    }