Exemple #1
0
        public ActionResult FastTravel()
        {
            var userId         = User.Identity.GetUserId();
            var user           = db.Users.Find(userId);
            var rainbowGemCost = Convert.ToInt32(Request.Form.Get("rainbowGemCost"));

            if (!db.Travels.Any(t => t.UserId == userId) || user.RainbowGems < rainbowGemCost)
            {
                return(RedirectToAction("Index"));
            }

            user.RainbowGems -= rainbowGemCost;

            var travel = db.Travels.First(t => t.UserId == userId);

            travel.ArrivalTime = DateTimeOffset.Now;

            db.SaveChanges();

            var travelService = new TravelService();

            travelService.CheckArrivalTime(userId);

            return(RedirectToAction("Index", "Land"));
        }
Exemple #2
0
        private static async Task ResultsStepSearch(DialogContext dc, IDictionary <string, object> args, SkipStepFunction next)
        {
            await dc.Context.SendActivity("Je recherche une destination qui pourrait vous intéresser, merci de patienter.");

            var state   = dc.Context.GetUserState <UserTravelState>();
            var travels = await TravelService.SearchTravelsAsync(state.Continent, state.Activities);

            var travel = travels.FirstOrDefault();

            if (travel == null)
            {
                state.CurrentTravelId = null;
                await dc.Prompt("ActionPrompt", "Désolé, je n'ai trouvé aucune destination. Voulez-vous lancer une nouvelle recherche ?");
            }
            else
            {
                state.CurrentTravelId = travel.Id;

                var activity = MessageFactory.ContentUrl(travel.MainImage.Url, "image/jpg", text: $"J'ai trouvé une destination : {travel.Days} jours pour {travel.Desc}");
                await dc.Context.SendActivity(activity);

                await Task.Delay(500);

                await dc.Prompt("ActionPrompt", "Voulez-vous réserver cette destination ?");
            }
        }
        public TravelListsPage()
        {
            InitializeComponent();

            _travelService = new TravelService();

            travelList.ItemsSource = _travelService.GetMockedTravelLists();
        }
 public TravelListPageViewModel(
     INavigationService navigationService,
     IPageDialogService dialogService,
     TravelService travelService
     ) : base(navigationService, dialogService)
 {
     this._travelService = travelService;
 }
Exemple #5
0
        public void Should_ReturnNull_When_DistanceLessThanZero()
        {
            var connectionMock = new Mock <IStarshipRepository>();

            TravelService travelService = new TravelService(connectionMock.Object);
            var           travels       = travelService.FindStops(0, new Starship());

            travels.Should().Be(null);
        }
 public AdminController(QuantitySevice quantitySevice, TravelService travelService,
                        IHostingEnvironment hostingEnvironment, TourContext db,
                        StaffService staffService)
 {
     this._staffService       = staffService;
     this._hostingEnvironment = hostingEnvironment;
     this._quantitySevice     = quantitySevice;
     this._travelService      = travelService;
     this._db = db;
 }
        public MainPage()
        {
            _service = new TravelService();
            InitializeComponent();

            //Event handlers
            TxtOriginLocation.TextChanged          += StartLocation_TextChanged;
            TxtDestinationLocation.TextChanged     += FinalLocation_TextChanged;
            OriginPicker.SelectedIndexChanged      += StartPicker_Selected;
            DestinationPicker.SelectedIndexChanged += FinalPicker_Selected;
            BtnSearch.Clicked += BtnSearch_Clicked;
        }
        public async void GetTravelAlertInfoAsyncTest()
        {
            // Arrange
            var newsService = new TravelService(_netService);

            // Act
            var items = await newsService.GetTravelAlertsAsync("國際重要疫情");

            // Assert
            Assert.True(items.Any());

            this._output.WriteLine(items.First().Headline);
        }
        //Кастуем урон
        private static async Task CastDamage(Person player, Magic magic, SocketCommandContext Context)
        {
            if (player.fight == false)
            {
                await Task.Run(() => Loging.Log(Context.User.Username + " кастанул " + magic.name + " в воздух и вокруг теперь " + magic.effect, Context.Channel));
            }
            else
            {
                player.p_Mana -= magic.cost;

                await TravelService.SetAttack(player, magic);
            }
        }
