public static List<MovePath> Convert(BoardGame.BoardPath path) { Debug.Assert(path.Count >= 2); var acc = new List<MovePath>(path.Count); if (path.Count == 2) { var from = new Vector3(path[0].x, 0f, path[0].y); var to = new Vector3(path[1].x, 0f, path[1].y); acc.Add(MovePath.CreateStraight(from, to)); } else { var pre2 = new Vector3(path[0].x, 0f, path[0].y); var pre1 = new Vector3(path[1].x, 0f, path[1].y); acc.Add(MovePath.CreateStraight(pre2, pre1)); for (int i = 2; i < path.Count; i++) { var pos = new Vector3(path[i].x, 0f, path[i].y); AddToAcc(acc, pos, pre1 - pre2); pre2 = pre1; pre1 = pos; } } return acc; }
public ActionResult Create([Bind(Include = "LocalBoardgameID,BoardgameID,Thumbnail,Image,Title,Description,PublicationYear,MinPlayers,MaxPlayers,PlayingTime,MaxPlayTime,MinPlayTime,MinAge")] BoardGame boardGame) { if (ModelState.IsValid) { db.BoardGames.Add(boardGame); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(boardGame)); }
public void Remove(BoardGame entity) { try { _data.Remove(entity); } catch (Exception ex) { throw new MockRepositoryException(ex); } }
public bool CreateGame(GameCreate model) { var entity = new Game(); if (model.GameType == Data.Games.GameType.BoardGame) { entity = new BoardGame() { //General Game properties UserId = _userId, GameTitle = model.GameTitle, GameDescription = model.GameDescription, AveragePlaytime = model.AveragePlaytime, MinGamePlayers = model.MinGamePlayers, MaxGamePlayers = model.MaxGamePlayers, GameType = model.GameType, //Board Game specific properties BoardGameGenre = model.BoardGameGenre, Category = model.Category, BGPublisher = model.BGPublisher, IsDiceGame = model.IsDiceGame, IsCardGame = model.IsCardGame }; } else { entity = new VideoGame() { //General Game properties UserId = _userId, GameTitle = model.GameTitle, GameDescription = model.GameDescription, AveragePlaytime = model.AveragePlaytime, MinGamePlayers = model.MinGamePlayers, MaxGamePlayers = model.MaxGamePlayers, GameType = model.GameType, //Video Game specific properties LocalCoop = model.LocalCoop, VideoGameGenre = model.VideoGameGenre, ESRBRating = model.ESRBRating, VGPublisher = model.VGPublisher, Console = model.Console }; } using (var ctx = new ApplicationDbContext()) { ctx.Games.Add(entity); return(ctx.SaveChanges() == 1); } }
public RobotDrawingActivity(RobotActionControl robotActionControl, GameHandler gameHandler, BoardGame boardGame, UpdateListBoxes updateListBoxes, Level level) { m_GameHandler = gameHandler; m_BoardGameForm = boardGame; m_RobotActionControl = robotActionControl; m_UpdateListBoxes = updateListBoxes; m_Level = level; player = gameHandler.player; robot1 = gameHandler.robot1; robot2 = gameHandler.robot2; robot3 = gameHandler.robot3; }
private void verifyPlaceASymbolToEmptySpaceThenSystemMustAcceptTheRequest(string[,] slots, string symbol, int row, int column, string expectedCurrentTurn) { var boardGame = new BoardGame { Slots = slots }; var canPlace = boardGame.Place(symbol, row, column); Assert.True(canPlace); Assert.Equal(expectedCurrentTurn, boardGame.CurrentTurn); Assert.Null(boardGame.GetWinner()); Assert.False(boardGame.IsDraw); }
public IActionResult Post([FromBody] BoardGame game) { //Determine the next ID var newID = _context.BoardGames.Select(x => x.ID).Max() + 1; game.ID = newID; _context.BoardGames.Add(game); _context.SaveChanges(); return(CreatedAtAction(nameof(Get), new { id = game.ID }, game)); }
public void Update(BoardGame entity) { try { Remove(Get(entity.Id)); Add(entity); } catch (Exception ex) { throw new MockRepositoryException(ex); } }
public void Handle_Should_ThrowBoardGameHasOpenRentalException_When_BoardGameWasNotFoundInDb() { BoardGame boardGame = null; _unitOfWork .Setup(x => x.BoardGameRepository.GetByIdAsync(_inputCommand.Id, _cancellationToken)) .ReturnsAsync(boardGame); Func <Task> act = async() => await _sut.Handle(_inputCommand, _cancellationToken); act.Should().Throw <BoardGameNotFoundException>(); }
public void GetCellsBetween_A1_Cell_And_D5_Cell_Should_Return_null() { BoardGame boardGame = new BoardGame(); boardGame.InitBoardGame(); var A1Coordinate = new BoardCoordinates(1, 1); var D5Coordinate = new BoardCoordinates(4, 5); var res = boardGame.GetCellsBetween(boardGame.Cells.At(A1Coordinate), boardGame.Cells.At(D5Coordinate)); Assert.Null(res); }
public IActionResult Post([FromBody] BoardGame value) { try { this._service.Add(value); return(this.Ok()); } catch (Exception) { return(StatusCode(500)); } }
public static string NotRecommendedPlayerCountTag(this BoardGame boardGame) { if (boardGame == null || boardGame.SuggestedPlayerNumbers == null) { return(" "); } return(SuggestedPlayerCountTag( boardGame.SuggestedPlayerNumbers .Where(n => n.StartsWith('-')) .Select(n => n.TrimStart('-')))); }
public async Task <IActionResult> PostBoardGame([FromBody] BoardGame boardGame) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.BoardGame.Add(boardGame); await _context.SaveChangesAsync(); return(CreatedAtAction("GetBoardGame", new { id = boardGame.Id }, boardGame)); }
public void Start_Game_With_Three_Players() { _playerThree = CreateUser(); _sut = _boardGameFactory.ToThreePlayer(_playerOne, _playerTwo, _playerThree); _sut.Start(); _sut.Players.NumberOfPlayers.Should().Be(3); _playerOne.BetCardsQuantity.Should().Be(2); _playerOne.MyRacingCards.Count().Should().Be(6); _playerTwo.MyRacingCards.Count().Should().Be(6); _playerThree.MyRacingCards.Count().Should().Be(6); }
public void DeleteBoardGame(BoardGame inBoardGame) { using (var session = sessionFactory.OpenSession()) { using (var transaction = session.BeginTransaction()) { session.Delete(inBoardGame); transaction.Commit(); } } NotifyObservers(); }
public void Update(BoardGame boardGame) { XElement node = boardGameData.Root.Elements("BoardGame").Where(i => (int)i.Element("Id") == boardGame.Id).FirstOrDefault(); node.SetElementValue("Name", boardGame.Name == null ?string.Empty : boardGame.Name); node.SetElementValue("Players", boardGame.Players); node.SetElementValue("Category", boardGame.Category); node.SetElementValue("Ages", boardGame.Ages); node.SetElementValue("Comments", boardGame.Comments); boardGameData.Save(HttpContext.Current.Server.MapPath(Constants.BOARD_GAME_REP_XML)); }
public ActionResult Create(BoardGame boardGame) { if (ModelState.IsValid) { _boardGameContext.AddBoardGame(boardGame); } else { ModelState.AddModelError("Create", "Something went wrong!"); } return(RedirectToAction("List", "BoardGame")); }
public BoardGame GetBoardGameById(int inBoardGameId) { using (var session = sessionFactory.OpenSession()) { BoardGame boardGame = session.QueryOver <BoardGame>().Where(x => x.BoardGameId == inBoardGameId).List <BoardGame>()[0]; if (boardGame == null) { throw new BoardGameDoesntExistsException(); } return(boardGame); } }
public GameHandler(Player Player, Robot Robot1, Robot Robot2, Robot Robot3, Level Levels) { player = Player; robot1 = Robot1; robot2 = Robot2; robot3 = Robot3; level = Levels; cards = new Cards(); m_BoardGameForm = new BoardGame(this, level); GetDatabaseData(); }
public async Task <IActionResult> Create([Bind("IdBoardGame,Nome,Fabricante,QuantidadeMinimaJogadores,QuantidadeMaximaJogadores,DuracaoMediaPartidaEmMinutos,IdJogador")] BoardGame boardGame) { if (ModelState.IsValid) { _context.Add(boardGame); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } //ViewData["IdJogador"] = new SelectList(_context.Jogadores, "IdJogador", "IdJogador", boardGame.IdJogador); return(View(boardGame)); }
public void Add(BoardGame entity) { try { entity.Id = entity.Id <= Decimal.Zero ? _data.Select(s => s.Id).Max() + 1 : entity.Id; _data.Add(entity); } catch (Exception ex) { throw new MockRepositoryException(ex); } }
public void GetCellsBetween_A1_Cell_And_A5_Cell_Should_Return_List_Of_5_Cells() { BoardGame boardGame = new BoardGame(); boardGame.InitBoardGame(); var A1Coordinate = new BoardCoordinates(1, 1); var A5Coordinate = new BoardCoordinates(1, 5); var res = boardGame.GetCellsBetween(boardGame.Cells.At(A1Coordinate), boardGame.Cells.At(A5Coordinate)); Assert.True(res.Count == 5); }
public IActionResult Add(BoardGame game) { //Determine the next ID var newID = context.BoardGames.Select(x => x.ID).Max() + 1; game.ID = newID; context.BoardGames.Add(game); context.SaveChanges(); return(RedirectToAction("Index")); }
public IHttpActionResult PostBoardGame(BoardGame boardGame) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _boardGame.InsertBoardGame(boardGame); _boardGame.Save(); return(CreatedAtRoute("DefaultApi", new { id = boardGame.Id }, boardGame)); }
public async Task <IActionResult> Index( int?boardGameId, List <int>?boardGameIdList, int?currentStock, bool?changeQuantityError = false) { var user = await _userManager.FindByEmailAsync(User.Identity.Name); string userId = user.Id.ToString(); IList <UserCart> UserCart = await _db.UserCart .Where(u => u.ApplicationUserId == userId) .Include(u => u.ApplicationUser) .Include(u => u.BoardGame) .ThenInclude(u => u.Brand) .ToListAsync(); IList <BoardGame> boardGames = new List <BoardGame>(); if (boardGameIdList.Count > 0) { foreach (var item in boardGameIdList) { BoardGame boardGame = await _db.BoardGames .Include(i => i.InventoryItems.Where(i => i.InStock == true)) .FirstOrDefaultAsync(i => i.ID == item); boardGames.Add(boardGame); } } string ErrorMessage = ""; int? ErrorBoardGameID = 0; if (changeQuantityError == true) { ErrorMessage = $"Only {currentStock} in stock"; ErrorBoardGameID = boardGameId; } UserCartViewModel UserCartViewModel = new UserCartViewModel() { UserCart = UserCart, ErrorMessage = ErrorMessage, ErrorBoardGameID = ErrorBoardGameID, BoardGames = boardGames }; return(View(UserCartViewModel)); }
public static void PrintBoardGame(BoardGame boardGame) { for (int i = 0; i < boardGame.Lines; i++) { Console.Write(8 - i + " "); for (int j = 0; j < boardGame.Columns; j++) { PrintPiece(boardGame.Piece(i, j)); } Console.WriteLine(); } Console.WriteLine(" a b c d e f g h"); }
public void AddBoardGame(BoardGame boardGame) { db.BoardGames.Add(boardGame); int i = db.SaveChanges(); if (i > 0) { cache.Set(boardGame.Id, boardGame, new MemoryCacheEntryOptions { AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(5) }); } }
public BoardGameShould() { _racingCardManager = new RacingCardManager(_racingCardsFactory, new RandomMixStrategy(), _racingCardOnDeskManager); _boardGameFactory = new BoardGameFactory(new PlayersManagerFactory(new RandomMixStrategy(), _racingCardManager), _racingCardOnDeskManager); _playerOne = CreateUser(); _playerTwo = CreateUser(); _sut = _boardGameFactory.ToTwoPlayer(_playerOne, _playerTwo); }
override public int predictWinner(int potentialCol, int potentialRow, int val) { int saved = tiles[BoardGame.GetIndex(potentialCol, potentialRow)]; int index = BoardGame.GetIndex(potentialCol, potentialRow); tiles[index] = val; int localWinner = checkWinner(); tiles[index] = saved; return(localWinner); }
public void CancelMove(Position origin, Position destiny, Piece capturedPiece) { Piece p = BoardGame.RemovePiece(destiny); p.DecreaseNumMoves(); if (capturedPiece != null) { BoardGame.PutPiece(capturedPiece, destiny); Captured.Remove(capturedPiece); } BoardGame.PutPiece(p, origin); }
private void InitializeData() { cache = BoardGameCache.Instance; // Fake board game with temp title boardGame = new BoardGame() { Name = " " }; expansions = new ObservableCollection <BoardGame>(Enumerable.Empty <BoardGame>()); expansionsVisible = Visibility.Visible; InitializeExploreOptions(); }
public TBGActionAttackMelee(int playerOwner, int unitIndex, BoardGame.BoardPath path, int damage, int targetUnitIndex, Basic.Vec2Int targetUnitPos, bool isTargetDead) : base(playerOwner, unitIndex) { _path = path; _damage = damage; _targetUnitIndex = targetUnitIndex; _targetUnitPos = targetUnitPos; _isTargetDead = isTargetDead; }
/// <summary> /// Constructor /// </summary> /// <param name="game">The BoardGame to be played</param> public GameControl(BoardGame game) { _game = game; _currentPlayer = Player.Player1; }
public TBGActionMove(int playerOwner, int unitIndex, BoardGame.BoardPath path) : base(playerOwner, unitIndex) { _path = path; }