Esempio n. 1
0
        private static void FindTechnologyTrainer(uint type, byte level, out IStructureBaseStats trainer)
        {
            foreach (var builderType in structureTypes)
            {
                byte structureLevel = 1;
                IStructureBaseStats stats;

                while ((stats = kernel.Get <IStructureCsvFactory>().GetBaseStats(builderType, structureLevel)) != null)
                {
                    structureLevel++;

                    ActionRequirementFactory.ActionRecord record =
                        kernel.Get <ActionRequirementFactory>().GetActionRequirementRecord(stats.WorkerId);

                    if (record == null)
                    {
                        continue;
                    }

                    if (
                        record.List.Any(
                            action =>
                            action.Type == ActionType.TechnologyUpgradeActive &&
                            ushort.Parse(action.Parms[0]) == type &&
                            byte.Parse(action.Parms[1]) >= level))
                    {
                        trainer = stats;
                        return;
                    }
                }
            }

            trainer = null;
        }
Esempio n. 2
0
        private static void FindStructureBuilder(ushort type,
                                                 byte level,
                                                 out IStructureBaseStats builder,
                                                 out bool convert)
        {
            if (level > 1)
            {
                builder = kernel.Get <IStructureCsvFactory>().GetBaseStats(type, (byte)(level - 1));
                convert = false;
                return;
            }

            foreach (var builderType in structureTypes)
            {
                if (builderType == type)
                {
                    continue;
                }

                byte structureLevel = 1;
                IStructureBaseStats stats;

                while ((stats = kernel.Get <IStructureCsvFactory>().GetBaseStats(builderType, structureLevel)) != null)
                {
                    structureLevel++;

                    ActionRequirementFactory.ActionRecord record =
                        kernel.Get <ActionRequirementFactory>().GetActionRequirementRecord(stats.WorkerId);

                    if (record == null)
                    {
                        continue;
                    }

                    foreach (var action in record.List)
                    {
                        if (level == 1)
                        {
                            if (action.Type == ActionType.StructureBuildActive && ushort.Parse(action.Parms[0]) == type)
                            {
                                builder = stats;
                                convert = false;
                                return;
                            }

                            if (action.Type == ActionType.StructureChangeActive && ushort.Parse(action.Parms[0]) == type)
                            {
                                builder = stats;
                                convert = true;
                                return;
                            }
                        }
                    }
                }
            }

            builder = null;
            convert = false;
        }
Esempio n. 3
0
        /// <summary>
        ///     Returns the cost for building the specified structure
        /// </summary>
        public virtual Resource StructureCost(ICity city, IStructureBaseStats stats)
        {
            if (city.Battle == null)
            {
                return(stats.Cost);
            }

            return(stats.Cost * Config.battle_cost_penalty);
        }
Esempio n. 4
0
 private static void CreateDefinition(IStructureBaseStats stats)
 {
     nodeDefintions[GetKey(stats)] =
         string.Format(
             "[label=\"{0} (Level {1})\", labelloc=\"b\", height={3}, shape=none, image=\"{2}.png\"]",
             lang[stats.Name + "_STRUCTURE_NAME"],
             stats.Lvl,
             stats.SpriteClass,
             stats.Size == 1 ? 1 : 2);
 }
