public BattleshipsGameBoard(IGameResources resx, IGameOptions opt, IGameRepository repo)
 {
     GameResources  = resx;
     GameOptions    = opt;
     GameRepository = repo;
     InputValidator = new InputValidator(resx, repo, opt);
 }
Exemplo n.º 2
0
        public static ICodemaker CreateCodemaker(IGameOptions options, ICodemaker lastCodemaker)
        {
            var type = ShellEx.PromptPlayerType("Codemaker", lastCodemaker?.Type);

            ShellEx.WriteKeyValue("Codemaker", type.ToString().ToLower());

            switch (type)
            {
            case PlayerType.Human:
                return(new HumanCodemaker(options));

            case PlayerType.Computer:
                PegPattern code;
                var        codeType = Shell.PromptEnum <ComputerCodeType>("Choose secret code", ComputerCodeType.Random);
                switch (codeType)
                {
                case ComputerCodeType.Random:
                    code = options.Palette.GetRandomPattern(options);
                    break;

                case ComputerCodeType.Custom:
                    code = ShellEx.PromptPegPattern("Enter secret code", options);
                    break;

                default:
                    throw new Exception($"Unknown code type");
                }
                ShellEx.WriteKeyValue("Code", codeType.ToString().ToLower());
                return(new ComputerCodemaker(options, code));

            default: throw new Exception($"Unknown player type: {type}");
            }
        }
Exemplo n.º 3
0
        public void Load(IUserProfileModel userProfileModel)
        {
            IUserInventory inventory   = LoadInventory();
            IUserStats     userStats   = LoadUserStats();
            IGameOptions   gameOptions = LoadGameOptions();

            userProfileModel.UserProfile = new UserProfile(inventory, userStats, gameOptions);
        }
Exemplo n.º 4
0
 public Game(ICommander console, IServiceProvider gameServices, CommandMap allCommands, CommandMap globalCommands, ISet <Type> areas, IGameOptions gameOptions)
 {
     Commander       = console;
     GameOptions     = gameOptions;
     _gameServices   = gameServices;
     _allCommands    = allCommands;
     _globalCommands = globalCommands;
     _areas          = areas;
 }
Exemplo n.º 5
0
        /// <inheritdoc/>
        public async Task <int> Start(IEnumerable <IPlayer> players, IGameOptions options = null)
        {
            if (options == null)
            {
                gameOptions = GameOptions.Default;
            }

            var pack = await gamePackLoader.Load();

            Pack = await ShuffleCards(pack);

            GameArea    = options.GameArea;
            GameSquares = await gameMapLoader.Load();

            return(CurrentGameId++);
        }
Exemplo n.º 6
0
        public IGame Build(IGameOptions gameOptions = null)
        {
            LoadAreas();
            LoadCommands();
            _startup.ConfigureCommands(this);

            _serviceCollection.AddSingleton <IGame, Game>(services => new Game(services.GetService <ICommander>(), GameServices, _commands, _globalCommands, _areas, gameOptions ?? new GameOptions()));

            GameServices = _serviceCollection.BuildServiceProvider();

            var game = GameServices.GetService <IGame>();

            _startup.ConfigureGame(game);
            GameServices.GetRequiredService <ICommander>().OnGameCreated(game);

            return(game);
        }
Exemplo n.º 7
0
 public GameManager(
     IGameOptions gameOptions,
     IDebug debug,
     IItemManager itemManager,
     IEntityManager entityManager,
     IHud hud,
     IPlayer player,
     IInventory inventory,
     IActiveGear activeGear
     )
 {
     // components
     _debug         = debug ?? throw new ArgumentNullException(ComponentStrings.Debug);
     _gameOptions   = gameOptions ?? throw new ArgumentNullException(ComponentStrings.GameOptions);
     _hud           = hud ?? throw new ArgumentNullException(ComponentStrings.HUD);
     _inventory     = inventory ?? throw new ArgumentNullException(ComponentStrings.Inventory);
     _itemManager   = itemManager ?? throw new ArgumentNullException(ComponentStrings.ItemManager);
     _entityManager = entityManager ?? throw new ArgumentNullException(ComponentStrings.EntityManager);
     _player        = player ?? throw new ArgumentNullException(ComponentStrings.Player);
     _activeGear    = activeGear ?? throw new ArgumentNullException(ComponentStrings.ActiveGear);
 }
