Example #1
0
        public SaintModel(Saint saint, SaintBitmask bitmask)
        {
            Name = saint.ShortName;
            Tip  = StringHelper.WordWrap(saint.Description + Environment.NewLine + Environment.NewLine + saint.Clue, 70);

            _id      = saint.Id;
            _bitmask = bitmask;
        }
Example #2
0
        public static Saint getSaints(DateTime date)
        {
            var saint            = new Saint();
            var saintTransformer = new SaintTransformer();

            using (var dbconn = new SqlConnection(ConfigurationManager.ConnectionStrings["dbconn"].ConnectionString))
            {
                if (dbconn.State == ConnectionState.Open)
                {
                    dbconn.Close();
                }
                dbconn.Open();

                using (var cmd = new SqlCommand("spGetSaintOfTheDay", dbconn))
                {
                    try
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.AddWithValue("@dateofFeast", date.ToString("MMMM d, yyyy"));

                        var reader = cmd.ExecuteReader();

                        while (reader.Read())
                        {
                            saint = saintTransformer.Transform(reader);
                        }
                    }
                    catch (Exception)
                    {
                        // Ignored
                    }
                }
            }

            return(saint);
        }
Example #3
0
 public SaintItem(Saint saint)
 {
     Saint = saint;
 }
        private void InitCommands()
        {
            WatchSaintCommand = new RelayCommand(x =>
            {
                WatchSaintViewModel watchSaint = new WatchSaintViewModel();
                watchSaint.SelectedSaint       = Saints.Get((int)x);
                factory.GetWindow(watchSaint, "WatchSaintView").ShowDialog();
            });
            SaveCommand = new RelayCommand(x =>
            {
                dataService.Save(Saints);
            });
            LoadCommand = new RelayCommand(x =>
            {
                Repository <Saint> loaded = dataService.Load();

                Saints.Data.Clear();
                foreach (var i in loaded.Data)
                {
                    saints.Data.Add(i);
                }
                SaintsView.Refresh();
            });
            StartupLoadCommand = new RelayCommand(x =>
            {
                Repository <Saint> loaded = dataService.StartupLoad();
                foreach (var i in loaded.Data)
                {
                    saints.Data.Add(i);
                }
                SaintsView.Refresh();
            });
            AddCommand = new RelayCommand(x =>
            {
                Saint saint     = new Saint();
                saint.ImagePath = @"../images/default.png";
                saint.Name      = "[Name]";
                saint.Id        = (Saints.Data.Max(b => b.Id)) + 1;
                Saints.Add(saint);
            });
            RemoveCommand = new RelayCommand(x =>
            {
                Saints.Delete((int)x);
            });
            GetSaints = new RelayCommand(x =>
            {
                foreach (Saint saint in Saint.GetSaints())
                {
                    Saints.Add(saint);
                }
                Notify();
            });
            EditImageCommand = new RelayCommand(x =>
            {
                OpenFileDialog dlg = new OpenFileDialog();
                dlg.Filter         = "Image Files|*.jpg;*.jpeg;*.png;*.gif;*.tif;...";
                var result         = dlg.ShowDialog();

                if (result == true)
                {
                    Saint saint     = Saints.Get((int)x);
                    saint.ImagePath = dlg.FileName;
                }
            });
            CloseWindowCommand = new RelayCommand(x =>
            {
                dataService.ClosingSave(Saints);
                if (x is Window window)
                {
                    window.Close();
                }
            });
            ChangeThemeCommand = new RelayCommand(x =>
            {
                if ((string)x == "Dark")
                {
                    foreach (var resource in Theme.GetLightTheme())
                    {
                        Application.Current.Resources.MergedDictionaries.Remove(resource);
                    }
                    foreach (var resource in Theme.GetDarkTheme())
                    {
                        Application.Current.Resources.MergedDictionaries.Add(resource);
                    }
                }
                else
                {
                    foreach (var resource in Theme.GetDarkTheme())
                    {
                        Application.Current.Resources.MergedDictionaries.Remove(resource);
                    }
                    foreach (var resource in Theme.GetLightTheme())
                    {
                        Application.Current.Resources.MergedDictionaries.Add(resource);
                    }
                }
            });
            SortCommand = new RelayCommand(x =>
            {
                SaintsView.SortDescriptions.Clear();
                SaintsView.SortDescriptions.Add(new SortDescription(x.ToString(), ListSortDirection.Ascending));
            });
            ChangeLanguageCommand = new RelayCommand(x =>
            {
                var ru  = Language.GetRussian();
                var eng = Language.GetEnglish();
                if ((string)x == "eng")
                {
                    Application.Current.Resources.MergedDictionaries.Remove(ru);
                    Application.Current.Resources.MergedDictionaries.Add(eng);
                }
                else
                {
                    Application.Current.Resources.MergedDictionaries.Remove(eng);
                    Application.Current.Resources.MergedDictionaries.Add(ru);
                }
            });
        }
