コード例 #1
0
        public void Then_Returns_Silver_Achievement()
        {
            var result = Achievement.ClassUnderTest.IsAwardedForThisPlayer(PlayerId);

            Assert.IsNotNull(result);
            Assert.IsTrue(result.LevelAwarded.HasValue);

            Assert.That(result.LevelAwarded.Value, Is.EqualTo(AchievementLevel.Silver));
            foreach (var game in PlayedGames.Where(c => c.PlayerId == PlayerId))
            {
                Assert.IsTrue(result.RelatedEntities.Contains(game.PlayedGame.GameDefinitionId));
            }
        }
コード例 #2
0
 private void Start()
 {
     if (AverageTime != null)
     {
         AverageTime.Invoke();
     }
     if (PlayedGames != null)
     {
         PlayedGames.Invoke();
     }
     if (AverageScore != null)
     {
         AverageScore.Invoke();
     }
 }
コード例 #3
0
        public PlayedGames GetPlayedGames(string id, string centerid, string gamedate, string otheruserid)
        {
            logger.Debug(Settings.MethodName());

            PlayedGames playedGames = new PlayedGames();

            if (isCorrectUser(id))
            {
                // voor het opvragen van games van een andere gebruiker, gebruiken we het andere id
                if (!String.IsNullOrEmpty(otheruserid))
                {
                    id = otheruserid;
                }

                long userid;
                long bowlingcenterid;

                int year;
                int month;
                int day;

                try
                {
                    long.TryParse(centerid, out bowlingcenterid);
                    long.TryParse(id, out userid);
                    int.TryParse(gamedate.Substring(0, 4), out year);
                    int.TryParse(gamedate.Substring(4, 2), out month);
                    int.TryParse(gamedate.Substring(6, 2), out day);
                    DateTime gameDate = new DateTime(year, month, day);

                    S_User          user          = UserManager.GetUserById(userid);
                    S_BowlingCenter bowlingcenter = BowlingCenterManager.GetBowlingCenterById(bowlingcenterid);

                    if (user != null && bowlingcenter != null)
                    {
                        playedGames = GameManager.GetPlayedGamesByUserAndBowlingcenterAndDate(user, bowlingcenter, gameDate);
                    }
                }
                catch
                {
                }
            }

            return(playedGames);
        }
コード例 #4
0
 public IActionResult AddGame(String gameName, String publisher, String genre, String rating, String platforms, string year)
 {
     try
     {
         DateTime Date = new DateTime(int.Parse(year), 1, 1);
         using (WgsipContext db = new WgsipContext())
         {
             Game  newGame  = new Game();
             Genre newGenre = db.Genres.First(g => g.GenreName.ToLower().Equals(genre.ToLower()));
             newGame.EsrbRating = rating;
             Publisher newPublisher;
             try
             {
                 newPublisher = db.Publishers.First(p => p.PublisherName.ToLower().Equals(publisher.ToLower()));
             }
             catch (Exception)
             {
                 newPublisher = new Publisher();
                 newPublisher.PublisherName = publisher;
                 db.Publishers.Add(newPublisher);
             }
             newGame.Genre         = newGenre;
             newGame.Publisher     = newPublisher;
             newGame.GameName      = gameName;
             newGame.Platforms     = platforms;
             newGame.DatePublished = Date;
             db.Games.Add(newGame);
             PlayedGames playedGame = new PlayedGames();
             playedGame.Game       = newGame;
             playedGame.PlayedGame = false;
             playedGame.User       = db.Accounts.First(a => a.AccountEmail.ToLower().Equals(User.Identity.Name.ToLower()));
             db.PlayedGames.Add(playedGame);
             db.SaveChanges();
         }
         return(Json(new { message = "successfully added game to the Games database" }));
     }
     catch (Exception e)
     {
         return(Json(new { message = e.Message }));
     }
 }
コード例 #5
0
 public IActionResult AddGameToPlayed(String gameName)
 {
     try
     {
         using (WgsipContext db = new WgsipContext())
         {
             Game        newGame    = db.Games.Include(g => g.Publisher).Include(g => g.Genre).First(g => g.GameName.ToLower().Equals(gameName.ToLower()));
             PlayedGames playedGame = new PlayedGames();
             playedGame.Game       = newGame;
             playedGame.PlayedGame = false;
             playedGame.User       = db.Accounts.First(a => a.AccountEmail.ToLower().Equals(User.Identity.Name.ToLower()));
             db.PlayedGames.Add(playedGame);
             db.SaveChanges();
         }
         return(Json(new { message = "successfully added game to played games list" }));
     }
     catch (Exception e)
     {
         return(Json(new { message = e.Message }));
     }
 }
コード例 #6
0
        public IActionResult SoundsGood(String game)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(Json(new { message = "You need to be logged in to add a game to your game list." }));
            }

            try
            {
                using (WgsipContext db = new WgsipContext())
                {
                    Account     user       = db.Accounts.First(a => a.AccountEmail == User.Identity.Name);
                    Game        gameEntry  = db.Games.First(g => g.GameName.ToLower().Equals(game.ToLower()));
                    PlayedGames playedGame = new PlayedGames();
                    playedGame.User       = user;
                    playedGame.Game       = gameEntry;
                    playedGame.PlayedGame = false;
                    if (!db.PlayedGames.Include(pg => pg.Game)
                        .Include(pg => pg.User)
                        .Any(pg => pg.Game == gameEntry &&
                             pg.User == user))
                    {
                        db.PlayedGames.Add(playedGame);
                        db.SaveChanges();
                        return(Json(new { message = "Game added to your games list! 😆" }));
                    }
                    else
                    {
                        return(Json(new { message = "The game is already in your games list." }));
                    }
                }
            }
            catch (Exception e)
            {
                return(Json(new { message = e.Message }));
            }
        }