示例#1
0
        public ReflectorController SpawnReflector(GridElementController container, ReflectorType type)
        {
            var prefab    = ItemsMap.Reflectors.FirstOrDefault((p) => p.Type == type).Prefab;
            var reflector = Instantiate(prefab, container.transform, false);

            return(reflector);
        }
示例#2
0
        protected readonly Reflector Reflector;                              //Reflector type

        public Enigma(WheelType[] wheelTypes, ReflectorType reflectorType, List <Tuple <char, char> > plugboardSettings = null)
        {
            Reflector = Reflector.CreateReflector(reflectorType);
            Wheels    = new Wheel[wheelTypes.Length];
            ConfigureWheels(wheelTypes);
            RightWheel = Wheels[Wheels.Length - 1];
            var tempDict = new Dictionary <char, char>();

            if (plugboardSettings != null)
            {
                ValidatePlugboardSettings(plugboardSettings);
                foreach (var tuple in plugboardSettings)
                {
                    tempDict.Add(tuple.Item1, tuple.Item2);
                    if (tuple.Item1 != tuple.Item2)
                    {
                        tempDict.Add(tuple.Item2, tuple.Item1);
                    }
                }
            }
            PlugboardDictionary         = new ReadOnlyDictionary <char, char>(tempDict);
            RightWheel.RotateNotch     += Wheels[1].Rotate;
            Wheels[1].RotateNotch      += Wheels[0].Rotate;
            RightWheel.RotateNotchBack += Wheels[1].RotateBack;
            Wheels[1].RotateNotchBack  += Wheels[0].RotateBack;
        }
示例#3
0
        public Reflector(Dictionary <char, char> connections, ReflectorType type, IEventAggregator eventAggregator, IUtilityFactory utilityFactory)
        {
            _connections    = connections;
            _utilityFactory = utilityFactory;

            Type = type;
            ReflectorAggregator = eventAggregator;
        }
示例#4
0
 public static Reflector CreateReflector(ReflectorType reflectorType)
 {
     if (reflectorType == ReflectorType.A) return new Reflector_A();
     if (reflectorType == ReflectorType.B) return new Reflector_B();
     if (reflectorType == ReflectorType.C) return new Reflector_C();
     if (reflectorType == ReflectorType.B_Thin) return new Reflector_B_Thin();
     if (reflectorType == ReflectorType.C_Thin) return new Reflector_C_Thin();
     throw new ArgumentException();
 }
示例#5
0
 public MapConfiguration(WheelType[] types, ReflectorType type, bool enableDB, char entry, char letter, MapEntry[] entries)
 {
     WheelTypes          = types;
     ReflectorType       = type;
     EnableDiagonalBoard = enableDB;
     CurrentEntry        = entry;
     InputLetter         = letter;
     MapEntries          = entries;
 }
示例#6
0
        private bool TryAddParts(HandApply interaction)
        {
            if (Validations.HasItemTrait(interaction.HandObject, CommonTraits.Instance.GlassSheet))
            {
                if (interaction.HandObject.TryGetComponent <Stackable>(out var stackable) && stackable.Amount >= glassNeeded)
                {
                    stackable.ServerConsume(glassNeeded);
                    currentState = ReflectorType.Single;

                    Chat.AddActionMsgToChat(interaction.Performer,
                                            $"You add {glassNeeded} glass sheets to the reflector.",
                                            $"{interaction.Performer.ExpensiveName()} adds {glassNeeded} glass sheets to the reflector.");

                    return(true);
                }

                Chat.AddExamineMsgFromServer(interaction.Performer, $"You need {glassNeeded} glass sheets to build a single reflector.");
                return(false);
            }

            if (Validations.HasItemTrait(interaction.HandObject, CommonTraits.Instance.ReinforcedGlassSheet))
            {
                if (interaction.HandObject.TryGetComponent <Stackable>(out var stackable) && stackable.Amount >= reinforcedGlassNeeded)
                {
                    stackable.ServerConsume(reinforcedGlassNeeded);
                    currentState = ReflectorType.Double;

                    Chat.AddActionMsgToChat(interaction.Performer,
                                            $"You add {reinforcedGlassNeeded} reinforced glass sheets to the reflector.",
                                            $"{interaction.Performer.ExpensiveName()} adds {reinforcedGlassNeeded} reinforced glass sheets to the reflector.");
                    return(true);
                }

                Chat.AddExamineMsgFromServer(interaction.Performer, $"You need {reinforcedGlassNeeded} reinforced glass sheets to build a double reflector.");
                return(false);
            }

            if (Validations.HasItemTrait(interaction.HandObject, CommonTraits.Instance.DiamondSheet))
            {
                if (interaction.HandObject.TryGetComponent <Stackable>(out var stackable) && stackable.Amount >= diamondsNeeded)
                {
                    stackable.ServerConsume(diamondsNeeded);
                    currentState = ReflectorType.Box;

                    Chat.AddActionMsgToChat(interaction.Performer,
                                            $"You add {diamondsNeeded} glass sheets to the reflector.",
                                            $"{interaction.Performer.ExpensiveName()} adds {diamondsNeeded} diamond to the reflector.");
                    return(true);
                }

                Chat.AddExamineMsgFromServer(interaction.Performer, $"You need {diamondsNeeded} diamond sheets to build a box reflector.");
                return(false);
            }

            return(false);
        }
