コード例 #1
0
        public ActionResult Train()
        {
            if (SessionHelper.CurrentEntity.Is(EntityTypeEnum.Citizen) == false)
            {
                return(RedirectToHomeWithError("You are not a citizen!"));
            }

            var citizen = SessionHelper.LoggedCitizen;

            if (citizen.HitPoints <= 0)
            {
                return(RedirectBackWithError("You do not have enough hitpoints!"));
            }

            if (citizen.Trained)
            {
                return(RedirectBackWithError("You had trained today!"));
            }
            double strengthGain = citizenService.Train(citizen);

            return(View(new TrainingDoneViewModel(SessionHelper.LoggedCitizen, strengthGain)));
        }