wemih
wemih
CC#
Created by wemih on 5/14/2024 in #help
I NEED HELP WITH MY CODE
I'm making this board game called Onitama and in my TableManager code im having a problem on the StartGameForTable code. using Onitama.Core.GameAggregate.Contracts; using Onitama.Core.PlayerAggregate.Contracts; using Onitama.Core.TableAggregate.Contracts; using Onitama.Core.UserAggregate; namespace Onitama.Core.TableAggregate; /// <inheritdoc cref="ITableManager"/> internal class TableManager : ITableManager { private readonly ITableRepository tableRepository; private readonly ITableFactory tableFactory; private readonly IGameRepository gameRepository; private readonly IGameFactory gameFactory; private readonly IGamePlayStrategy gamePlayStrategy; public TableManager( ITableRepository tableRepository, ITableFactory tableFactory, IGameRepository gameRepository, IGameFactory gameFactory, IGamePlayStrategy gamePlayStrategy) { this.tableRepository = tableRepository; this.tableFactory = tableFactory; this.gameRepository = gameRepository; this.gameFactory = gameFactory; this.gamePlayStrategy = gamePlayStrategy; } public ITable AddNewTableForUser(User user, TablePreferences preferences) { ITable table = tableFactory.CreateNewForUser(user, preferences); tableRepository.Add(table); return table; } public void JoinTable(Guid tableId, User user) { ITable table = tableRepository.Get(tableId); table.Join(user); } public void LeaveTable(Guid tableId, User user) { ITable table = tableRepository.Get(tableId); table.Leave(user.Id); if (0 == table.SeatedPlayers.Count) { tableRepository.Remove(table.Id); } } public void FillWithArtificialPlayers(Guid tableId, User user) { tableRepository.Get(tableId).FillWithArtificialPlayers(gamePlayStrategy); } public IGame StartGameForTable(Guid tableId, User user) { ITable table = tableRepository.Get(tableId); TableFactory tableFactory = new TableFactory(); ITable _table = tableFactory.CreateNewForUser(user, table.Preferences); IGame game = gameFactory.CreateNewForTable(_table); gameRepository.Add(game); return game; } }
4 replies