Esempio n. 5
0
        public StructureBuildActiveActionExecuteBuilder(IFixture fixture)
        {
            this.fixture = fixture;

            requirementCsvFactory = fixture.Freeze <IRequirementCsvFactory>();
            requirementCsvFactory
            .GetLayoutRequirement(Arg.Any <ushort>(), Arg.Any <byte>())
            .Validate(Arg.Any <IStructure>(), Arg.Any <ushort>(), Arg.Any <uint>(), Arg.Any <uint>(), Arg.Any <byte>())
            .Returns(true);

            structureBaseStats = fixture.Freeze <IStructureBaseStats>();
            structureBaseStats.Size.Returns <byte>(0);
            var structureCost = new Resource(1234, 8446, 1343, 1234, 1246);

            structureBaseStats.Cost.Returns(structureCost);

            var structure = fixture.Freeze <IStructure>();

            structure.Stats.Base.Returns(structureBaseStats);

            objectTypeFactory = fixture.Freeze <IObjectTypeFactory>();
            objectTypeFactory.IsObjectType("NoRoadRequired", Arg.Any <ushort>()).Returns(true);

            city = fixture.Create <ICity>();
            city.PrimaryPosition.Returns(new Position(99, 98));
            city.Radius.Returns <byte>(5);
            city.Resource.HasEnough(structureBaseStats.Cost).Returns(true);
            city.CreateStructure(Arg.Any <ushort>(), Arg.Any <byte>(), Arg.Any <uint>(), Arg.Any <uint>()).Returns(structure);

            roadPathFinder = fixture.Freeze <IRoadPathFinder>();
            roadPathFinder.CanBuild(Arg.Any <Position>(), Arg.Any <byte>(), city, Arg.Any <bool>()).Returns(Error.Ok);

            tileLocator = fixture.Freeze <ITileLocator>();
            tileLocator.TileDistance(new Position(99, 98), 1, Arg.Any <Position>(), 1).Returns(1);

            world = fixture.Freeze <IWorld>();
            ICity outCity;

            world.TryGetObjects(Arg.Any <uint>(), out outCity).Returns(x =>
            {
                x[1] = city;
                return(true);
            });
            world.Regions.GetObjectsInTile(Arg.Any <uint>(), Arg.Any <uint>()).Returns(new List <ISimpleGameObject>());
            world.Regions.IsValidXandY(0, 0).ReturnsForAnyArgs(true);
            world.Regions.Add(structure).Returns(true);

            structureCsvFactory = fixture.Freeze <IStructureCsvFactory>();
            structureCsvFactory.GetBaseStats(0, 0).ReturnsForAnyArgs(structureBaseStats);

            formula = Substitute.For <Formula>();
            formula.CityMaxConcurrentBuildActions(0, 0, null, null).ReturnsForAnyArgs(Error.Ok);
            formula.StructureCost(null, null).ReturnsForAnyArgs(structureCost);
            fixture.Register(() => formula);
        }
Esempio n. 6
0
        public void Execute_WhenAllStructureTilesAreValid_ReturnsOk(
            [Frozen] IWorld world,
            [Frozen] ITileLocator tileLocator,
            [Frozen] IStructureBaseStats structureBaseStats,
            Fixture fixture)
        {
            var action = new StructureBuildActiveActionExecuteBuilder(fixture).Build();

            structureBaseStats.Size.Returns <byte>(11);

            tileLocator.ForeachMultitile(action.X, action.Y, 11).Returns(new[] { new Position(1, 1), new Position(1, 2) });

            world.Regions.IsValidXandY(Arg.Any <uint>(), Arg.Any <uint>()).Returns(false);
            world.Regions.IsValidXandY(1, 1).Returns(true);
            world.Regions.IsValidXandY(1, 2).Returns(true);

            action.Execute().Should().Be(Error.Ok);
        }
Esempio n. 7
0
        protected StrongholdCombatStructure(uint id,
                                            uint battleId,
                                            ushort type,
                                            byte lvl,
                                            decimal hp,
                                            IStronghold stronghold,
                                            IStructureCsvFactory structureCsvFactory,
                                            IBattleFormulas battleFormulas,
                                            IDbManager dbManager)
            : base(id, battleId, battleFormulas, dbManager)
        {
            Stronghold = stronghold;
            this.type  = type;
            this.lvl   = lvl;
            this.hp    = hp;

            structureBaseStats = structureCsvFactory.GetBaseStats(type, lvl);
            stats = new BattleStats(structureBaseStats.Battle);
        }
