public virtual IList <ResourceType> GetResourcesAvailable(bool shareableOnly) { var resourcesAvailable = new List <ResourceType>(); if (wonder == null) { return(new List <ResourceType>()); } resourcesAvailable.Add(wonder.OriginalResource); var cardsAvailable = cards .Where(c => c.Type == StructureType.RawMaterial || c.Type == StructureType.ManufacturedGood || (shareableOnly ? false : c.Type == StructureType.Commercial)).ToList(); foreach (var c in cardsAvailable) { var effects = c.StandaloneEffect .Where(e => Enumerator.ContainsEnumeratorValue <RawMaterialType>((int)e.Type) || Enumerator.ContainsEnumeratorValue <ManufacturedGoodType>((int)e.Type)); foreach (var e in effects) { for (int i = 0; i < e.Quantity; ++i) { resourcesAvailable.Add((ResourceType)((int)e.Type)); } } } return(resourcesAvailable); //As of now there is no need to check standalone resources for wonder effects as it never happens }
static void CurrentResources(IGamePlayer player, bool shareable = false) { var sb = new StringBuilder(); var separator = ""; foreach (var r in player.GetResourcesAvailable(shareable)) { sb.AppendFormat("{0}{1}", separator, r.ToString()); separator = ";"; } foreach (var c in player.GetChoosableResources(shareable)) { if (!Enumerator.ContainsEnumeratorValue <ResourceType>((int)c.First())) { continue; } sb.Append(separator); var chooseSeparator = ""; foreach (var r in c) { sb.AppendFormat("{0}{1}", chooseSeparator, r.ToString()); chooseSeparator = "/"; } separator = ";"; } Console.WriteLine(string.Format("Resources: {0}", sb.ToString())); }
protected override void Compute(IList <IPlayer> players) { LoggerHelper.DebugFormat("Starting to compute scientific symbol victory points"); foreach (var player in players) { var symbols = new List <ScientificSymbol>(); var cards = player.Cards.Where(c => c.Type == StructureType.Scientific || c.Type == StructureType.Guilds).ToList(); var choosables = 0; foreach (var c in cards) { symbols.AddRange(c.StandaloneEffect .Where(e => Enumerator.ContainsEnumeratorValue <ScientificSymbol>((int)e.Type)) .Select(e => (ScientificSymbol)((int)e.Type))); choosables += c.ChoosableEffect .Any(e => Enumerator.ContainsEnumeratorValue <ScientificSymbol>((int)e.Type)) ? 1 : 0; } foreach (var p in player.Wonder.ChoosableEffectsAvailable) { choosables += p.Any(e => Enumerator.ContainsEnumeratorValue <ScientificSymbol>((int)e.Type)) ? 1 : 0; } var symbolsToCompute = GetBestCombination(symbols, choosables); player.VictoryPoints += GetVictoryPoints(symbolsToCompute); LoggerHelper.DebugFormat("{0} has now {1} victory points.", player.Name, player.VictoryPoints); } }
public IList <IList <ResourceType> > GetChoosableResources(bool shareableOnly) { var choosableResources = new List <IList <ResourceType> >(); var cardsAvailable = cards .Where(c => c.Type == StructureType.RawMaterial || c.Type == StructureType.ManufacturedGood || (shareableOnly ? false : c.Type == StructureType.Commercial)).ToList(); foreach (var c in cardsAvailable) { var effects = c.ChoosableEffect .Where(e => Enumerator.ContainsEnumeratorValue <RawMaterialType>((int)e.Type) || Enumerator.ContainsEnumeratorValue <ManufacturedGoodType>((int)e.Type)); if (!effects.Any()) { continue; } var effectResources = new List <ResourceType>(); foreach (var e in effects) { for (int i = 0; i < e.Quantity; ++i) { effectResources.Add((ResourceType)((int)e.Type)); } } choosableResources.Add(effectResources); } if (!shareableOnly) { foreach (var wr in wonder.ChoosableEffectsAvailable) { var effects = wr.Where(e => Enumerator.ContainsEnumeratorValue <RawMaterialType>((int)e.Type) || Enumerator.ContainsEnumeratorValue <ManufacturedGoodType>((int)e.Type)); if (!effects.Any()) { continue; } var effectResources = new List <ResourceType>(); foreach (var e in effects) { for (int i = 0; i < e.Quantity; ++i) { effectResources.Add((ResourceType)((int)e.Type)); } } choosableResources.Add(effectResources); } } return(choosableResources); }
public virtual IList <IEffect> GetNonResourceEffects() { var effects = wonder.EffectsAvailable.ToList(); foreach (var c in cards) { effects.AddRange(c.Production.Where(e => !Enumerator.ContainsEnumeratorValue <RawMaterialType>((int)e.Type) && !Enumerator.ContainsEnumeratorValue <ManufacturedGoodType>((int)e.Type))); } return(effects); }
public bool HasDiscount(PlayerDirection direction, TradeDiscountType type) { var availableDiscounts = new List <IEffect>(); foreach (var l in cards.Where(c => c.Type == StructureType.Commercial).Select(c => c.Production)) { availableDiscounts.AddRange(l.Where(e => Enumerator.ContainsEnumeratorValue <TradeDiscountType>((int)e.Type))); } availableDiscounts.AddRange(wonder.EffectsAvailable.Where(e => Enumerator.ContainsEnumeratorValue <TradeDiscountType>((int)e.Type))); return(availableDiscounts.Any(e => (int)e.Type == (int)type && e.Direction.HasFlag(direction))); }
protected override IList <IEffect> CheckSpecialCondition(bool lookForStandalone) { if (!production.Any(e => Enumerator.ContainsEnumeratorValue <VictoryPointType>((int)e.Type))) { return(base.CheckSpecialCondition(lookForStandalone)); } if (lookForStandalone) { return(production); } else { return(new List <IEffect>()); } }