Exemple #10
0
        //Получаем урон
        public async Task GetDamage(Person hero, Magic magic = null)
        {
            var chanel = KingdomRun.client.GetChannel(room) as IMessageChannel;

            if (heroes.TryAdd(hero.name, hero))
            {
                heroes.Add(hero.name, hero);
            }

            //Если это не магия
            if (magic == null)
            {
                Random rand = new Random();

                float damag = rand.Next(hero.m_Attack - 10, hero.m_Attack + 10);

                damag = damage - (defence * 0.75f);

                hp = (int)(hp - damag);

                await Loging.Log(name + " получил " + hero.m_Attack + " урона. Осталось " + hp + " здоровья!", chanel);
            }
            else//если все таки магия
            {
                hp = (int)(hp - magic.value);

                await Loging.Log(name + " получил " + magic.value + " урона. Осталось " + hp + " здоровья!", chanel);

                await Loging.Log(name + " теперь " + magic.effect, chanel);
            }

            //Если враг побежден
            if (hp <= 0)
            {
                await Loging.Log(name + " побежден!", chanel);

                float splitExp = exp / heroes.Count;

                //распределяем опыт между игроками
                foreach (KeyValuePair <string, Person> p in heroes)
                {
                    p.Value.fight = false;

                    await p.Value.GetExp((int)splitExp);
                }

                await TravelService.CheckEnemys();

                return;
            }
        }
Exemple #11
0
 public AdminController(YourTourContext db, IHostingEnvironment hostingEnvironment,
                        TravelService travelService, StaffService staffService, LocationService locationService,
                        CommonService commonService, AdminService adminService, TourService tourService,
                        HoaDonService hoaDonService, LienHeService lienHeService)
 {
     this._db = db;
     this._hostingEnvironment = hostingEnvironment;
     this._travelService      = travelService;
     this._staffService       = staffService;
     this._locationService    = locationService;
     this._commonService      = commonService;
     this._adminService       = adminService;
     this._tourService        = tourService;
     this._hoaDonService      = hoaDonService;
     this._lienHeService      = lienHeService;
 }
Exemple #12
0
        public void ValidateTravel_Invalid()
        {
            var mockContext = new Mock<ApplicationDbContext>();

            var locationMockDbSet = new MockDbSet<Location>();
            mockContext.Setup(m => m.Locations).Returns(locationMockDbSet.DbSet.Object);

            var entryCharMockDbSet = new MockDbSet<EntryLocationCharacter>();
            mockContext.Setup(m => m.EntryLocationCharacters).Returns(entryCharMockDbSet.DbSet.Object);

            var service = new TravelService(mockContext.Object);

            var result = service.ValidateTravel("tag", 1);

            Assert.IsFalse(result.IsValid);
            Assert.AreEqual(result.Messages.Count(), 2);
        }
Exemple #13
0
        public void Should_Valid_When_NumberTravelsEqualsToNumberStarshipsVo()
        {
            var connectionMock = new Mock <IStarshipRepository>();

            connectionMock.Setup(p => p.GetAllData())
            .Returns(new List <StarshipVo>()
            {
                new StarshipVo(), new StarshipVo()
            });

            var repository = connectionMock.Object;

            TravelService travelService = new TravelService(connectionMock.Object);
            var           travels       = travelService.NumberOfStops(100);

            travels.Should().HaveCount(2);
        }
Exemple #14
0
        public void Should_NumberStops_When_DistanceGreaterThanZero()
        {
            double distance = 55;
            double _MGLT    = 10;

            var connectionMock = new Mock <IStarshipRepository>();

            TravelService travelService = new TravelService(connectionMock.Object);
            var           travels       = travelService.FindStops(distance, new Starship()
            {
                MGLT = _MGLT
            });

            var stops = Math.Floor(distance / _MGLT);

            travels.stops.Should().Be(stops);
        }