Esempio n. 8
0
        public void Execute_WhenAStructureTileIsAlreadyOccupied_ReturnsError(
            [Frozen] IWorld world,
            [Frozen] ITileLocator tileLocator,
            [Frozen] ICity city,
            [Frozen] IStructureBaseStats structureBaseStats,
            Fixture fixture)
        {
            var action = new StructureBuildActiveActionExecuteBuilder(fixture).Build();

            structureBaseStats.Size.Returns <byte>(11);

            tileLocator.ForeachMultitile(action.X, action.Y, 11).Returns(new[] { new Position(1, 1), new Position(1, 2) });
            world.Regions.GetObjectsInTile(1, 1).Returns(new List <ISimpleGameObject>());
            world.Regions.GetObjectsInTile(1, 2).Returns(new List <ISimpleGameObject> {
                Substitute.For <IStructure>()
            });

            action.Execute().Should().Be(Error.StructureExists);
        }
Esempio n. 9
0
        public void Execute_WhenAStructureTileIsOutOfCityRadius_ReturnsError(
            [Frozen] IWorld world,
            [Frozen] ITileLocator tileLocator,
            [Frozen] ICity city,
            [Frozen] IStructureBaseStats structureBaseStats,
            Fixture fixture)
        {
            var action = new StructureBuildActiveActionExecuteBuilder(fixture).Build();

            structureBaseStats.Size.Returns <byte>(11);

            tileLocator.ForeachMultitile(action.X, action.Y, 11).Returns(new[] { new Position(1, 1), new Position(1, 2) });
            tileLocator.TileDistance(city.PrimaryPosition, 1, Arg.Is <Position>(p => p.X == 1 && p.Y == 1), 1).Returns(5);
            tileLocator.TileDistance(city.PrimaryPosition, 1, Arg.Is <Position>(p => p.X == 1 && p.Y == 2), 1).Returns(6);

            city.Radius.Returns <byte>(6);

            action.Execute().Should().Be(Error.NotWithinWalls);
        }
Esempio n. 10
0
 private static void WriteNode(IStructureBaseStats from, TechnologyBase to)
 {
     nodeConnections.WriteLine("{0} -> {1};", GetKey(from), GetKey(to));
 }
Esempio n. 11
0
 private static void WriteNode(IStructureBaseStats from, IStructureBaseStats to, string style, string label)
 {
     // Causes graphviz to freak out and draw a lot of edge intersections
     //nodeConnections.WriteLine("{0} -> {1} [ label = \"{2}\" ];", GetKey(from), GetKey(to), label);
     nodeConnections.WriteLine("{0} -> {1} [style={2} label=\"{3}\"];", GetKey(from), GetKey(to), style, label);
 }
