Пример #1
0
        public override string Command(Bomb bomb, string command)
        {
            if (command == "combination locks")
            {
                return(Solve(bomb));
            }

            foreach (var word in command.Split(' '))
            {
                if (InternalFunctions.IsNumber(word))
                {
                    if (TwoFactor1.Length < 6)
                    {
                        TwoFactor1 += InternalFunctions.GetNumber(word);
                    }
                    else
                    {
                        TwoFactor2 += InternalFunctions.GetNumber(word);
                    }
                }
            }

            if (TwoFactor1.Length != 6 || TwoFactor2.Length != 6)
            {
                return("Could not get two factors.");
            }

            return(Solve(bomb));
        }
Пример #2
0
        public override string Solve(Bomb bomb)
        {
            int number1 = 0, number2 = 0, number3 = 0;

            //Number 1
            if (!string.IsNullOrEmpty(TwoFactor1))
            {
                number1 += InternalFunctions.GetNumber(TwoFactor1[5].ToString());
            }

            if (!string.IsNullOrEmpty(TwoFactor2))
            {
                number1 += InternalFunctions.GetNumber(TwoFactor2[5].ToString());
            }

            number1 += bomb.GetBatteries();

            //Number 2
            if (!string.IsNullOrEmpty(TwoFactor1))
            {
                number2 += InternalFunctions.GetNumber(TwoFactor1[0].ToString());
            }

            if (!string.IsNullOrEmpty(TwoFactor2))
            {
                number2 += InternalFunctions.GetNumber(TwoFactor2[0].ToString());
            }
            number2 += bomb.GetSolvedModules();

            //Number 3
            number3 += number1 + number2;
            Solved   = true;
            return($"The numbers are {number1%20}, {number2 % 20}, {number3 % 20}.");
        }
Пример #3
0
        public override string Command(Bomb bomb, string command)
        {
            if (command.Contains("reset"))
            {
                Stages.Clear(); return("Moduled reseted");
            }

            var op = 0;
            var numberDisplayed = 0;
            var value1          = "";
            var value2          = "";
            var value3          = "";
            var value4          = "";

            foreach (var word in command.Split(' '))
            {
                if (word == "display" || word == "monitor" || word == "show")
                {
                    op = 1;
                }
                if (word == "numbers")
                {
                    op = 2;
                }
                if (InternalFunctions.GetNumber(word) != -1)
                {
                    if (op == 1)
                    {
                        numberDisplayed = InternalFunctions.GetNumber(word);
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(value1))
                        {
                            value1 = word; continue;
                        }
                        if (string.IsNullOrEmpty(value2))
                        {
                            value2 = word; continue;
                        }
                        if (string.IsNullOrEmpty(value3))
                        {
                            value3 = word; continue;
                        }
                        if (string.IsNullOrEmpty(value4))
                        {
                            value4 = word; continue;
                        }
                    }
                }
            }
            return(StageOption(numberDisplayed.ToString(), value1, value2, value3, value4));
        }
        public override string Command(Bomb bomb, string command)
        {
            if (command.Contains("serial"))
            {
                foreach (var word in command.Split(' '))
                {
                    Serial += InternalFunctions.GetLetterFromPhoneticLetter(word).ToUpper();
                    Serial += InternalFunctions.GetNumber(word) == -1 ? "" : InternalFunctions.GetNumber(word).ToString();
                }
                return("Serial added.");
            }
            if (command.Contains("type"))
            {
                if (command.Contains("strk"))
                {
                    Type = "STRK";
                }
                if (command.Contains("leds"))
                {
                    Type = "LEDS";
                }
                if (command.Contains("cntd"))
                {
                    Type = "CNTD";
                }
                if (command.Contains("expl"))
                {
                    Type = "EXPL";
                }

                if (Type != "")
                {
                    return("Type added.");
                }
            }
            foreach (var word in command.Split(' '))
            {
                if (InternalFunctions.IsNumber(word))
                {
                    if (command.Contains("pins"))
                    {
                        PinQuantity = InternalFunctions.GetNumber(word);
                        return("Pin quantity added.");
                    }
                    else
                    {
                        PinNumber = InternalFunctions.GetNumber(word);
                        return(Solve(bomb));
                    }
                }
            }
            return("Cannot resolve, try again.");
        }