Exemple #15
0
        public void ValidateTravel_Valid()
        {
            var mockContext = new Mock<ApplicationDbContext>();

            var locationMockDbSet = new MockDbSet<Location>();
            locationMockDbSet.Add(new Location { Tag = "tag", Type = ModelEnums.LocationType.City });
            mockContext.Setup(m => m.Locations).Returns(locationMockDbSet.DbSet.Object);

            var entryCharMockDbSet = new MockDbSet<EntryLocationCharacter>();
            entryCharMockDbSet.Add(new EntryLocationCharacter { Arrival = DateTime.Now.AddHours(-1), Character_Id = 1 });
            mockContext.Setup(m => m.EntryLocationCharacters).Returns(entryCharMockDbSet.DbSet.Object);

            var service = new TravelService(mockContext.Object);

            var result = service.ValidateTravel("tag", 1);

            Assert.IsTrue(result.IsValid);
        }
    // Should move this to another class
    private void AddServices(GameObject gameObject)
    {
        var services = aiData.GetServices();

        // Give all Npc's persuasion
        PersuasionService.Create(gameObject);

        foreach (var service in services)
        {
            switch (service)
            {
            case Service.Barter:
                BarterService.Create(gameObject);
                break;

            case Service.Enchanting:
                EnchantingService.Create(gameObject);
                break;

            case Service.Repair:
                RepairService.Create(gameObject);
                break;

            case Service.Spellmaking:
                SpellmakingService.Create(gameObject);
                break;

            case Service.Spells:
                SpellService.Create(gameObject);
                break;

            case Service.Training:
                TrainingService.Create(gameObject);
                break;
            }
        }

        if (destinationData != null && destinationData.Count > 0)
        {
            TravelService.Create(gameObject);
        }
    }
        public HomePage()
        {
            _travels = new ObservableCollection <Travel>();

            this.InitializeComponent();

            LoaderProgressRing.IsActive = true;

            Task.Run(() =>
            {
                return(TravelService.GetAllTravelsAsync());
            }).ContinueWith(x =>
            {
                foreach (var travel in x.Result.Take(MaxElements))
                {
                    Travels.Add(travel);
                }

                LoaderProgressRing.IsActive = false;
            }, TaskScheduler.FromCurrentSynchronizationContext());
        }
Exemple #18
0
        public void Travel()
        {
            var mockContext = new Mock<ApplicationDbContext>();

            var locationMockDbSet = new MockDbSet<Location>();
            locationMockDbSet.Add(new Location { Tag = "tag", Type = ModelEnums.LocationType.City });
            mockContext.Setup(m => m.Locations).Returns(locationMockDbSet.DbSet.Object);

            var entryCharMockDbSet = new MockDbSet<EntryLocationCharacter>();
            entryCharMockDbSet.Add(new EntryLocationCharacter { Arrival = DateTime.Now.AddHours(-1), Character_Id = 1 });
            mockContext.Setup(m => m.EntryLocationCharacters).Returns(entryCharMockDbSet.DbSet.Object);

            var service = new TravelService(mockContext.Object);

            service.Travel("tag", 1);

            mockContext.Verify(m => m.SaveChanges(), Times.Once());
            Assert.AreEqual(entryCharMockDbSet.Items.Count(), 2);
            Assert.IsNotNull(entryCharMockDbSet.Items.First().Leaves);
            Assert.IsNull(entryCharMockDbSet.Items.Last().Leaves);
        }
Exemple #19
0
        public async Task SmashPly(string msg)
        {
            var chanel = KingdomRun.client.GetChannel(ulong.Parse(lastRoom)) as IMessageChannel;

            var mob = TravelService.enemys[way];

            TravelService.lockWay[way] = false;

            mob.heroes.Remove(name);

            way = -1;

            ghost = true;

            fight = false;

            await chanel.SendMessageAsync(msg);

            await TravelService.CheckEnemys();

            return;
        }
