示例#1
0
 public ActionsDTO(TamaguchiBL.Models.Action a)
 {
     actionId        = a.ActionId;
     actionName      = a.ActionName;
     actionTypeId    = a.ActionTypeId;
     actionEffection = a.ActionEffection;
 }
示例#2
0
        public PetsDTO Feed([FromQuery] int actionId)
        {
            PlayerDTO pDto = HttpContext.Session.GetObject <PlayerDTO>("player");

            if (pDto != null)
            {
                Player p = context.Players.Where(pp => pp.UserName == pDto.UserName).FirstOrDefault();
                TamaguchiBL.Models.Action ac = context.Actions.Where(a => a.ActionId == actionId).FirstOrDefault();
                Pet pe = p.Pets.Where(a => a.LifeCycleId == 1).FirstOrDefault();
                if (pe == null)
                {
                    return(null);
                }
                else
                {
                    context.FeedAnimal(pe, ac);

                    Console.WriteLine($"the pet ate {ac.ActionName}");
                    //Console.ReadKey();
                    Response.StatusCode = (int)System.Net.HttpStatusCode.OK;

                    return(new PetsDTO(pe));
                }
                //p.Pets.Where(a => a.LifeCycleId == 0).FirstOrDefault().FeedAnimal(context.Actions.Where(x=>x.ActionId== actionId).FirstOrDefault());
            }
            else
            {
                Response.StatusCode = (int)System.Net.HttpStatusCode.Forbidden;
                return(null);
            }
        }
示例#3
0
        public void Play([FromBody] ActionsDTO actionsDTO)
        {
            PlayerDTO pDto = HttpContext.Session.GetObject <PlayerDTO>("player");

            if (pDto != null)
            {
                Player p   = context.Players.Where(pp => pp.UserName == pDto.UserName).FirstOrDefault();
                Pet    pet = p.Pets.Where(a => a.LifeCycleId == 1).FirstOrDefault();
                //TamaguchiBL.Models.Action action = new TamaguchiBL.Models.Action
                //{
                //    ActionName = actionsDTO.actionName,
                //    ActionEffection = actionsDTO.actionEffection,
                //    ActionId = actionsDTO.actionId
                //};
                TamaguchiBL.Models.Action ac = context.Actions.Where(a => a.ActionId == actionsDTO.actionId).FirstOrDefault();
                context.Play(pet, ac);
                Response.StatusCode = (int)System.Net.HttpStatusCode.OK;
            }
        }