Пример #5
0
        public override string Command(Bomb bomb, string command)
        {
            if (command.Contains("solve"))
            {
                return(Solve(bomb));
            }
            foreach (var word in command.Split(' '))
            {
                if (InternalFunctions.GetNumber(word) != -1)
                {
                    AddNumber(bomb, InternalFunctions.GetNumber(word).ToString());
                }
            }

            return("Number saved.");
        }
        public override string Command(Bomb bomb, string command)
        {
            StartPosition = new Wire();
            var positionList = new List <int>()
            {
            };
            var colorList = new List <string>();

            foreach (var word in command.Split(' '))
            {
                if (InternalFunctions.IsNumber(word))
                {
                    positionList.Add(InternalFunctions.GetNumber(word));
                }
                if (InternalFunctions.IsColor(word))
                {
                    colorList.Add(word);
                }
            }

            if (positionList.Count != colorList.Count || positionList.Count == 0 || colorList.Count == 0)
            {
                return("Different number of colors and positions.");
            }

            var originalStart = StartPosition;

            for (int i = 0; i < positionList.Count - 1; i++)
            {
                StartPosition.Start         = positionList[i];
                StartPosition.End           = positionList[i + 1 % positionList.Count];
                StartPosition.Color         = colorList[i];
                StartPosition.Next          = new Wire();
                StartPosition.Next.Previous = StartPosition;
                StartPosition = StartPosition.Next;
            }

            StartPosition.Start         = positionList[positionList.Count - 1];
            StartPosition.End           = positionList[0];
            StartPosition.Color         = colorList[colorList.Count - 1];
            StartPosition.Next          = originalStart;
            StartPosition.Next.Previous = StartPosition;
            StartPosition = StartPosition.Next;

            return(Solve(bomb));
        }
Пример #7
0
        public override string Command(Bomb bomb, string command)
        {
            Dials.Clear();

            foreach (var word in command.Split(' '))
            {
                if (InternalFunctions.GetNumber(word) != -1)
                {
                    Dials.Add(InternalFunctions.GetNumber(word));
                }
            }
            if (Dials.Count != 6)
            {
                return("Not enought dials.");
            }
            return(Solve(bomb));
        }
Пример #8
0
        public override string Command(Bomb bomb, string command)
        {
            foreach (var word in command.Split(' '))
            {
                if (InternalFunctions.IsNumber(word))
                {
                    Quantity = InternalFunctions.GetNumber(word);
                }
                if (InternalFunctions.IsColor(word))
                {
                    Color = word;
                }
            }
            if (Quantity == 0 || string.IsNullOrEmpty(Color))
            {
                return("Cannot find quantity and color");
            }

            return(Solve(bomb));
        }
Пример #9
0
        public override string Command(Bomb bomb, string command)
        {
            foreach (var word in command.Split(' '))
            {
                if (InternalFunctions.IsNumber(word))
                {
                    Numbers.Add(InternalFunctions.GetNumber(word));
                }
                if (InternalFunctions.IsPhoneticLetter(word))
                {
                    Letters.Add(InternalFunctions.GetLetterFromPhoneticLetter(word));
                }
            }

            if (Letters.Count != 5)
            {
                return("Not enought phonetic letters.");
            }

            return(Solve(bomb));
        }
Пример #10
0
        public override string Command(Bomb bomb, string command)
        {
            foreach (var word in command.Split(' '))
            {
                if (InternalFunctions.IsColor(word))
                {
                    Color = word;
                }

                if (InternalFunctions.IsNumber(word))
                {
                    Volume = InternalFunctions.GetNumber(word);
                }
            }

            if (string.IsNullOrEmpty(Color))
            {
                return("Could not identify solution.");
            }
            return(Solve(bomb));
        }
