Exemplo n.º 1
0
        public RacesForm(string gameName)
        {
            InitializeComponent();

            _gameName = gameName;
            _races = new List<Race>();

            _saved = true;

            // Load stats and modifier type list boxes
            string[] files;

            try
            {
                files = Directory.GetFiles(Application.StartupPath + @"\Games\" + _gameName + @"\stats");

                _stats = new List<Stat>();

                foreach (string file in files)
                    LoadStat(file);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Error loading stats");
            }

            _saved = true;

            LoadModifiersAndWRsListBoxes();

            files = Directory.GetFiles(Application.StartupPath + @"\Games\" + _gameName + @"\races");

            foreach (string file in files)
            {
                Race race = GlobalFunctions.LoadRace(file);
                if (race != null)
                {
                    _races.Add(race);
                    cbRaces.Items.Add(race.Name);
                }
            }

            _race = new Race();
        }
Exemplo n.º 2
0
        private void SetupForNewEntry()
        {
            _race = new Race();

            // Clear controls
            txtRaceName.Text = "";
            txtRaceDescription.Text = "";
            txtModifierAmount.Text = "";
            txtWRAmount.Text = "";

            LoadModifiersAndWRsListBoxes();

            lstStats.Items.Clear();
            lstModifierTypes.Items.Clear();

            btnAddWR.Enabled = false;
            btnRemoveWR.Enabled = false;
            btnAddModifier.Enabled = false;
            btnRemoveModifier.Enabled = false;

            _saved = false;
        }
Exemplo n.º 3
0
        private void cbRaces_SelectedIndexChanged(object sender, EventArgs e)
        {
            _race = _races[cbRaces.SelectedIndex];

            txtRaceName.Text = _race.Name;
            txtRaceDescription.Text = _race.Description;

            LoadModifiersAndWRsListBoxes();

            int val;

            lstStatModifiers.Items.Clear();

            foreach (Stat stat in _stats)
            {
                val = _race.GetStatModifier(stat.Abbreviation);
                if (val != 0)
                {
                    lstStatModifiers.Items.Add(stat.Name + ": " + val.ToString());

                    // remove from stat box
                    lstStats.Items.RemoveAt(lstStats.Items.IndexOf(stat.Name));
                }
            }

            lstWRs.Items.Clear();

            // iterate through values in the enum
            foreach (ModifierType mod in Enum.GetValues(typeof(ModifierType)))
            {
                val = _race.CheckResistnance(mod);

                if (val > 0)
                    lstWRs.Items.Add("Resistance - " + mod.ToString() + ": " + val);
            }

            foreach (ModifierType mod in Enum.GetValues(typeof(ModifierType)))
            {
                val = _race.CheckWeakness(mod);

                if (val > 0)
                    lstWRs.Items.Add("Weakness - " + mod.ToString() + ": " + val);
            }

            btnAdd.Enabled = false;
            btnUpdate.Enabled = true;
            btnDelete.Enabled = true;
            btnNew.Enabled = true;
        }