示例#7
0
 public EnigmaApp(WheelType[] wTypes, ReflectorType rType, List <Tuple <char, char> > pSets, List <string> rotorPos)
 {
     InitializeComponent();
     wheels              = wTypes;
     reflector           = rType;
     plugboardSets       = pSets;
     enigma              = new Enigma(wheels, reflector, plugboardSets);
     loadedCharPositions = new char[] { rotorPos[0][0], rotorPos[1][0], rotorPos[2][0] };
     enigma.SetWheelPositions(loadedCharPositions);
     isLoadedFromWindow = true;
     LoadFromWindow();
 }
示例#8
0
        private void OnValidate()
        {
            if (Application.isPlaying)
            {
                return;
            }

            spriteHandler = GetComponentInChildren <SpriteHandler>();
            currentState  = startingState;
            spriteHandler.ChangeSprite((int)startingState);
            rotation = -startingAngle;
            transform.localEulerAngles       = new Vector3(0, 0, rotation);
            spriteTransform.localEulerAngles = Vector3.zero;
        }
示例#9
0
        private void RenderItemsManagmentMenu()
        {
            EditorGUILayout.BeginHorizontal();

            selectedAbsorberType  = (AbsorberType)EditorGUILayout.EnumPopup(selectedAbsorberType);
            selectedReflectorType = (ReflectorType)EditorGUILayout.EnumPopup(selectedReflectorType);
            selectedEmitterType   = (EmitterType)EditorGUILayout.EnumPopup(selectedEmitterType);

            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();

            {
                SetEnabled(selectedAbsorberType != AbsorberType.None);
                if (GUILayout.Button("Spawn"))
                {
                    TrySetEntityToSpawn(new LevelEntity()
                    {
                        Type = EntityType.Absorber, AbsorberType = selectedAbsorberType
                    });
                }
                ResetEnabled();
            }

            {
                SetEnabled(selectedReflectorType != ReflectorType.None);
                if (GUILayout.Button("Spawn"))
                {
                    TrySetEntityToSpawn(new LevelEntity()
                    {
                        Type = EntityType.Reflector, ReflectorType = selectedReflectorType
                    });
                }
                ResetEnabled();
            }

            {
                SetEnabled(selectedEmitterType != EmitterType.None);
                if (GUILayout.Button("Spawn"))
                {
                    TrySetEntityToSpawn(new LevelEntity()
                    {
                        Type = EntityType.Emitter, EmitterType = selectedEmitterType
                    });
                }
                ResetEnabled();
            }

            EditorGUILayout.EndHorizontal();
        }
示例#10
0
 public BombeEnigma(WheelType[] wheelTypes, ReflectorType reflectorType, 
     int stepsAhead, Bus leftBus, Bus rightBus)
     : base(wheelTypes, reflectorType)
 {
     this.StepsAheadOfKey = stepsAhead;
     foreach (var wheel in Wheels)
     {
         wheel.EnableNotch = false;
     }
     this.LeftBus = leftBus;
     LeftBus.EnigmaConnected = true;
     LeftBus.SignalEvent += LeftBus_SignalEvent;
     this.RightBus = rightBus;
     RightBus.EnigmaConnected = true;
     RightBus.SignalEvent += RightBus_SignalEvent;
 }
示例#11
0
 public BombeEnigma(WheelType[] wheelTypes, ReflectorType reflectorType,
                    int stepsAhead, Bus leftBus, Bus rightBus)
     : base(wheelTypes, reflectorType)
 {
     this.StepsAheadOfKey = stepsAhead;
     foreach (var wheel in Wheels)
     {
         wheel.EnableNotch = false;
     }
     this.LeftBus             = leftBus;
     LeftBus.EnigmaConnected  = true;
     LeftBus.SignalEvent     += LeftBus_SignalEvent;
     this.RightBus            = rightBus;
     RightBus.EnigmaConnected = true;
     RightBus.SignalEvent    += RightBus_SignalEvent;
 }
