internal static void Main() { Item sallingerBook = new Book("4adwlj4", "Catcher in the Rye", 20.00m, "J. D. Salinger", "fiction"); Item threeManBook = new Book("84djesd", "Three Men in a Boat", 39.99m, "Jerome K. Jerome", new List<string> { "comedy" }); Item acGame = new Game("9gkjdsa", "AC Revelations", 78.00m, "historical", AgeRestriction.Teen); Item bubbleSplashGame = new Game("r8743jf", "Bubble Splash", 7.80m, new List<string> { "child", "fun" }); Item godfatherMovie = new Video("483252j", "The Godfather", 99.00m, 178, "crime"); Item dieHardMovie = new Video("9853kfds", "Die Hard 4", 9.90m, 144, new List<string> { "action", "crime", "thriller" }); DateTime today = DateTime.Now; DateTime fiveYearsAgo = today.AddYears(-5); Sale dieHardSale = new Sale(dieHardMovie, fiveYearsAgo); Console.WriteLine(dieHardSale.SaleDate); // 1/30/2015 2:31:55 PM (today) Sale acSale = new Sale(acGame); Console.WriteLine(acSale.SaleDate); // 1/30/2010 2:31:55 PM DateTime afterOneWeek = today.AddDays(30); Rent bookRent = new Rent(sallingerBook, today, afterOneWeek); Console.WriteLine(bookRent.RentState); // Pending DateTime lastMonth = today.AddDays(-34); DateTime lastWeek = today.AddDays(-8); Rent movieRent = new Rent(godfatherMovie, lastMonth, lastWeek); Console.WriteLine(movieRent.RentState); // Overdue movieRent.ReturnItem(); Console.WriteLine(movieRent.RentState); // Returned Console.WriteLine(movieRent.ReturnDate); // 1/30/2015 2:41:53 PM Console.WriteLine(movieRent.RentFine); // 7.9200 }
private IEnumerable<IGame> GenerateFakeCollectionOfGames() { var games = new List<Game>(); var fakeGame = new Game(new GameField(5, 5)); fakeGame.Id = "FakeId"; games.Add(fakeGame); games.Add(new Game(new GameField(10, 10))); games.Add(new Game(new GameField(15, 15))); return games; }
/// <summary> /// Starts the game. /// </summary> /// <param name="game">The game.</param> /// <param name="stateViewModel">The state view model.</param> public void StartGame(Game game, GameStateViewModel stateViewModel) { Application.Current.MainWindow.Closing += this.OnWindowClosing; this.PrepareNewGame(); this.CurrentGame = game; this.CurrentGame.CurrentGameState = Game.GameState.Running; this.gameStateViewModel = stateViewModel; this.gameStateViewModel.StartGame(); switch (this.CurrentGame.GameType) { case GameConfiguration.GameType.SinglePlayerTraining: this.gameController = new SinglePlayerTrainingGameController(); break; case GameConfiguration.GameType.MultiPlayerGame: this.gameController = new MultiplayerGameController(); break; default: this.gameController = new SinglePlayerGameController(); break; } this.gameController.BallPlacedOnGameField += this.PlaceBallOnGameField; this.gameController.RoundStarted += this.StartRound; this.gameController.RoundEnded += this.RoundEnded; this.gameController.GameCanceled += this.CancelGame; this.gameController.ErrorOccurred += this.ErrorOccurred; this.gameController.StartGame(); this.OpenGameField(); if (this.CurrentGame.LocalPlayer.HasFirstTurn) { this.PlaceBallOnGameField(); } }
public void Update(Game game) { this.games.Update(game); this.games.SaveChanges(); }
public void Add(Game game) { this.games.Add(game); this.games.SaveChanges(); }
public IHttpActionResult Post(PostRequestCreateGame model) { if (!ModelState.IsValid) { return BadRequest("Invalid post parameters!"); } ValidateNumber(model.Number); var userId = this.User.Identity.GetUserId(); var game = new Game { Name = model.Name, RedNumber = model.Number, DateCreated = DateTime.Now, RedId = userId, GameState = GameState.WaitingForOpponent, }; this.data.Games.Add(game); this.data.SaveChanges(); var responseModel = this.data.Games.All().Where(g => g.ID == game.ID) .Select(GameDataModel.FromGame); return Ok(responseModel); }
private char[,] ShootAt1x1(char[,] manualFieldBefor) { var gameFieldXLen = manualFieldBefor.GetLength(0); var gameFieldYLen = manualFieldBefor.GetLength(1); GameField gameField = new GameField(gameFieldXLen, gameFieldYLen); // fill the field with the manual chars for (int i = 0; i < gameFieldXLen; i++) { for (int j = 0; j < gameFieldYLen; j++) { gameField[i, j] = manualFieldBefor[i, j]; } } // Create game with custom field Game game = new Game(gameField); var logicProvider = new GameLogicProvider(game); // shoot 1x1 Coordinates positionToShoot = new Coordinates(1, 1); logicProvider.ShootBalloonAtPosition(positionToShoot); return gameField.GetField(); }