Пример #1
0
        private IEnumerable <IImprovementTemplate> GetImprovementsValidFor(
            IHexCell cell, IResourceNode nodeAtLocation,
            IEnumerable <IResourceDefinition> availableResources,
            IEnumerable <IImprovementTemplate> availableImprovements
            )
        {
            if (nodeAtLocation != null &&
                nodeAtLocation.Resource.Extractor != null &&
                availableResources.Contains(nodeAtLocation.Resource) &&
                availableImprovements.Contains(nodeAtLocation.Resource.Extractor)
                )
            {
                return(new List <IImprovementTemplate>()
                {
                    nodeAtLocation.Resource.Extractor
                });
            }
            else
            {
                var retval = availableImprovements.Where(
                    improvement => ImprovementValidityLogic.IsTemplateValidForCell(improvement, cell, true)
                    ).ToList();

                retval.Add(null);

                return(retval);
            }
        }
 private void TryAddImprovementTo(IImprovementTemplate template, IHexCell location)
 {
     if (ImprovementValidityLogic.IsTemplateValidForCell(template, location, true) &&
         ImprovementLocationCanon.CanPlaceImprovementOfTemplateAtLocation(template, location)
         )
     {
         ImprovementFactory.BuildImprovement(template, location, 0, true, false);
     }
 }
Пример #3
0
        private bool CanHandleWithNewSite(AbilityCommandRequest command, IUnit unit)
        {
            var unitLocation = UnitPositionCanon.GetOwnerOfPossession(unit);

            var templateOfName    = GetTemplateOfName(command.ArgsToPass.FirstOrDefault());
            var improvementOnCell = ImprovementLocationCanon.GetPossessionsOfOwner(unitLocation).FirstOrDefault();

            return(templateOfName != null &&
                   ValidityLogic.IsTemplateValidForCell(templateOfName, unitLocation, false) &&
                   (improvementOnCell == null || improvementOnCell.Template != templateOfName));
        }