示例#12
0
 public Enigma(WheelType[] wheelTypes, ReflectorType reflectorType, IList<Tuple<char,char>> plugboardSettings = null)
 {
     Reflector = Reflector.CreateReflector(reflectorType);
     Wheels = new Wheel[wheelTypes.Length];
     ConfigureWheels(wheelTypes);
     RightWheel = Wheels[Wheels.Length - 1];
     var tempDict = new Dictionary<char, char>();
     if (plugboardSettings != null)
     {
         ValidatePlugboardSettings(plugboardSettings);
         foreach (var tuple in plugboardSettings)
         {
             tempDict.Add(tuple.Item1, tuple.Item2);
             tempDict.Add(tuple.Item2, tuple.Item1);
         }
     }
     PlugboardDictionary = new ReadOnlyDictionary<char, char>(tempDict);
 }
示例#13
0
        public Settings(MachineType typ, ReflectorType refTyp, RotorName[] rotors, int[] ringPos, string[] plugs)
            : this(typ, refTyp)
        {
            MachineType   = typ;
            ReflectorType = refTyp;

            if (MachineType == MachineType.M4K)
            {
                if (refTyp == ReflectorType.B_Dunn)
                {
                    Rotors.Add(new RotorSetting(RotorName.Beta, 0));
                }
                else
                {
                    Rotors.Add(new RotorSetting(RotorName.Gamma, 0));
                }
            }

            Rotors.Add(new RotorSetting(RotorName.I, 0));
            Rotors.Add(new RotorSetting(RotorName.II, 0));
            Rotors.Add(new RotorSetting(RotorName.III, 0));

            Plugs.Clear();

            for (int i = 0; i < rotors.Length; i++)
            {
                if (i <= Rotors.Count)
                {
                    Rotors[i].Name = rotors[i];
                    if (i <= ringPos.Length)
                    {
                        Rotors[i].RingSetting = ringPos[i];
                    }
                }
            }

            for (int i = 0; i < 10; i++)
            {
                if (i <= plugs.Length)
                {
                    Plugs.Add(new PlugSetting(plugs[i]));
                }
            }
        }
示例#14
0
        public Bombe(IEnumerable<MapEntry> mapping, char input, char entry, 
            WheelType[] wheelTypes, ReflectorType reflectorType, bool enableDiagonalBoard)
        {
            this.input = input;
            this.entry = entry;
            Buses = new Dictionary<char, Bus>();
            for (char c = 'A'; c <= 'Z'; c++) Buses.Add(c, new Bus(c));
            if (enableDiagonalBoard)
            {
                diagonalBoard = new DiagonalBoard(Buses);  //yes, hackey....
            }
            Enigmas = new List<BombeEnigma>();

            foreach (var map in mapping)
            {
                var bombeEnigma = new BombeEnigma(wheelTypes, reflectorType, map.StepsAheadOfKey, Buses[map.LeftChar], Buses[map.RightChar]);
                Enigmas.Add(bombeEnigma);
            }
            CurrentKeys = new char[wheelTypes.Length];
        }
示例#15
0
        public static MonthlySettings Random(int year, int month, MachineType t, ReflectorType r, bool compatibilityMode = false)
        {
            MonthlySettings result = new MonthlySettings();

            result.Month = month;
            result.Year  = year;

            for (int i = DateTime.DaysInMonth(year, month); i > 0; i--)
            {
                Settings s = Settings.Random(t);
                s.Day = i;
                result.DailySettings.Add(s);
            }

            foreach (var item in result.DailySettings)
            {
                item.ReflectorType = r;
                if (t == MachineType.M4K)
                {
                    if (r == ReflectorType.B_Dunn)
                    {
                        item.Rotors[0].Name = RotorName.Beta;
                        if (compatibilityMode)
                        {
                            item.Rotors[0].RingSetting = 0;
                        }
                    }
                    else
                    {
                        item.Rotors[0].Name = RotorName.Gamma;
                        if (compatibilityMode)
                        {
                            item.Rotors[0].RingSetting = 0;
                        }
                    }
                }
            }

            return(result);
        }