Пример #11
0
        public override string Command(Bomb bomb, string command)
        {
            var count = 0;

            foreach (var word in command.Split(' '))
            {
                if (InternalFunctions.GetNumber(word) != -1)
                {
                    switch (count)
                    {
                    case 0: Number100 += InternalFunctions.GetNumber(word); count++; break;

                    case 1: Number10 += InternalFunctions.GetNumber(word); count++; break;

                    case 2: Number1 += InternalFunctions.GetNumber(word); count++; break;
                    }
                }
                if (Number1 > 9)
                {
                    Number1  -= 10;
                    Number10 += 1;
                }

                if (Number10 > 9)
                {
                    Number10  -= 10;
                    Number100 += 1;
                }

                if (Number100 > 9)
                {
                    Number100 -= 10;
                }
            }

            return(Solve(bomb));
        }
Пример #12
0
        public override string Solve(Bomb bomb)
        {
            var      message      = "";
            Solution acidSolution = Solutions.First(x => x.Color == Color);
            Solution baseSolution;

            //Defining base to add
            if (bomb.HasLitIndicator("NSA") && bomb.HasExactlyBatteries(3))
            {
                baseSolution = Solutions.First(x => x.Name == "ammonia");
            }
            else if (bomb.HasLitIndicator("CAR") || bomb.HasLitIndicator("FRQ") || bomb.HasLitIndicator("IND"))
            {
                baseSolution = Solutions.First(x => x.Name == "potassium hydroxide");
            }
            else if (!bomb.HasManyPorts(1) && bomb.HasSerialVowel())
            {
                baseSolution = Solutions.First(x => x.Name == "lythium hydroxide");
            }
            else if (bomb.HasIndicatorWithLetterInWord(acidSolution.Formula))
            {
                baseSolution = Solutions.First(x => x.Name == "potassium hydroxide");
            }
            else if (bomb.GetDBatteries() > bomb.GetAABatteries())
            {
                baseSolution = Solutions.First(x => x.Name == "ammonia");
            }
            else if (acidSolution.AnionAtomicNumber < 20)
            {
                baseSolution = Solutions.First(x => x.Name == "sodium hydroxide");
            }
            else
            {
                baseSolution = Solutions.First(x => x.Name == "lythium hydroxide");
            }

            message += baseSolution.Message;

            //Defining acid concentration
            double acidConcentration = 0;

            acidConcentration += acidSolution.AnionAtomicNumber;
            acidConcentration -= baseSolution.CationAtomicNumber;
            if (InternalFunctions.HasVowelInWord(acidSolution.AnionFormula) || InternalFunctions.HasVowelInWord(baseSolution.CationFormula))
            {
                acidConcentration -= 4;
            }
            if (acidSolution.AnionFormula.Length == baseSolution.CationFormula.Length)
            {
                acidConcentration *= 3;
            }
            acidConcentration = InternalFunctions.GetNumber(acidConcentration.ToString().Last().ToString());
            if (acidConcentration == 0)
            {
                acidConcentration = Volume * 2 / 5;
            }
            acidConcentration /= 10;

            //Defining base concentration
            double baseConcentration = 0;

            if (bomb.GetBatteriesHolders() > bomb.GetPortsQuantity() && bomb.GetBatteriesHolders() > bomb.GetIndicators())
            {
                baseConcentration = 5;
            }
            if (bomb.GetPortTypesQuantity() > bomb.GetBatteriesHolders() && bomb.GetPortTypesQuantity() > bomb.GetIndicators())
            {
                baseConcentration = 10;
            }
            if (bomb.GetIndicators() > bomb.GetBatteriesHolders() && bomb.GetIndicators() > bomb.GetPortTypesQuantity())
            {
                baseConcentration = 20;
            }
            if (bomb.GetBatteriesHolders() == bomb.GetPortTypesQuantity() && bomb.GetPortTypesQuantity() == bomb.GetIndicators())
            {
                var difference5  = Math.Abs(5 - baseSolution.CationAtomicNumber);
                var difference10 = Math.Abs(10 - baseSolution.CationAtomicNumber);
                var difference20 = Math.Abs(20 - baseSolution.CationAtomicNumber);

                if (difference5 < difference10 && difference5 < difference20)
                {
                    baseConcentration = 5;
                }
                if (difference10 < difference5 && difference10 < difference20)
                {
                    baseConcentration = 10;
                }
                if (difference20 < difference5 && difference20 < difference10)
                {
                    baseConcentration = 20;
                }
            }

            if ((acidSolution.Formula == "HI" && baseSolution.Formula == "KOH") || (acidSolution.Formula == "HCl" && baseSolution.Formula == "NH3"))
            {
                baseConcentration = 20;
            }

            //Defining drops
            double drops = 20;

            drops   /= baseConcentration;
            drops   *= Volume;
            drops   *= acidConcentration;
            message += $"{(int)drops} drops. ";

            //Defining filter
            switch (acidSolution.Formula)
            {
            case "HBr":
                if (baseSolution.Formula == "NH3" || baseSolution.Formula == "NaOH")
                {
                    message += "Filter off.";
                }
                else
                {
                    message += "Filter on.";
                }
                break;

            case "HF":
                if (baseSolution.Formula == "KOH" || baseSolution.Formula == "NaOH")
                {
                    message += "Filter off.";
                }
                else
                {
                    message += "Filter on.";
                }
                break;

            case "HCl":
                if (baseSolution.Formula == "LiOH")
                {
                    message += "Filter off.";
                }
                else
                {
                    message += "Filter on.";
                }
                break;

            case "HI":
                if (baseSolution.Formula != "NaOH")
                {
                    message += "Filter off.";
                }
                else
                {
                    message += "Filter on.";
                }
                break;
            }

            Solved = true;

            return(message);
        }
