Example #1
0
        public ItemTemplateTest()
        {
            var serviceProvider = new ServiceCollection()
                                  .AddEntityFrameworkInMemoryDatabase()
                                  .BuildServiceProvider();

            var options = new DbContextOptionsBuilder <DataContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .UseInternalServiceProvider(serviceProvider)
                          .Options;

            _dbContext = new DataContext(options);
            _dbContext.Database.EnsureCreated();
            Seed(_dbContext);

            _repo = new ItemTemplateRepository(_dbContext);
            MapperConfiguration config = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <ItemTemplate, ItemTemplateForGetDto>();
                cfg.CreateMap <ItemTemplate, ItemTemplateForAddDto>();
                cfg.CreateMap <ItemTemplate, ItemTemplateForTableDto>();
            });

            _mapper = config.CreateMapper();
        }
 public ItemTemplateController(IItemTemplateRepository repo, DataContext context,
                               IMapper mapper, UserManager <User> userManager, IEventLogRepository eventLogRepo)
 {
     _context      = context;
     _mapper       = mapper;
     _repo         = repo;
     _userManager  = userManager;
     _eventLogRepo = eventLogRepo;
 }
Example #3
0
        public LevelEnemyUnitSetupProcessor(AgentFactory agentFactory, IItemTemplateRepository itemTemplateRepository, IRandomizer randomizer, IUnitIdPool unitIdPool, UnitBuilder unitBuilder, IAbilityRepository abilityRepository, ISpellRepository spellRepository, ICardEffectsRepository cardEffectsRepository)
        {
            AgentFactory           = agentFactory;
            ItemTemplateRepository = itemTemplateRepository;
            Randomizer             = randomizer;
            UnitIdPool             = unitIdPool;
            UnitBuilder            = unitBuilder;
            AbilityRepository      = abilityRepository;
            SpellRepository        = spellRepository;
            CardEffectsRepository  = cardEffectsRepository;

            GlobalLootTable = GenerateLootTable();
        }
Example #4
0
 public QuestManagement(IConfigRepository configRepository, IRefreshingMechnism refreshingMechnism,
                        IValueRandomizer randomizer, IFormationTemplateRepository formationTemplateRepository,
                        IAccountManagement accountManagement, IQuestRepository questRepository,
                        IRewardTemplatesRepository rewardTemplatesRepository, IInventoryManagement inventoryManagement,
                        IItemTemplateRepository itemTemplateRepository, IFightManagement fightManagement)
 {
     _configRepository            = configRepository;
     _refreshingMechnism          = refreshingMechnism;
     _randomizer                  = randomizer;
     _formationTemplateRepository = formationTemplateRepository;
     _accountManagement           = accountManagement;
     _questRepository             = questRepository;
     _rewardTemplatesRepository   = rewardTemplatesRepository;
     _inventoryManagement         = inventoryManagement;
     _itemTemplateRepository      = itemTemplateRepository;
     _fightManagement             = fightManagement;
 }