示例#16
0
        public Bombe(IEnumerable <MapEntry> mapping, char input, char entry,
                     WheelType[] wheelTypes, ReflectorType reflectorType, bool enableDiagonalBoard)
        {
            this.input = input;
            this.entry = entry;
            Buses      = new Dictionary <char, Bus>();
            for (char c = 'A'; c <= 'Z'; c++)
            {
                Buses.Add(c, new Bus(c));
            }
            if (enableDiagonalBoard)
            {
                diagonalBoard = new DiagonalBoard(Buses);  //yes, hackey....
            }
            Enigmas = new List <BombeEnigma>();

            foreach (var map in mapping)
            {
                var bombeEnigma = new BombeEnigma(wheelTypes, reflectorType, map.StepsAheadOfKey, Buses[map.LeftChar], Buses[map.RightChar]);
                Enigmas.Add(bombeEnigma);
            }
            CurrentKeys = new char[wheelTypes.Length];
        }
示例#17
0
 public static Reflector CreateReflector(ReflectorType reflectorType)
 {
     if (reflectorType == ReflectorType.A)
     {
         return(new Reflector_A());
     }
     if (reflectorType == ReflectorType.B)
     {
         return(new Reflector_B());
     }
     if (reflectorType == ReflectorType.C)
     {
         return(new Reflector_C());
     }
     if (reflectorType == ReflectorType.B_Thin)
     {
         return(new Reflector_B_Thin());
     }
     if (reflectorType == ReflectorType.C_Thin)
     {
         return(new Reflector_C_Thin());
     }
     throw new ArgumentException();
 }
示例#18
0
 private void ChangeState(ReflectorType newState)
 {
     currentState = newState;
     spriteHandler.ChangeSprite((int)newState);
     objectAttributes.ServerSetArticleName(newState + " Reflector");
 }
示例#19
0
        public static void SaveMonth(string folder, string title, int year, int month, MachineType t, ReflectorType r, bool compatibilityMode = false)
        {
            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }

            MonthlySettings s = MonthlySettings.Random(year, month, t, r, compatibilityMode);

            string fileName = MonthFileName(year, month, TEXT_FILE_EXTENSION);
            string filePath = Path.Combine(folder, fileName);

            SaveFile(filePath, Formatting.MonthlySettings(title, year, month, t, r, s.DailySettings));

            fileName = MonthFileName(year, month, XML_FILE_EXTENSION);
            filePath = Path.Combine(folder, fileName);
            s.Save(filePath);

            if (t != MachineType.M3)
            {
                SaveDigraphTable(year, month, folder);
            }
        }
示例#20
0
        public static void SaveYear(string folder, string title, int year, MachineType t, ReflectorType r, bool compatibilityMode = false)
        {
            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }

            for (int m = 1; m <= 12; m++)
            {
                string monthFolderName = MonthFolderName(year, m);
                string monthFolderPath = Path.Combine(folder, monthFolderName);

                if (!Directory.Exists(monthFolderPath))
                {
                    Directory.CreateDirectory(monthFolderPath);
                }

                MonthlySettings s = MonthlySettings.Random(year, m, t, r, compatibilityMode);
                string          serializedFileName = MonthFileName(year, m, ".xml");

                string serializedPath = Path.Combine(monthFolderPath, serializedFileName);
                s.Save(serializedPath);

                string textFileName = MonthFileName(year, m, ".txt");
                string textFilePath = Path.Combine(monthFolderPath, textFileName);
                SaveFile(textFilePath, Formatting.MonthlySettings(title, year, m, t, r, s.DailySettings));

                SaveDigraphTable(year, m, monthFolderPath);
            }

            SaveKeySheet(year, folder);
        }
 public Reflector this[ReflectorType refTyp]
 {
     get { return(this.FirstOrDefault(r => r.ReflectorType == refTyp)); }
 }
示例#22
0
 public Reflector(ReflectorType r)
     : base(r.ToString(), Constants.Reflectors[(int)r])
 {
     ReflectorType = r;
 }