Exemple #20
0
        //получаем урон
        public async Task GetDamage(float damage)
        {
            var chanel = KingdomRun.client.GetChannel(ulong.Parse(lastRoom)) as IMessageChannel;

            Random rand = new Random();

            damage = rand.Next((int)damage - 15, (int)damage + 15);

            damage = damage - (m_Defence * 0.85f);

            if (damage < 0)
            {
                damage = 1;
            }

            p_Hp = (int)(p_Hp - damage);
            //Если нет здоровья
            if (p_Hp < 0)
            {
                var mob = TravelService.enemys[way];
                TravelService.lockWay[way] = false;

                mob.heroes.Remove(name);

                way = -1;

                ghost = true;

                fight = false;

                await Loging.Log("Ты проиграл битву и теперь ты дух. Тебе доступен только потусторонний мир!", chanel);

                await TravelService.CheckEnemys();

                return;
            }

            await Loging.Log(name + " получил " + damage + " урона. Осталось " + p_Hp + " здоровья !", chanel);
        }
Exemple #21
0
        public ActionResult Travelling()
        {
            var userId = User.Identity.GetUserId();

            var travelService = new TravelService();

            travelService.CheckArrivalTime(userId);

            if (db.CurrentLands.Any(cl => cl.UserId == userId))
            {
                return(RedirectToAction("Index", "Land"));
            }

            if (!db.Travels.Any(t => t.UserId == userId))
            {
                return(RedirectToAction("Index"));
            }


            var travel = db.Travels.First(t => t.UserId == userId);

            return(View(travel));
        }
Exemple #22
0
        public async Task Construct_TestRoute_1()
        {
            //Arragen
            var travelService            = new TravelService(_osmRouter);
            var routeConstructionService = new RouteConstructionService(travelService, _mappingService, _tourRepositoryMock.Object);
            var controller = new RouteController(routeConstructionService, _arrivalTimeServiceMock.Object);

            //Act
            var response = await controller.CreateRoute(JsonConvert.DeserializeObject <RouteReqDto>(RequestBodies.TestRoute1));


            //Assert
            var actionResult          = Assert.IsType <ActionResult <RouteRespDto> >(response);
            var createdAtActionResult = Assert.IsType <CreatedAtActionResult>(actionResult.Result);
            var returnValue           = Assert.IsType <RouteRespDto>(createdAtActionResult.Value);

            returnValue.Waypoints[0].Latitude.Should().BeApproximately(46.94753, 0.00001);
            returnValue.Waypoints[1].Latitude.Should().BeApproximately(46.92716, 0.00001);
            returnValue.Waypoints[2].Latitude.Should().BeApproximately(46.92040, 0.00001);
            returnValue.Waypoints[3].Latitude.Should().BeApproximately(46.90992, 0.00001);
            returnValue.Waypoints[4].Latitude.Should().BeApproximately(46.95574, 0.00001);
            returnValue.Waypoints[5].Latitude.Should().BeApproximately(46.94753, 0.00001);
        }
        void RunServices()
        {
            var db = new ApplicationDbContext();

            var userId = User.Identity.GetUserId();
            var user   = db.Users.Find(userId);

            if ((DateTimeOffset.Now - user.LastRainbowGemTime).TotalHours >= 24)
            {
                user.RainbowGems++;
                user.LastRainbowGemTime = DateTimeOffset.Now;
            }

            user.LastActive = DateTimeOffset.Now;
            db.SaveChanges();

            if (db.Travels.Any(t => t.UserId == userId))
            {
                var travelService = new TravelService();
                travelService.CheckArrivalTime(userId);
            }

            if (user.Stamina < user.MaxStamina)
            {
                var staminaService = new StaminaService();
                staminaService.UpdateStamina(userId);
            }

            var battleService = new BattleService();

            battleService.RunBattles();

            var auctionService = new AuctionService();

            auctionService.CheckAuctions();
        }
Exemple #24
0
 public TravelController(DesafioContext context)
 {
     travelService = new TravelService(context);
 }
Exemple #25
0
 public Task Login() => TravelService.Travel(Context);
Exemple #26
0
 public Task Attack() => TravelService.AttackEnemy(Context);
Exemple #27
0
 public RickUnitTest() : base()
 {
     rickService   = new RickService(this.context);
     travelService = new TravelService(this.context);
 }
 public TarvelUnitTest() : base()
 {
     travelService = new TravelService(this.context);
     rickService   = new RickService(this.context);
 }
Exemple #29
0
 public TourController(TourService tourService, YourTourContext db, TravelService travelService)
 {
     this._tourService   = tourService;
     this._travelService = travelService;
     this._db            = db;
 }