private ITechDefinition BuildTech(
            string name,
            List <ITechDefinition> prerequisities    = null,
            List <IBuildingTemplate> buildings       = null,
            List <IUnitTemplate> units               = null,
            List <IAbilityDefinition> abilities      = null,
            List <IResourceDefinition> resources     = null,
            List <IPolicyTreeDefinition> policyTrees = null,
            List <IImprovementTemplate> improvements = null,
            TechnologyEra era = TechnologyEra.Ancient
            )
        {
            var mockTech = new Mock <ITechDefinition>();

            mockTech.Name = name;

            mockTech.Setup(tech => tech.Name).Returns(name);
            mockTech.Setup(tech => tech.Era).Returns(era);

            mockTech.Setup(tech => tech.Prerequisites).Returns(prerequisities != null ? prerequisities : new List <ITechDefinition>());
            mockTech.Setup(tech => tech.BuildingsEnabled).Returns(buildings != null ? buildings      : new List <IBuildingTemplate>());
            mockTech.Setup(tech => tech.UnitsEnabled).Returns(units != null ? units          : new List <IUnitTemplate>());
            mockTech.Setup(tech => tech.AbilitiesEnabled).Returns(abilities != null ? abilities      : new List <IAbilityDefinition>());
            mockTech.Setup(tech => tech.RevealedResources).Returns(resources != null ? resources      : new List <IResourceDefinition>());
            mockTech.Setup(tech => tech.PolicyTreesEnabled).Returns(policyTrees != null ? policyTrees    : new List <IPolicyTreeDefinition>());
            mockTech.Setup(tech => tech.ImprovementsEnabled).Returns(improvements != null ? improvements   : new List <IImprovementTemplate>());

            AvailableTechs.Add(mockTech.Object);

            return(mockTech.Object);
        }
 public static TechnologyEra GetNextEra(this TechnologyEra currentEra)
 {
     if (!HasNextEra(currentEra))
     {
         throw new InvalidOperationException(string.Format("Era {0} has no next era"));
     }
     else
     {
         return((TechnologyEra)(((int)currentEra) + 1));
     }
 }
        public IEnumerable <ITechDefinition> GetEntryTechsOfEra(TechnologyEra era)
        {
            if (era.HasPreviousEra())
            {
                var previousEra = era.GetPreviousEra();

                return(GetTechsOfEra(era).Where(tech => !tech.Prerequisites.Any(prereq => prereq.Era != previousEra)));
            }
            else
            {
                return(GetTechsOfEra(era).Where(tech => !tech.Prerequisites.Any()));
            }
        }
        public IEnumerable <ITechDefinition> GetTechsOfPreviousEras(TechnologyEra currentEra)
        {
            var activeEra = currentEra;

            var retval = new List <ITechDefinition>();

            while (activeEra.HasPreviousEra())
            {
                activeEra = activeEra.GetPreviousEra();

                retval.AddRange(GetTechsOfEra(activeEra));
            }

            return(retval);
        }
 public static bool HasPreviousEra(this TechnologyEra currentEra)
 {
     return(currentEra != TechnologyEra.Ancient);
 }
 public static bool HasNextEra(this TechnologyEra currentEra)
 {
     return(currentEra != TechnologyEra.Medieval);
 }
Exemple #7
0
 public void UpdateStartingEra(int optionIndex)
 {
     StartingEra = (TechnologyEra)optionIndex;
 }
 public IEnumerable <ITechDefinition> GetTechsOfEra(TechnologyEra era)
 {
     return(AvailableTechs.Where(tech => tech.Era == era));
 }