Example #5
0
        private void mainScreen_Load(object sender, EventArgs e)
        {
            _accountRepository = new AccountJsonFileRepository(@"C:\Emil\Projects\HeroGameDataFiles\Accounts.json");
            var accounts = _accountRepository.GetAll();

            if (accounts.Count == 0)
            {
                _accountRepository.Add(new Account("testAccount", "testPassword"));
                _accountRepository.Add(new Account("testAccount1", "testPassword"));
                _accountRepository.Add(new Account("testAccount2", "testPassword"));
            }
            _accountManagement = new AccountManagement(_accountRepository);

            _configRepository = new ConfigJsonFileRepository(@"C:\Emil\Projects\HeroGameDataFiles\Configuration.json");
            EnsureConfigValue("Delay_for_option_Mercenaries_in_sec", "20");
            EnsureConfigValue("Delay_for_option_Quests_in_sec", "20");
            EnsureConfigValue("NumberOfRecruits", "10");
            EnsureConfigValue("ChanceForLevel_1_mercenary", "10000_10000");
            EnsureConfigValue("ChanceForLevel_2_mercenary", "2500_10000");
            EnsureConfigValue("ChanceForLevel_3_mercenary", "500_10000");
            EnsureConfigValue("ChanceForLevel_4_mercenary", "50_10000");

            EnsureConfigValue("ConvinceLevel_1_recruit", "7500_10000");
            EnsureConfigValue("ConvinceLevel_2_recruit", "5000_10000");
            EnsureConfigValue("ConvinceLevel_3_recruit", "2000_10000");
            EnsureConfigValue("ConvinceLevel_4_recruit", "1000_10000");
            EnsureConfigValue("NumberOfQuests", "5");

            EnsureConfigValue("ChanceForLevel_1_quest", "7500_10000");
            EnsureConfigValue("ChanceForLevel_2_quest", "5000_10000");
            EnsureConfigValue("ChanceForLevel_3_quest", "2000_10000");
            EnsureConfigValue("ChanceForLevel_4_quest", "1000_10000");

            _packFormationRepository = new PackFormationJsonFileRepository(@"C:\Emil\Projects\HeroGameDataFiles\");
            _packFormationBuilder    = new PackFormationBuilder(_packFormationRepository, _accountManagement);


            _refreshRepository           = new RefreshJsonFileRepository(@"C:\Emil\Projects\HeroGameDataFiles\");
            _recruitsRepository          = new RecruitsJsonRepository(@"C:\Emil\Projects\HeroGameDataFiles\");
            _refreshingMechnism          = new RefreshingMechnism(_refreshRepository, _configRepository, _accountManagement);
            _mercenaryTemplateRepository = new MercenaryTemplateJsonFileRepository(@"C:\Emil\Projects\HeroGameDataFiles\MercenaryTemplates.json");
            _mercenaryRepository         = new MercenaryJsonFileRepository(@"C:\Emil\Projects\HeroGameDataFiles\");
            if (_mercenaryTemplateRepository.GetAll().Count == 0)
            {
                foreach (var template in MercenaryTemplatesCollectionGenerator.Generate())
                {
                    _mercenaryTemplateRepository.Add(template);
                }
            }


            _positionInInventoryRepository = new PositionInInventoryJsonFileRepository(@"C:\Emil\Projects\HeroGameDataFiles\");
            _itemTemplateRepository        = new ItemTemplateJsonFileRepository(@"C:\Emil\Projects\HeroGameDataFiles\ItemTemplates.json");
            _inventoryManagement           = new InventoryManagement(_itemTemplateRepository, _positionInInventoryRepository, _accountManagement);
            if (_itemTemplateRepository.GetAll().Count == 0)
            {
                foreach (var template in ItemTemplatesCollectionGenerator.Generate())
                {
                    _itemTemplateRepository.Add(template);
                }
            }
            _mercenaryManagement          = new MercenaryManagement(_mercenaryRepository, _accountManagement, _mercenaryTemplateRepository, new ValueRandomizer(), _configRepository, _recruitsRepository, _inventoryManagement, _refreshingMechnism);
            _formationTemplateRepository  = new FormationTemplateJsonFileRepository(@"C:\Emil\Projects\HeroGameDataFiles\FormationTemplates.json");
            _opponentPackFormationBuilder = new OpponentPackFormationBuilder(_formationTemplateRepository, _mercenaryManagement);
            if (_formationTemplateRepository.GetAll().Count == 0)
            {
                foreach (var template in FormationTemplatesCollectionGenerator.Generate())
                {
                    _formationTemplateRepository.Add(template);
                }
            }
            _valueRandomizer           = new ValueRandomizer();
            _logger                    = new FakeLogger();
            _questsRepository          = new QuestsJasonFileRepository(@"C:\Emil\Projects\HeroGameDataFiles\");
            _rewardTemplatesRepository = new RewardTemplatesJsonFileRepository(@"C:\Emil\Projects\HeroGameDataFiles\RewardTemplates.json");
            if (_rewardTemplatesRepository.GetAll().Count == 0)
            {
                foreach (var template in RewardTemplatesCollectionGenerator.Generate())
                {
                    _rewardTemplatesRepository.Add(template);
                }
            }

            _fightMechanizm = new FightMechanizm(_valueRandomizer);

            _fightManagement = new FightManagement(_opponentPackFormationBuilder, _fightMechanizm, _packFormationBuilder, _mercenaryManagement);

            _questManagement = new QuestManagement(_configRepository, _refreshingMechnism, _valueRandomizer,
                                                   _formationTemplateRepository, _accountManagement, _questsRepository,
                                                   _rewardTemplatesRepository, _inventoryManagement, _itemTemplateRepository, _fightManagement);
            UpdateGameControls(_accountManagement.GetLoggedAccount());
        }
Example #6
0
 public InventoryManagement(IItemTemplateRepository itemTemplateRepository, IPositionInInventoryRepository positionInInventoryRepository, IAccountManagement accountManagement)
 {
     _itemTemplateRepository        = itemTemplateRepository;
     _positionInInventoryRepository = positionInInventoryRepository;
     _accountManagement             = accountManagement;
 }
Example #7
0
 public ItemDictionaryScreen(IItemTemplateRepository itemTemplateRepository)
 {
     InitializeComponent();
     _itemTemplateRepository = itemTemplateRepository;
 }
Example #8
0
 public ItemTemplateController(IItemTemplateRepository itemTemplateRepository)
 {
     _itemTemplateRepository = itemTemplateRepository as ItemTemplateRepository;
 }