Esempio n. 12
0
        private static void Main()
        {
            string settings = string.Empty;

            try
            {
                var p = new OptionSet {
                    { "output=", v => output = v }, { "settings=", v => settings = v }
                };

                p.Parse(Environment.GetCommandLineArgs());
            }
            catch (Exception)
            {
            }

            if (!string.IsNullOrEmpty(settings))
            {
                Config.LoadConfigFile(settings);
            }

            kernel = Engine.CreateDefaultKernel();
            kernel.Get <FactoriesInitializer>().CompileAndInit();

            LoadLanguages();

            // Get types
            structureTypes = from structure in kernel.Get <IStructureCsvFactory>().AllStructures()
                             group structure by structure.Type
                             into types orderby types.Key select types.Key;

            technologyTypes = from technology in kernel.Get <TechnologyFactory>().AllTechnologies()
                              group technology by technology.Techtype
                              into types orderby types.Key select types.Key;

            unitTypes = from unit in kernel.Get <UnitFactory>().AllUnits()
                        group unit by unit.Type
                        into types orderby types.Key select types.Key;

            // Process structures
            Directory.CreateDirectory(output);
            using (var writer = new StreamWriter(File.Create(Path.Combine(output, "structure_listing.inc.php"))))
            {
                writer.Write(@"<?php
                    $structures = array(
                ");

                foreach (var type in structureTypes)
                {
                    if (kernel.Get <IObjectTypeFactory>().IsObjectType("DatabaseIgnoreStructures", type))
                    {
                        continue;
                    }

                    ProcessStructure(type);

                    IStructureBaseStats stats = kernel.Get <IStructureCsvFactory>().GetBaseStats(type, 1);

                    var sprite = stats.SpriteClass;

                    // Sorry this is a bit of a hack, it's a CropField then we append the Mature status to it :)
                    if (kernel.Get <IObjectTypeFactory>().IsObjectType("CropField", type))
                    {
                        sprite =
                            kernel.Get <IStructureCsvFactory>()
                            .AllStructures()
                            .First(structure => structure.Lvl == 1 && structure.Name == "MATURE_" + stats.Name)
                            .SpriteClass;
                    }

                    writer.WriteLine("'{2}_STRUCTURE' => array('name' => '{1}', 'sprite' => '{0}'),",
                                     sprite,
                                     lang[stats.Name + "_STRUCTURE_NAME"],
                                     stats.Name);
                }

                writer.Write(@");");
            }

            // Process units
            using (var writer = new StreamWriter(File.Create(Path.Combine(output, "unit_listing.inc.php"))))
            {
                writer.Write(@"<?php
                    $units = array(
                ");
                foreach (var type in unitTypes)
                {
                    ProcessUnit(type);

                    IBaseUnitStats stats = kernel.Get <UnitFactory>().GetUnitStats(type, 1);
                    writer.WriteLine("'{2}_UNIT' => array('name' => '{1}', 'sprite' => '{0}'),",
                                     stats.SpriteClass,
                                     lang[stats.Name + "_UNIT"],
                                     stats.Name);
                }
                writer.Write(@");");
            }

            // Process technologies
            // Process units
            using (var writer = new StreamWriter(File.Create(Path.Combine(output, "technology_listing.inc.php"))))
            {
                writer.Write(@"<?php
                    $technologies = array(
                ");
                foreach (var type in technologyTypes)
                {
                    if (kernel.Get <IObjectTypeFactory>().IsObjectType("DatabaseIgnoreTech", (ushort)type))
                    {
                        continue;
                    }

                    ProcessTechnology(type);

                    TechnologyBase stats = kernel.Get <TechnologyFactory>().GetTechnologyBase(type, 1);
                    writer.WriteLine("'{0}_TECHNOLOGY' => array('name' => '{1}'),",
                                     stats.Name,
                                     lang[stats.Name + "_TECHNOLOGY_NAME"]);
                }
                writer.Write(@");");
            }
        }
Esempio n. 13
0
 private static string GetKey(IStructureBaseStats stats)
 {
     return("STRUCTURE_" + stats.StructureHash);
 }
Esempio n. 14
0
        private static Result ProcessStructure(IStructureBaseStats structureBaseStats, bool skipUpgrades)
        {
            int hash = structureBaseStats.Type * 100 + structureBaseStats.Lvl;

            if (processedStructures.Contains(hash))
            {
                return(Result.AlreadyProcessed);
            }

            Console.Out.WriteLine("Parsing " + structureBaseStats.Name + " " + structureBaseStats.Lvl);

            ActionRequirementFactory.ActionRecord record =
                kernel.Get <ActionRequirementFactory>().GetActionRequirementRecord(structureBaseStats.WorkerId);

            processedStructures.Add(hash);

            bool hadConnection = false;

            if (structureBaseStats.Lvl == 1)
            {
                CreateDefinition(structureBaseStats);
            }

            if (record == null)
            {
                return(Result.Empty);
            }

            // First pass
            foreach (var action in record.List)
            {
                switch (action.Type)
                {
                case ActionType.StructureBuildActive:
                case ActionType.StructureChangeActive:
                    IStructureBaseStats building = kernel.Get <IStructureCsvFactory>().GetBaseStats(ushort.Parse(action.Parms[0]), 1);
                    Result result = ProcessStructure(building, false);
                    if (result != Result.AlreadyProcessed)
                    {
                        if (action.Type == ActionType.StructureBuildActive)
                        {
                            WriteNode(structureBaseStats, building);
                        }
                        else if (action.Type == ActionType.StructureChangeActive)
                        {
                            WriteNode(structureBaseStats, building, "dashed", "Converts To");
                        }

                        hadConnection = true;
                    }
                    break;

                case ActionType.UnitTrainActive:
                    IBaseUnitStats training =
                        kernel.Get <UnitFactory>().GetUnitStats(ushort.Parse(action.Parms[0]), 1);
                    if (!processedUnits.Contains(training.UnitHash))
                    {
                        WriteNode(structureBaseStats, training);
                        CreateDefinition(training);
                        hadConnection = true;
                        processedUnits.Add(training.UnitHash);
                    }
                    break;

                case ActionType.TechnologyUpgradeActive:
                    TechnologyBase tech =
                        kernel.Get <TechnologyFactory>().GetTechnologyBase(ushort.Parse(action.Parms[0]), 1);
                    if (!processedTechnologies.Contains(tech.TechnologyHash))
                    {
                        WriteNode(structureBaseStats, tech);
                        CreateDefinition(tech);
                        hadConnection = true;
                        processedTechnologies.Add(tech.TechnologyHash);
                    }
                    break;
                }
            }

            // Second pass
            foreach (var action in record.List)
            {
                switch (action.Type)
                {
                case ActionType.StructureUpgradeActive:
                    if (!skipUpgrades)
                    {
                        byte maxLvl = byte.Parse(action.Parms[0]);
                        IStructureBaseStats from = structureBaseStats;
                        var newRank = new List <String> {
                            GetKey(from)
                        };

                        for (int i = from.Lvl; i < maxLvl; i++)
                        {
                            IStructureBaseStats to = kernel.Get <IStructureCsvFactory>()
                                                     .GetBaseStats(from.Type, (byte)(i + 1));
                            Result result = ProcessStructure(to, true);
                            if (result == Result.Ok || i == maxLvl - 1)
                            {
                                WriteNode(from, to);
                                CreateDefinition(to);
                                hadConnection = true;
                                newRank.Add(GetKey(to));
                                from = to;
                            }
                        }

                        if (newRank.Count > 1)
                        {
                            ranks.Add(newRank);
                        }
                    }
                    break;
                }
            }

            return(hadConnection ? Result.Ok : Result.Empty);
        }
Esempio n. 15
0
        private static IEnumerable <string> GetUnitRequirements(ushort type, byte level, IStructureBaseStats trainer)
        {
            ActionRequirementFactory.ActionRecord record =
                kernel.Get <ActionRequirementFactory>().GetActionRequirementRecord(trainer.WorkerId);

            ActionRequirement foundAction;

            if (level == 1)
            {
                foundAction =
                    record.List.FirstOrDefault(
                        action =>
                        action.Type == ActionType.UnitTrainActive &&
                        ushort.Parse(action.Parms[0]) == type);
            }
            else
            {
                foundAction =
                    record.List.FirstOrDefault(
                        action =>
                        action.Type == ActionType.UnitUpgradeActive &&
                        ushort.Parse(action.Parms[0]) == type &&
                        byte.Parse(action.Parms[1]) >= level);
            }

            if (foundAction == null)
            {
                yield break;
            }

            var requirements =
                kernel.Get <EffectRequirementFactory>().GetEffectRequirementContainer(foundAction.EffectReqId);

            foreach (
                var requirement in requirements.Where(requirement => requirement.WebsiteDescription != string.Empty)
                )
            {
                yield return(requirement.WebsiteDescription);
            }
        }
Esempio n. 16
0
        public StructureStats(IStructureBaseStats baseStats)
        {
            Base = baseStats;

            hp = baseStats.Battle.MaxHp;
        }
Esempio n. 17
0
        // Structure Database
        private static void ProcessStructure(ushort type)
        {
            string generalTemplate = @"<?php
                // Generated by DatabaseGenerator program on #DATE#
	            $structureKey = '#STRUCTURE#';
	            $structureName = '#STRUCTURE_NAME#';
	            $description = '#DESCRIPTION#';
	
	            $converted = '#CONVERTED#';
	            $builtBy = array('name' => '#BUILT_BY_NAME#', 'key' => '#BUILT_BY#', 'level' => '#BUILT_BY_LEVEL#');
	
	            // Levels array should contain:
	            $levels = array(
		            #LEVELS#
	            );

                include $includeLocation . 'structure_view.ctp';
            ";

            const string levelTemplate =
                @"array('description' => '#DESCRIPTION#', 'time' => #TIME#, 'splash' => #SPLASH#, 'gold' => #GOLD#, 'crop' => #CROP#, 'iron' => #IRON#, 'labor' => #LABOR#, 'wood' => #WOOD#, 'hp' => #HP#, 'attack' => #ATTACK#, 'range' => #RANGE#, 'stealth' => #STEALTH#, 'weapon' => '#WEAPON#', 'maxLabor' => #MAXLABOR#, 'requirements' => array(#REQUIREMENTS#)),";

            string requirementTemplate = @"'#REQUIREMENT#',";

            // Get basic information
            IStructureBaseStats stats = kernel.Get <IStructureCsvFactory>().GetBaseStats(type, 1);

            generalTemplate = generalTemplate.Replace("#DATE#", DateTime.Now.ToString());
            generalTemplate = generalTemplate.Replace("#STRUCTURE#", stats.Name + "_STRUCTURE");
            generalTemplate = generalTemplate.Replace("#STRUCTURE_NAME#", lang[stats.Name + "_STRUCTURE_NAME"]);
            generalTemplate = generalTemplate.Replace("#DESCRIPTION#",
                                                      lang[stats.Name + "_STRUCTURE_DESCRIPTION"].Replace("'", "\\'"));

            // Builder info
            IStructureBaseStats builder;
            bool converted;

            FindStructureBuilder(type, 1, out builder, out converted);
            generalTemplate = generalTemplate.Replace("#CONVERTED#", converted ? "1" : "0");
            generalTemplate = generalTemplate.Replace("#BUILT_BY_NAME#",
                                                      builder != null ? lang[builder.Name + "_STRUCTURE_NAME"] : "");
            generalTemplate = generalTemplate.Replace("#BUILT_BY#", builder != null ? builder.Name + "_STRUCTURE" : "");
            generalTemplate = generalTemplate.Replace("#BUILT_BY_LEVEL#", builder != null ? builder.Lvl.ToString() : "");

            // Level info
            byte level        = 1;
            var  levelsWriter = new StringWriter(new StringBuilder());
            IStructureBaseStats currentStats = stats;

            do
            {
                string currentLevel = levelTemplate.Replace("#DESCRIPTION#",
                                                            lang[currentStats.Name + "_STRUCTURE_LVL_" + level].Replace(
                                                                "'",
                                                                "\\'"));
                currentLevel = currentLevel.Replace("#TIME#", currentStats.BuildTime.ToString());
                currentLevel = currentLevel.Replace("#GOLD#", currentStats.Cost.Gold.ToString());
                currentLevel = currentLevel.Replace("#CROP#", currentStats.Cost.Crop.ToString());
                currentLevel = currentLevel.Replace("#IRON#", currentStats.Cost.Iron.ToString());
                currentLevel = currentLevel.Replace("#LABOR#", currentStats.Cost.Labor.ToString());
                currentLevel = currentLevel.Replace("#WOOD#", currentStats.Cost.Wood.ToString());
                currentLevel = currentLevel.Replace("#HP#", currentStats.Battle.MaxHp.ToString());
                currentLevel = currentLevel.Replace("#ATTACK#", currentStats.Battle.Attack.ToString());
                currentLevel = currentLevel.Replace("#RANGE#", currentStats.Battle.Range.ToString());
                currentLevel = currentLevel.Replace("#STEALTH#", currentStats.Battle.Stealth.ToString());
                currentLevel = currentLevel.Replace("#SPLASH#", currentStats.Battle.Splash.ToString());
                currentLevel = currentLevel.Replace("#WEAPON#", currentStats.Battle.Weapon.ToString());
                currentLevel = currentLevel.Replace("#MAXLABOR#", currentStats.MaxLabor.ToString());

                // Get requirements
                var requirementsWriter = new StringWriter(new StringBuilder());

                if (builder != null)
                {
                    foreach (var requirement in GetStructureRequirements(type, level, builder))
                    {
                        requirementsWriter.WriteLine(requirementTemplate.Replace("#REQUIREMENT#", requirement));
                    }
                }

                currentLevel = currentLevel.Replace("#REQUIREMENTS#", requirementsWriter.ToString());

                levelsWriter.WriteLine(currentLevel);

                level++;
                FindStructureBuilder(type, level, out builder, out converted);
            }while ((currentStats = kernel.Get <IStructureCsvFactory>().GetBaseStats(type, level)) != null);

            generalTemplate = generalTemplate.Replace("#LEVELS#", levelsWriter.ToString());

            using (
                var writer =
                    new StreamWriter(
                        File.Create(Path.Combine(output, string.Format("{0}_STRUCTURE.ctp", stats.Name)))))
            {
                writer.Write(generalTemplate);
            }
        }
Esempio n. 18
0
        private static IEnumerable <string> GetTechnologyRequirements(uint type, byte level, IStructureBaseStats trainer)
        {
            ActionRequirementFactory.ActionRecord record =
                kernel.Get <ActionRequirementFactory>().GetActionRequirementRecord(trainer.WorkerId);

            ActionRequirement foundAction =
                record.List.FirstOrDefault(
                    action =>
                    action.Type == ActionType.TechnologyUpgradeActive &&
                    ushort.Parse(action.Parms[0]) == type &&
                    ushort.Parse(action.Parms[1]) >= level);

            if (foundAction != null)
            {
                var requirements =
                    kernel.Get <EffectRequirementFactory>()
                    .GetEffectRequirementContainer(foundAction.EffectReqId);
                foreach (var requirement in requirements)
                {
                    if (requirement.WebsiteDescription != string.Empty)
                    {
                        yield return(requirement.WebsiteDescription);
                    }
                }
            }
        }
Esempio n. 19
0
        private static IEnumerable <string> GetStructureRequirements(ushort type, byte level, IStructureBaseStats builder)
        {
            ActionRequirementFactory.ActionRecord record =
                kernel.Get <ActionRequirementFactory>().GetActionRequirementRecord(builder.WorkerId);

            ActionRequirement foundAction = null;

            foreach (var action in record.List)
            {
                if (level == 1 && action.Type == ActionType.StructureBuildActive &&
                    ushort.Parse(action.Parms[0]) == type)
                {
                    foundAction = action;
                    break;
                }

                if (level == 1 && action.Type == ActionType.StructureChangeActive &&
                    ushort.Parse(action.Parms[0]) == type)
                {
                    foundAction = action;
                    break;
                }

                if (action.Type == ActionType.StructureUpgradeActive && byte.Parse(action.Parms[0]) >= level)
                {
                    foundAction = action;
                    break;
                }
            }

            if (foundAction != null)
            {
                var requirements =
                    kernel.Get <EffectRequirementFactory>()
                    .GetEffectRequirementContainer(foundAction.EffectReqId);
                foreach (var requirement in requirements)
                {
                    if (requirement.WebsiteDescription != string.Empty)
                    {
                        yield return(requirement.WebsiteDescription);
                    }
                }
            }
        }