Exemplo n.º 8
0
        public static ICodebreaker CreateCodebreaker(IGameOptions options, ICodebreaker lastCodebreaker)
        {
            var type = ShellEx.PromptPlayerType("Codebreaker", lastCodebreaker?.Type);

            ShellEx.WriteKeyValue("Codebreaker", type.ToString().ToLower());

            switch (type)
            {
            case PlayerType.Human:
                return(new HumanCodebreaker(options));

            case PlayerType.Computer:
                PegPattern initialGuess;
                var        initialGuessType = Shell.PromptEnum <ComputerInitialGuessType>("Choose initial guess", ComputerInitialGuessType.Default);
                switch (initialGuessType)
                {
                case ComputerInitialGuessType.Default:
                    initialGuess = null;
                    break;

                case ComputerInitialGuessType.Random:
                    initialGuess = options.Palette.GetRandomPattern(options);
                    break;

                case ComputerInitialGuessType.Custom:
                    initialGuess = ShellEx.PromptPegPattern("Enter initial guess", options);
                    break;

                default:
                    throw new Exception($"Unknown initial guess type");
                }
                ShellEx.WriteKeyValue("Initial guess", initialGuessType.ToString().ToLower());
                return(new ComputerCodebreaker(options, initialGuess));

            default: throw new Exception($"Unknown player type: {type}");
            }
        }
Exemplo n.º 9
0
 private void SaveGameOptions(IGameOptions gameOptions)
 {
     CustomPlayerPrefs.SetBool(StringConstants.PlayerPrefsKeys.IsSoundOn, gameOptions.IsSoundOn);
     CustomPlayerPrefs.SetBool(StringConstants.PlayerPrefsKeys.IsMusicOn, gameOptions.IsMusicOn);
 }
Exemplo n.º 10
0
 protected Codebreaker(IGameOptions options) : base(options)
 {
 }
Exemplo n.º 11
0
 public HumanCodemaker(IGameOptions options) : base(options)
 {
 }
Exemplo n.º 12
0
 public InputValidator(IGameResources resx, IGameRepository repo, IGameOptions opt)
 {
     GameResources  = resx;
     GameRepository = repo;
     GameOptions    = opt;
 }
Exemplo n.º 13
0
 public GameController(IGameOptions gameOptions)
 {
     _gameOptions = gameOptions;
 }
Exemplo n.º 14
0
 protected Player(IGameOptions options)
 {
     Options = options;
 }
Exemplo n.º 15
0
 public Game2048(IGameEngine engine, IGameOptions options, IStatefullBoard board)
 {
     m_engine  = engine;
     m_options = options;
     m_board   = board;
 }
Exemplo n.º 16
0
 public ComputerCodemaker(IGameOptions options, PegPattern code) : base(options)
 {
     _code = code ?? throw new ArgumentNullException(nameof(code));
 }
Exemplo n.º 17
0
 public Game2048(IGameEngine engine, IGameOptions options, IStatefullBoard board)
 {
     m_engine = engine;
     m_options = options;
     m_board = board;
 }
Exemplo n.º 18
0
 public ComputerCodemaker(IGameOptions options) : base(options)
 {
     _code = Options.Palette.GetRandomPattern(Options);
 }
Exemplo n.º 19
0
 public ComputerCodebreaker(IGameOptions options, PegPattern initialGuess = null) : base(options)
 {
     _initialGuess = initialGuess;
 }
Exemplo n.º 20
0
 public UserProfile(IUserInventory inventory, IUserStats userStats, IGameOptions gameOptions)
 {
     UserInventory = inventory;
     UserStats     = userStats;
     GameOptions   = gameOptions;
 }