private float DetermineMaximumPopulationIncrease(int buildingId) { var buildingMaximumPopulationIncreases = _gameConfigRepository.GetEntities("BuildingMaximumPopulationIncrease"); var filtered = buildingMaximumPopulationIncreases.Filter("BuildingId", buildingId); var amt = 0.0f; foreach (var item in filtered) { amt += (float)item.Value; } return(amt); }
public RaceConfig(int raceId) { _gameConfigRepository = CallContext <GameConfigRepository> .GetData("GameConfigRepository"); var races = _gameConfigRepository.GetEntities("Race"); _race = races.GetById(raceId); _raceTownNames = _gameConfigRepository.GetEntities("RaceTownName").Filter("RaceId", raceId); _unitRaces = _gameConfigRepository.GetEntities("UnitRace").Filter("RaceId", raceId); _raceBuildings = _gameConfigRepository.GetEntities("RaceBuilding").Filter("RaceId", raceId); TownNamesForThisRace = _gameConfigRepository.ToList(_raceTownNames, "TownName", "TownNameId", "Name"); UnitsThatCanBeBuiltByThisRace = _gameConfigRepository.ToList(_unitRaces, "Unit", "UnitId", "Name"); BuildingsThatCanBeBuiltByThisRace = _gameConfigRepository.ToList(_raceBuildings, "Building", "BuildingId", "Name"); }
private List <Texture> DeterminePossibleTexturesForThisTerrain() { var toList = _gameConfigRepository.GetEntities("Texture"); var list = new List <Texture>(); foreach (var item in _terrainTextures) { var fromAttributeValue = (int)item["TextureId"]; var toItem = toList.GetById(fromAttributeValue); var toAttribute1 = (string)toItem["TexturePalette"]; var toAttribute2 = (byte)toItem["TextureId"]; list.Add(new Texture(toAttribute1, toAttribute2)); } return(list); }
public TerrainConfig(int terrainId) { _gameConfigRepository = CallContext <GameConfigRepository> .GetData("GameConfigRepository"); var terrains = _gameConfigRepository.GetEntities("Terrain"); _terrain = terrains.GetById(terrainId); _terrainMovements = _gameConfigRepository.GetEntities("TerrainMovement").Filter("TerrainId", terrainId); _terrainTextures = _gameConfigRepository.GetEntities("TerrainTexture").Filter("TerrainId", terrainId); Movements = DetermineMovementsForThisTerrain(); PossibleTexturesForThisTerrain = DeterminePossibleTexturesForThisTerrain(); CanSettleOn = DetermineCanSettleOn(terrainId); FoodOutput = DetermineFoodOutput(terrainId); ProductionPercentage = DetermineProductionPercentage(terrainId); }
public ActionConfig(int actionId) { _gameConfigRepository = CallContext <GameConfigRepository> .GetData("GameConfigRepository"); var actions = _gameConfigRepository.GetEntities("Action"); _action = actions.GetById(actionId); }
public void Action_can_be_fetched() { var actions1 = _repo.GetEntities("Action"); var action1 = actions1.GetById(1); var action2 = actions1.GetByName("Patrol"); //var actions2 = _repo.GetActionsThatApplyToAll(); Assert.AreEqual("Done", action1.Name); Assert.AreEqual("Patrol", action2.Name); Assert.AreEqual(7, actions1.Count); //Assert.AreEqual(5, actions2.Count); foreach (var item in actions1) { Console.WriteLine($"Action name: {item.Name}"); } }
public MovementConfig(int movementId) { _gameConfigRepository = CallContext <GameConfigRepository> .GetData("GameConfigRepository"); var movements = _gameConfigRepository.GetEntities("Movement"); _movement = movements.GetById(movementId); IncrementSightBy = DetermineIncrementSightBy(movementId); }
public BuildingConfig(int buildingId) { _gameConfigRepository = CallContext <GameConfigRepository> .GetData("GameConfigRepository"); var buildings = _gameConfigRepository.GetEntities("Building"); _building = buildings.GetById(buildingId); _raceBuildings = _gameConfigRepository.GetEntities("RaceBuilding").Filter("BuildingId", buildingId); _unitBuildings = _gameConfigRepository.GetEntities("UnitBuilding").Filter("BuildingId", buildingId); _requiredBuildings = _gameConfigRepository.GetEntities("RequiredBuilding").Filter("BuildingId", buildingId); RacesThatCanBuildThisBuilding = _gameConfigRepository.ToList(_raceBuildings, "Race", "RaceId", "Name"); UnitsThatAreRequiredByThisBuilding = _gameConfigRepository.ToList(_unitBuildings, "Unit", "UnitId", "Name"); BuildingsRequiredToBuildThisBuilding = _gameConfigRepository.ToList(_requiredBuildings, "Building", "RequiredBuildingId", "Name"); MaximumPopulationIncrease = DetermineMaximumPopulationIncrease(buildingId); PopulationGrowthRateIncrease = DeterminePopulationGrowthRateIncrease(buildingId); FoodOutputIncrease = DetermineFoodOutputIncrease(buildingId); }
public UnitConfig(int unitId) { _gameConfigRepository = CallContext <GameConfigRepository> .GetData("GameConfigRepository"); var units = _gameConfigRepository.GetEntities("Unit"); _unit = units.GetById(unitId); _unitActions = _gameConfigRepository.GetEntities("UnitAction").Filter("UnitId", unitId); _unitMovements = _gameConfigRepository.GetEntities("UnitMovement").Filter("UnitId", unitId); _unitBuildings = _gameConfigRepository.GetEntities("UnitBuilding").Filter("UnitId", unitId); _unitRaces = _gameConfigRepository.GetEntities("UnitRace").Filter("UnitId", unitId); _movementIncrementSightBy = _gameConfigRepository.GetEntities("MovementIncrementSightBy"); ActionsThisUnitCanPerform = _gameConfigRepository.ToList(_unitActions, "Action", "ActionId", "Name"); MovementTypesThisUnitCanPerform = _gameConfigRepository.ToList(_unitMovements, "Movement", "MovementId", "Name"); BuildingsRequiredToBuildThisUnit = _gameConfigRepository.ToList(_unitBuildings, "Building", "BuildingId", "Name"); RacesThatCanBuildThisUnit = _gameConfigRepository.ToList(_unitRaces, "Race", "RaceId", "Name"); MovementSightIncrements = new List <int>(); foreach (var item in _unitMovements) { var movementId = (int)item.MovementId; var movementIncrementSightBy = _movementIncrementSightBy.Filter("MovementId", movementId); foreach (var item2 in movementIncrementSightBy) { MovementSightIncrements.Add((int)item2.Value); } } }
private float DetermineIncrementSightBy(int movementId) { var movementIncrementSightBys = _gameConfigRepository.GetEntities("MovementIncrementSightBy"); var filtered = movementIncrementSightBys.Filter("MovementId", movementId); var amt = 0; foreach (var item in filtered) { var val = (int)item.Value; if (val > amt) { amt = val; } } return(amt); }