Esempio n. 1
0
        public void can_drink_contained_liquids()
        {
            Location = Rooms.Get <BelowTheGrate>();

            Bottle bottle = Objects.Get <Bottle>();

            bottle.Add <WaterInTheBottle>();

            Inventory.Add(bottle);

            Execute("drink h2o");
            Assert.Equal("You drink the cool, refreshing water, draining the bottle in the process.", Line1);
        }
Esempio n. 2
0
        public void should_empty_bottle()
        {
            Bottle bottle = Objects.Get <Bottle>() as Bottle;

            bottle.Add <WaterInTheBottle>();

            Inventory.Add(bottle);

            Assert.AreEqual(1, bottle.Contents.Count);

            parser.Parse("drink water");

            Assert.AreEqual(0, bottle.Contents.Count);
        }
Esempio n. 3
0
        public void can_drink_contained_liquids()
        {
            Location = Rooms.Get <BelowTheGrate>();

            Bottle bottle = Objects.Get <Bottle>() as Bottle;

            bottle.Add <WaterInTheBottle>();

            Inventory.Add(bottle);

            IList <string> results = parser.Parse("drink h2o");

            Assert.AreEqual("You drink the cool, refreshing water, draining the bottle in the process.", results[0]);
        }
Esempio n. 4
0
        public void should_favor_inventory_over_location()
        {
            // there are two sources of water: the stream and the bottle in inventory
            Location = Rooms.Get <InsideBuilding>();

            Bottle bottle = Objects.Get <Bottle>() as Bottle;

            bottle.Add <WaterInTheBottle>();

            Inventory.Add(bottle);

            IList <string> results = parser.Parse("drink water");

            Assert.AreEqual("You drink the cool, refreshing water, draining the bottle in the process.", results[0]);
        }
Esempio n. 5
0
        public void should_empty_bottle()
        {
            Location = Rooms.Get <Forest1>();

            Bottle bottle = Objects.Get <Bottle>();

            bottle.Add <WaterInTheBottle>();

            Inventory.Add(bottle);

            Assert.Equal(1, bottle.Contents.Count);

            Execute("drink water");

            Assert.Equal("You drink the cool, refreshing water, draining the bottle in the process.", Line1);
            Assert.Equal(0, bottle.Contents.Count);
        }
Esempio n. 6
0
        public void should_favor_location_over_inventory()
        {
            // there are two sources of water: the stream and the bottle in inventory
            Location = Rooms.Get <InsideBuilding>();

            Bottle bottle = Objects.Get <Bottle>();

            bottle.Add <WaterInTheBottle>();

            Inventory.Add(bottle);

            Execute("drink water");

            Assert.Contains("You have taken a drink from the stream.", ConsoleOut);
            Assert.Contains("The water tastes strongly of minerals, but is not unpleasant.", ConsoleOut);
            Assert.Contains("It is extremely cold.", ConsoleOut);
        }
        public JsonResult AddDriftBottle(Bottle bottle)
        {
            //Bottle bottle = new Bottle();
            if (string.IsNullOrWhiteSpace(bottle.Massage))
            {
                return(Json(new Result(false, "多少说点东西!"), JsonRequestBehavior.AllowGet));
            }
            if (bottle.Massage.Length > 300)
            {
                return(Json(new Result(false, "内容太多了!"), JsonRequestBehavior.AllowGet));
            }

            string currentUserNanme = "妩媚的阳光";

            //如果是管理员丢瓶子,则随机名字
            if (CurrentInfo.CurrentUser.ID == 6)
            {
                Random rd = new Random();
                currentUserNanme = NetUserNames.NetUserGirl[rd.Next(0, NetUserNames.NetUserGirl.Count)];
            }
            else
            {
                currentUserNanme = CurrentInfo.CurrentUser.RealName;
            }

            bottle.FishingCount   = 0;
            bottle.CreateTime     = DateTime.Now;
            bottle.CreateUserID   = CurrentInfo.CurrentUser.ID;
            bottle.Sexual         = CurrentInfo.CurrentUser.Sexual;
            bottle.CreateUserName = currentUserNanme;

            bottle.LastReplyMassage = bottle.Massage;
            bottle.LastReplyUserID  = CurrentInfo.CurrentUser.ID;;


            bottle.LastReplyUserName = currentUserNanme;
            bottle.LastReplyTime     = DateTime.Now;
            bottle.CreateViewTime    = DateTime.Now;
            bottle.ReplyViewTime     = DateTime.Now;
            bool flage = bottle.Add() == null ? false : true;

            return(Json(new Result(flage, ResultType.Add), JsonRequestBehavior.AllowGet));
        }