Пример #1
0
        private void btnDone_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (GameInfo == null)
                {
                    GameInfo = new GameInfo()
                    {
                        Region = _region
                    }
                }
                ;
                var trimmedData = data.Take(currentPic.Clamp(0, _secretLength)).ToArray();

                switch (Mode)
                {
                case SecretType.Game:
                    GameSecret gs = new GameSecret();
                    gs.Load(trimmedData, _region);
                    gs.UpdateGameInfo(GameInfo);
                    break;

                case SecretType.Ring:
                    RingSecret rs = new RingSecret();
                    rs.Load(trimmedData, _region);
                    rs.UpdateGameInfo(GameInfo, chkAppendRings.IsChecked == true);
                    break;

                case SecretType.Memory:
                    MemorySecret ms = new MemorySecret();
                    ms.Load(trimmedData, _region);
                    // Now what?
                    break;
                }

                this.Close();
            }
            catch (SecretException ex)
            {
                MessageBox.Show(ex.Message, "Invalid Secret", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Пример #2
0
        protected void OnButtonOkPressed(object sender, EventArgs e)
        {
            try
            {
                if (GameInfo == null)
                {
                    GameInfo = new GameInfo();
                }
                var trimmedData = data.Take(currentPic.Clamp(0, _secretLength)).ToArray();

                switch (Mode)
                {
                case SecretType.Game:
                    GameSecret gs = new GameSecret(_region);
                    gs.Load(trimmedData);
                    gs.UpdateGameInfo(GameInfo);
                    break;

                case SecretType.Ring:
                    RingSecret rs = new RingSecret(_region);
                    rs.Load(trimmedData);
                    rs.UpdateGameInfo(GameInfo, chkAppendRings.Active);
                    break;

                case SecretType.Memory:
                    MemorySecret ms = new MemorySecret(_region);
                    ms.Load(trimmedData);
                    // Now what?
                    break;
                }

                this.Respond(ResponseType.Ok);
            }
            catch (InvalidSecretException ex)
            {
                MessageBox.Show(ex.Message, "Invalid Secret", ButtonsType.Ok, MessageType.Error);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", ButtonsType.Ok, MessageType.Error);
            }
        }
Пример #3
0
        public void UpdateGameInfo()
        {
            var info = new GameInfo()
            {
                Region = GameRegion.US,
                GameID = 14129,
                Rings  = Rings.PowerRingL1
            };

            // Mismatched region
            var s1 = new RingSecret()
            {
                Region = GameRegion.JP,
                GameID = 14129,
                Rings  = Rings.DoubleEdgeRing | Rings.ProtectionRing
            };

            // Mismatched game ID
            var s2 = new RingSecret()
            {
                Region = GameRegion.US,
                GameID = 1,
                Rings  = Rings.DoubleEdgeRing | Rings.ProtectionRing
            };

            var s3 = new RingSecret()
            {
                Region = GameRegion.US,
                GameID = 14129,
                Rings  = Rings.DoubleEdgeRing | Rings.ProtectionRing
            };

            GameSecretTest.DesiredSecret.UpdateGameInfo(info);

            Assert.Throws <SecretException>(() => s1.UpdateGameInfo(info, true));
            Assert.Throws <SecretException>(() => s2.UpdateGameInfo(info, true));
            Assert.DoesNotThrow(() => s3.UpdateGameInfo(info, true));
            Assert.AreEqual(GameInfoTest.DesiredInfo, info);
        }