示例#23
0
        void SetNewSettings()
        {
            rotorSets[0] = rotor1.Text;
            rotorSets[1] = rotor2.Text;
            rotorSets[2] = rotor3.Text;
            reflectorStr = refType.Text;
            for (int i = 0; i < rotorSets.Length; i++)
            {
                switch (rotorSets[i])
                {
                case ("I"):
                    wheels[i] = WheelType.I;
                    break;

                case ("II"):
                    wheels[i] = WheelType.II;
                    break;

                case ("III"):
                    wheels[i] = WheelType.III;
                    break;

                case ("IV"):
                    wheels[i] = WheelType.IV;
                    break;

                case ("V"):
                    wheels[i] = WheelType.V;
                    break;

                case ("VI"):
                    wheels[i] = WheelType.VI;
                    break;

                case ("VII"):
                    wheels[i] = WheelType.VII;
                    break;

                case ("VIII"):
                    wheels[i] = WheelType.VIII;
                    break;

                case ("Beta"):
                    wheels[i] = WheelType.Beta;
                    break;

                case ("Gamma"):
                    wheels[i] = WheelType.Gamma;
                    break;
                }
            }
            switch (refType.Text)
            {
            case ("A"):
                reflector = ReflectorType.A;
                break;

            case ("B"):
                reflector = ReflectorType.B;
                break;

            case ("C"):
                reflector = ReflectorType.C;
                break;

            case ("B_Thin"):
                reflector = ReflectorType.B_Thin;
                break;

            case ("C_Thin"):
                reflector = ReflectorType.C_Thin;
                break;
            }
            plugboardSets = newPlugboardSets;
            if (enigma != null)
            {
                enigma.SetWheelPositions(new char[] { rotorLab1.Text[0], rotorLab2.Text[0], rotorLab3.Text[0] });
            }
        }
示例#24
0
        public static string MonthlySettings(string title, int year, int month, MachineType t, ReflectorType r, bool compatibilityMode = false)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine();
            sb.AppendLine(TitleLine(t, title, year, month));
            sb.AppendLine();
            sb.AppendLine(DashedLine(t));
            sb.AppendLine(HeaderLine(t));
            sb.AppendLine(DashedLine(t));

            for (int i = DateTime.DaysInMonth(year, month); i >= 1; i--)
            {
                Settings s = Settings.Random(t);
                s.ReflectorType = r;
                if (t == MachineType.M4K)
                {
                    if (s.ReflectorType == ReflectorType.B_Dunn)
                    {
                        s.Rotors[0].Name = RotorName.Beta;

                        if (compatibilityMode)
                        {
                            s.Rotors[0].RingSetting = 0;
                        }
                    }
                    else
                    {
                        s.Rotors[0].Name = RotorName.Gamma;

                        if (compatibilityMode)
                        {
                            s.Rotors[0].RingSetting = 0;
                        }
                    }
                }

                sb.AppendLine(SettingLine(s, i));
            }

            sb.AppendLine(DashedLine(t));

            return(sb.ToString());
        }
示例#25
0
        public IReflector CreateReflector(ReflectorType type)
        {
            var aggregator = CreateEventAggregator();

            return(new Reflector(_reflectorConnections[type], type, aggregator, UtilityFactory));
        }
示例#26
0
 public void ChangeReflector(ReflectorType type)
 {
     _reflector = _componentFactory.CreateReflector(type);
     _settingsAggregator.PublishOnUIThread(_reflector);
 }
示例#27
0
 protected Reflector(ReflectorType reflectorType, int[] mapping)
 {
     this.ReflectorType = reflectorType;
     this.Mapping = mapping;
 }
示例#28
0
        public async void Process_GetCorrectOutput(char inputLetter, char expectedLetter, bool step, bool expectedStep, ReflectorType type)
        {
            // Arrange
            var utilityFactory = new UtilityFactory();
            var factory        = new ComponentFactory(utilityFactory);
            var reflector      = factory.CreateReflector(type);
            var inputValue     = CommonHelper.LetterToNumber(inputLetter);
            var signal         = await utilityFactory.CreateSignal(inputValue, step, SignalDirection.In);

            // Act
            var resultSignal = await reflector.Process(signal);

            var resultValue  = resultSignal.Value;
            var resultLetter = CommonHelper.NumberToLetter(resultValue);
            var resultStep   = resultSignal.Step;

            // Assert
            Assert.Equal(expectedLetter, resultLetter);
            Assert.Equal(expectedStep, resultStep);
        }
示例#29
0
 protected Reflector(ReflectorType reflectorType, int[] mapping)
 {
     this.ReflectorType = reflectorType;
     this.Mapping       = mapping;
 }