Example #5
0
        public void BeastSetClass(Unit enemy)
        {
            var rng         = new Random();
            int beastNumber = rng.Next(0, 27);

            if (beastNumber == 0 || beastNumber == 1 || beastNumber == 2 ||
                beastNumber == 3 || beastNumber == 4 || beastNumber == 5)
            {
                Beast beast = new Beast();
                beast.StatIncrement(enemy, beast);
                beast.RarityRng(enemy);
                BeastSpellRepository repos = new BeastSpellRepository(enemy);
                repos.SpellRepositoryInitilization(enemy, repos);
            }

            if (beastNumber == 6 || beastNumber == 7 || beastNumber == 8 ||
                beastNumber == 9 || beastNumber == 10)
            {
                Reptile reptile = new Reptile();
                reptile.StatIncrement(enemy, reptile);
                reptile.RarityRng(enemy);
                ReptileSpellRepository repos = new ReptileSpellRepository(enemy);
                repos.SpellRepositoryInitilization(enemy, repos);
            }

            if (beastNumber == 19 || beastNumber == 20)
            {
                Wyrm wyrm = new Wyrm();
                wyrm.StatIncrement(enemy, wyrm);
                wyrm.RarityRng(enemy);
                WyrmSpellRepository repos = new WyrmSpellRepository(enemy);
                repos.SpellRepositoryInitilization(enemy, repos);
            }

            if (beastNumber == 21 || beastNumber == 22)
            {
                Giant giant = new Giant();
                giant.StatIncrement(enemy, giant);
                giant.RarityRng(enemy);
                GiantSpellRepository repos = new GiantSpellRepository(enemy);
                repos.SpellRepositoryInitilization(enemy, repos);
            }

            if (beastNumber == 11 || beastNumber == 12 || beastNumber == 13 ||
                beastNumber == 14)
            {
                Zombie zombie = new Zombie();
                zombie.StatIncrement(enemy, zombie);
                zombie.RarityRng(enemy);
                ZombieSpellRepository repos = new ZombieSpellRepository(enemy);
                repos.SpellRepositoryInitilization(enemy, repos);
            }

            if (beastNumber == 23 || beastNumber == 24)
            {
                Gryphon gryphon = new Gryphon();
                gryphon.StatIncrement(enemy, gryphon);
                gryphon.RarityRng(enemy);
                GryphonSpellRepository repos = new GryphonSpellRepository(enemy);
                repos.SpellRepositoryInitilization(enemy, repos);
            }

            if (beastNumber == 15 || beastNumber == 16 || beastNumber == 17 ||
                beastNumber == 18)
            {
                Skeleton skeleton = new Skeleton();
                skeleton.StatIncrement(enemy, skeleton);
                skeleton.RarityRng(enemy);
                SkeletonSpellRepository repos = new SkeletonSpellRepository(enemy);
                repos.SpellRepositoryInitilization(enemy, repos);
            }

            if (beastNumber == 25)
            {
                Saint saint = new Saint();
                saint.StatIncrement(enemy, saint);
                saint.RarityRng(enemy);
                SaintSpellRepository repos = new SaintSpellRepository(enemy);
                repos.SpellRepositoryInitilization(enemy, repos);
            }

            if (beastNumber == 26)
            {
                Demon demon = new Demon();
                demon.StatIncrement(enemy, demon);
                demon.RarityRng(enemy);
                DemonSpellRepository repos = new DemonSpellRepository(enemy);
                repos.SpellRepositoryInitilization(enemy, repos);
            }
        }