Пример #13
0
        public override string Command(Bomb bomb, string command)
        {
            var result = "";

            if (command.Contains("reset"))
            {
                Circle1        = "";
                Circle2        = "";
                ExitPosition   = "";
                PlayerPosition = "";
                result         = "Module reseted";
            }

            if (command.Contains("player"))
            {
                foreach (var word in command.Split(' '))
                {
                    if (InternalFunctions.GetNumber(word) != -1)
                    {
                        PlayerPosition += InternalFunctions.GetNumber(word) + " ";
                    }
                }
                PlayerPosition = PlayerPosition.Trim().Replace(' ', ',');

                result = "Recorded player position.";
            }
            if (command.Contains("exit"))
            {
                foreach (var word in command.Split(' '))
                {
                    if (InternalFunctions.GetNumber(word) != -1)
                    {
                        ExitPosition += InternalFunctions.GetNumber(word) + " ";
                    }
                }
                ExitPosition = ExitPosition.Trim().Replace(' ', ',');

                result = "Recorded exit position.";
            }
            if (command.Contains("circle"))
            {
                foreach (var word in command.Split(' '))
                {
                    if (InternalFunctions.GetNumber(word) != -1)
                    {
                        Circle2 += InternalFunctions.GetNumber(word) + " ";
                    }
                }
                Circle2 = Circle2.Trim().Replace(' ', ',');

                if (string.IsNullOrEmpty(Circle1))
                {
                    Circle1 = Circle2;
                    Circle2 = "";
                }

                result = "Recorded circle position";
            }

            if (!(string.IsNullOrWhiteSpace(Circle1) || string.IsNullOrWhiteSpace(Circle2) || string.IsNullOrWhiteSpace(ExitPosition) || string.IsNullOrWhiteSpace(PlayerPosition)))
            {
                result = Solve(bomb);
                Solved = result.StartsWith("Missing");
            }

            return(result);
        }