示例#30
0
        MapConfiguration GetMapFromData()
        {
            if (rotor1.SelectedIndex == -1 || rotor2.SelectedIndex == -1 || rotor3.SelectedIndex == -1 ||
                reflectorType.SelectedIndex == -1 || currentEntry.SelectedIndex == -1 || inputLetter.SelectedIndex == -1)
            {
                MessageBox.Show("Fill all the gaps!");
                return(null);
            }
            if (MapEntryList == null)
            {
                MessageBox.Show("Fill Map Entries!");
                return(null);
            }
            string[]    wheelStr = { rotor1.Text, rotor2.Text, rotor3.Text };
            WheelType[] wheels   = new WheelType[3];
            for (int i = 0; i < wheels.Length; i++)
            {
                switch (wheelStr[i])
                {
                case ("I"):
                    wheels[i] = WheelType.I;
                    break;

                case ("II"):
                    wheels[i] = WheelType.II;
                    break;

                case ("III"):
                    wheels[i] = WheelType.III;
                    break;

                case ("IV"):
                    wheels[i] = WheelType.IV;
                    break;

                case ("V"):
                    wheels[i] = WheelType.V;
                    break;

                case ("VI"):
                    wheels[i] = WheelType.VI;
                    break;

                case ("VII"):
                    wheels[i] = WheelType.VII;
                    break;

                case ("VIII"):
                    wheels[i] = WheelType.VIII;
                    break;

                case ("Beta"):
                    wheels[i] = WheelType.Beta;
                    break;

                case ("Gamma"):
                    wheels[i] = WheelType.Gamma;
                    break;
                }
            }
            ReflectorType refType = ReflectorType.A;

            switch (reflectorType.Text)
            {
            case ("A"):
                refType = ReflectorType.A;
                break;

            case ("B"):
                refType = ReflectorType.B;
                break;

            case ("C"):
                refType = ReflectorType.C;
                break;

            case ("B_Thin"):
                refType = ReflectorType.B_Thin;
                break;

            case ("C_Thin"):
                refType = ReflectorType.C_Thin;
                break;
            }
            bool enableDB = enableDiagonalBoard.Checked;
            char entry    = currentEntry.Text[0];
            char input    = inputLetter.Text[0];

            MapEntry[] mapEntries = entries.ToArray();
            return(new MapConfiguration(wheels, refType, enableDB, entry, input, mapEntries));
        }
示例#31
0
        public Settings(MachineType typ, ReflectorType refTyp, params object[] args)
            : this(typ, refTyp)
        {
            MachineType   = typ;
            ReflectorType = refTyp;

            if (MachineType == MachineType.M4K)
            {
                if (refTyp == ReflectorType.B_Dunn)
                {
                    Rotors.Add(new RotorSetting(RotorName.Beta, 0));
                }
                else
                {
                    Rotors.Add(new RotorSetting(RotorName.Gamma, 0));
                }
            }

            Rotors.Add(new RotorSetting(RotorName.I, 0));
            Rotors.Add(new RotorSetting(RotorName.II, 0));
            Rotors.Add(new RotorSetting(RotorName.III, 0));

            Plugs.Clear();

            List <RotorName> rotorNames   = new List <RotorName>();
            List <int>       ringSettings = new List <int>();
            List <string>    plugSettings = new List <string>();

            foreach (var item in args)
            {
                if (item is RotorName)
                {
                    rotorNames.Add((RotorName)item);
                    continue;
                }

                if (item is int)
                {
                    ringSettings.Add((int)item);
                    continue;
                }

                if (item is string)
                {
                    plugSettings.Add((string)item);
                    continue;
                }
            }

            for (int i = 0; i < rotorNames.Count; i++)
            {
                if (i <= Rotors.Count)
                {
                    Rotors[i].Name = rotorNames[i];
                    if (i <= ringSettings.Count)
                    {
                        Rotors[i].RingSetting = ringSettings[i];
                    }
                }
            }

            for (int i = 0; i < 10; i++)
            {
                if (i <= plugSettings.Count)
                {
                    Plugs.Add(new PlugSetting(plugSettings[i]));
                }
            }
        }
示例#32
0
        public static string MonthlySettings(string title, int year, int month, MachineType t, ReflectorType r, IEnumerable <Settings> settings)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine();
            sb.AppendLine(TitleLine(t, title, year, month));
            sb.AppendLine();
            sb.AppendLine(DashedLine(t));
            sb.AppendLine(HeaderLine(t));
            sb.AppendLine(DashedLine(t));

            foreach (var s in settings)
            {
                sb.AppendLine(SettingLine(s, s.Day));
            }
            sb.AppendLine(DashedLine(t));

            return(sb.ToString());
        }
示例#33
0
 public Settings(MachineType typ, ReflectorType refTyp)
     : this()
 {
     MachineType   = typ;
     ReflectorType = refTyp;
 }