コード例 #1
0
 private void Number_reg_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
 {
     try
     {
         if (!(Regex.IsMatch(Height.Text, @"^\d*$")))
         {
             Height.Clear();
             throw new Exception("Error!!! Неправильные символы");
         }
         else if (!(Regex.IsMatch(Weight.Text, @"^\d*$")))
         {
             Weight.Clear();
             throw new Exception("Error!!! Неправильные символы");
         }
         else if (!(Regex.IsMatch(Arms.Text, @"^\d*$")))
         {
             Arms.Clear();
             throw new Exception("Error!!! Неправильные символы");
         }
         else if (!(Regex.IsMatch(Waist.Text, @"^\d*$")))
         {
             Waist.Clear();
             throw new Exception("Error!!! Неправильные символы");
         }
         else if (!(Regex.IsMatch(Chest.Text, @"^\d*$")))
         {
             Chest.Clear();
             throw new Exception("Error!!! Неправильные символы");
         }
         else if (!(Regex.IsMatch(Leg.Text, @"^\d*$")))
         {
             Leg.Clear();
             throw new Exception("Error!!! Неправильные символы");
         }
         else if (!(Regex.IsMatch(Hip.Text, @"^\d*$")))
         {
             Hip.Clear();
             throw new Exception("Error!!! Неправильные символы");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
コード例 #2
0
        protected override void UpdateCards()
        {
            ClearChoices();
            Chest.Clear();
            Deck.Clear();

            foreach (Card c in Program.ActivePlayer.Chest)
            {
                if ((SpellMode && c is Spell) || (!SpellMode && c is Monster))
                {
                    if (Chest.ContainsKey(c.ID))
                    {
                        Chest[c.ID]++;
                    }
                    else
                    {
                        Chest.Add(c.ID, 1);
                    }
                }
            }

            foreach (Card c in Program.ActivePlayer.Deck)
            {
                if ((SpellMode && c is Spell) || (!SpellMode && c is Monster))
                {
                    if (Deck.ContainsKey(c.ID))
                    {
                        Deck[c.ID]++;
                    }
                    else
                    {
                        Deck.Add(c.ID, 1);
                    }
                }
            }

            if (Deck.Count == 0)
            {
                SetTexts(new[] { "There are no cards in your deck. Head to your chest to fill it up!" });
                return;
            }

            foreach (int id in Deck.Keys)
            {
                Card c;
                if (SpellMode)
                {
                    c = new Spell(id);
                }
                else
                {
                    c = new Monster(id);
                }
                Dictionary <string, Action> choices = new Dictionary <string, Action>();
                choices.Add("Add to Deck", delegate() { AddToDeck(c); UpdateCards(); });
                choices.Add("Add to Chest", delegate() { AddToChest(c); UpdateCards(); });
                choices.Add("Back", delegate() { Program.SceneManager.EndSubscene(); });


                int noInDeck = 0;
                if (Deck.ContainsKey(c.ID))
                {
                    noInDeck = Deck[c.ID];
                }
                int noInChest = 0;
                if (Chest.ContainsKey(c.ID))
                {
                    noInChest = Chest[c.ID];
                }

                AddChoice(
                    "(" + id.ToString("000") + ") " + c.Name + " [" + noInDeck + "-" + noInChest + "]",
                    delegate() {
                    Program.SceneManager.AddSubscene(
                        new TextScene(new CardSprite(c).Render() + "\nDeck: " + noInDeck + " Chest: " + noInChest, "What do you want to do?", choices)
                        );
                }
                    );
            }

            AddChoice("Back", delegate() { Program.SceneManager.EndSubscene(); });
        }