private static string GenerateRequestedDeff(DeffRequestVillage village, List <int> deffPerAttackCount, MainWindow contextWindow)
        {
            string deffString;

            if (contextWindow.CheckBoxCalculateAvailableDeff.IsChecked == true)
            {
                int usedFarmPlaces = village.Units.Spear + village.Units.Sword + village.Units.Arrow + 6 * village.Units.HeavyCavalry;
                int availableDeff  = usedFarmPlaces / int.Parse(contextWindow.TextBoxAvailableDeffBhPlaces.Text);
                deffString = availableDeff + "/";
            }
            else
            {
                deffString = "0/";
            }
            if (contextWindow.CheckBoxIgnoreGreenAttacks.IsChecked == true)
            {
                int relevantAttackCount = village.Attacks.Where(s => s.Type != "attack_small").ToList().Count;
                deffString += deffPerAttackCount[Math.Max(relevantAttackCount - 1, 0)];
            }
            else
            {
                deffString += deffPerAttackCount[village.Attacks.Count - 1];
            }

            return(deffString);
        }
        private static string GenerateAttackSizeCode(string size, DeffRequestVillage village, MainWindow contextWindow)
        {
            string attackTypeString = "";

            if (size == "all" || size == "large")
            {
                if (village.Attacks.Count(a => a.Type == "attack_large") > 0)
                {
                    attackTypeString += "[command]attack_large[/command]" +
                                        village.Attacks.Count(a => a.Type == "attack_large");
                }
            }
            if (size == "all" || size == "medium")
            {
                if (village.Attacks.Count(a => a.Type == "attack_medium") > 0)
                {
                    if (size == "all")
                    {
                        attackTypeString += " ";
                    }
                    attackTypeString += "[command]attack_medium[/command]" +
                                        village.Attacks.Count(a => a.Type == "attack_medium");
                }
            }
            if ((size == "all" || size == "small") && contextWindow.CheckBoxIgnoreGreenAttacks.IsChecked != true)
            {
                if (village.Attacks.Count(a => a.Type == "attack_small") > 0)
                {
                    if (size == "all")
                    {
                        attackTypeString += " ";
                    }
                    attackTypeString += "[command]attack_small[/command]" +
                                        village.Attacks.Count(a => a.Type == "attack_small");
                }
            }
            if (size == "all" || size == "unknown")
            {
                if (village.Attacks.Count(a => a.Type == "attack") > 0)
                {
                    if (size == "all")
                    {
                        attackTypeString += " ";
                    }
                    attackTypeString += "[command]attack[/command]" +
                                        village.Attacks.Count(a => a.Type == "attack");
                }
            }

            return(attackTypeString);
        }
Ejemplo n.º 3
0
        public static List <DeffRequestVillage> Parse(string input)
        {
            List <DeffRequestVillage> villages       = new List <DeffRequestVillage>();
            DeffRequestVillage        currentVillage = null;
            List <string>             lines          = Regex.Split(input, "\r\n|\r|\n").ToList();

            lines = lines.Where(s => !string.IsNullOrWhiteSpace(s)).ToList();
            foreach (string line in lines)
            {
                List <string> parts = line.Split(new char[0], StringSplitOptions.RemoveEmptyEntries).ToList();
                switch (parts[0].Substring(0, Math.Min(12, parts[0].Length)))
                {
                case "[b]Dorf:[/b]":
                    if (currentVillage != null)
                    {
                        villages.Add(currentVillage);
                        currentVillage = new DeffRequestVillage();
                        currentVillage.AddCoord(parts[1]);
                        break;
                    }
                    else
                    {
                        currentVillage = new DeffRequestVillage();
                        currentVillage.AddCoord(parts[1]);
                        break;
                    }

                case "[b]Wallstufe":
                    currentVillage.AddWallLevel(parts[1]);
                    break;

                case "[b]Zustimmun":
                    currentVillage.AddLoyalty(parts[1]);
                    break;

                case "[b]Verteidig":
                    parts.RemoveAt(0);
                    currentVillage.Units = new DeffRequestUnits(parts);
                    break;

                case "[command]att":
                    currentVillage.Attacks.Add(new DeffRequestAttack(parts));
                    break;
                }
            }
            villages.Add(currentVillage);
            return(villages);
        }