Exemple #1
0
        public static IServiceCollection AddArmyInterface(this IServiceCollection services)
        {
            var armyInterface = SingletonFactory <ArmyInterface> .Create(provider => {
                return(new ArmyInterface(
                           provider.GetService <CountryController>(),
                           provider.GetService <PopulationController>(),
                           provider.GetService <ArmyController>(),
                           provider.GetService <InputController>(),
                           provider.GetService <OutputController>(),
                           provider.GetService <ContextController>()
                           ));
            });

            return(services
                   .AddSingleton <IStartHandler, ArmyInterface>(armyInterface)
                   .AddSingleton <IContext <ArmyController>, ArmyInterface>(armyInterface));
        }
Exemple #2
0
        public static IServiceCollection AddGameLogics(this IServiceCollection services)
        {
            var gameLogics = SingletonFactory <GameLogics> .Create(provider => {
                return(new GameLogics(
                           provider.GetService <InputController>(),
                           provider.GetService <OutputController>(),
                           provider.GetService <ContextController>(),
                           provider.GetService <CountryController>(),
                           provider.GetService <TimeController>()
                           ));
            });

            return(services
                   .AddSingleton(gameLogics)
                   .AddSingleton <IDayStarter, GameLogics>(gameLogics)
                   .AddSingleton <ICountryHandler, GameLogics>(gameLogics));
        }
Exemple #3
0
        public static IServiceCollection AddGameController(this IServiceCollection services)
        {
            var controller = SingletonFactory <IGameController> .Create(provider => {
                if (provider.GetService <GameSettings>().WithPlayer)
                {
                    return(new PlayerController(
                               provider.GetService <ContextController>(),
                               provider.GetService <InputController>(),
                               provider.GetService <OutputController>()));
                }
                else
                {
                    return(new AutoController());
                }
            });

            return(services.AddSingleton(controller));
        }
Exemple #4
0
        public static IServiceCollection AddConquestInterface(this IServiceCollection services)
        {
            var conquestInterface = SingletonFactory <ConquestInterface> .Create(provider => {
                return(new ConquestInterface(
                           provider.GetService <ContextController>(),
                           provider.GetService <InputController>(),
                           provider.GetService <OutputController>(),
                           provider.GetService <CountryController>(),
                           provider.GetService <MapController>(),
                           provider.GetService <DiscoveryController>(),
                           provider.GetService <ArmyController>(),
                           provider.GetService <ConquestController>()
                           ));
            });

            return(services
                   .AddSingleton <IContext <ConquestController>, ConquestInterface>()
                   .AddSingleton <IConquestHandler, ConquestInterface>(conquestInterface));
        }