示例#1
0
        public void AddRace(Race race)
        {
            if (race == null) throw new ArgumentNullException("race");

            if (!_races.Contains(race))
            {
                _races.Add(race);
                if (this.RaceAdded != null)
                    this.RaceAdded(this, new RaceAddedEventArgs(race));
            }
        }
示例#2
0
        public void Bonus(Race race)
        {
            ObservableCollection<AbilityBonusViewModel> list = AbilityDBConverter.ConvertToVM(race.AbiBonus);
            foreach (AbilityBonusViewModel abvm in list)
            {
                if (abvm.SelectedAbility.Description == "Strength")
                {
                    Str.Value += abvm.SelectedBonus;
                }
                if (abvm.SelectedAbility.Description == "Dexterity")
                {
                    Dex.Value += abvm.SelectedBonus;
                }
                if (abvm.SelectedAbility.Description == "Constitution")
                {
                    Con.Value += abvm.SelectedBonus;
                }
                if (abvm.SelectedAbility.Description == "Intelligence")
                {
                    Int.Value += abvm.SelectedBonus;
                }
                if (abvm.SelectedAbility.Description == "Wisdom")
                {
                    Wis.Value += abvm.SelectedBonus;
                }
                if (abvm.SelectedAbility.Description == "Charisma")
                {
                    Chr.Value += abvm.SelectedBonus;
                }
                if (abvm.SelectedAbility.Description == "All")
                {
                    Str.Value += abvm.SelectedBonus;
                    Dex.Value += abvm.SelectedBonus;
                    Con.Value += abvm.SelectedBonus;
                    Int.Value += abvm.SelectedBonus;
                    Wis.Value += abvm.SelectedBonus;
                    Chr.Value += abvm.SelectedBonus;

                }
            }
        }
示例#3
0
        public Character()
        {
            
            _name = "Sarah Brown";
            _classes = new ObservableCollection<CharacterClass> {new Bard(), new Barbarian()};
            XP = 6500;
            _background = Background.Sage;
            _playerName = "Meghan";
            _alignment = Alignment.LawfulGood;
            _class = new Bard();
            _str = new Ability("Strength") {Value = 15};
            _dex = new Ability("Dexterity") {Value = 14};
            _con = new Ability("Constitution") { Value = 13 };
            _int = new Ability("Intelligence") { Value = 12 };
            _wis = new Ability("Wisdom") { Value = 10 };
            _chr = new Ability("Charisma") { Value = 8 };

            Abilities = new ObservableCollection<Ability>
            {
                Str, Dex, Con, Int, Wis, Chr
            };
            
            //Race = Subraces.Human;
            Race = new Race
            {
                Name = "Human",
                RaceEnum = RaceEnum.Human,
                Darkvision = "No",
                Size = "Medium",
                Speed = 30
            };
        }
示例#4
0
        public static Race CreateRace(string query)
        {
            Race newRace = new Race();
            string dbConnectionString = @"Data Source=FreeDataBase.sqlite;Version=3;";
            SQLiteConnection con = new SQLiteConnection(dbConnectionString);
            con.Open();
            string q = String.Format("SELECT * FROM Race WHERE Name = '{0}'", query);
            string mainrace = string.Empty;

            SQLiteCommand command = new SQLiteCommand(q, con);
            command.ExecuteNonQuery();
            SQLiteDataReader dr = command.ExecuteReader();


            while (dr.Read())
            {

                for (int ii = 0; ii < 11; ii++)
                {
                    if (dr.IsDBNull(ii) == false)
                    {
                        switch (ii)
                        {
                            case 0:
                                //Name
                                newRace.Name = dr.GetString(ii);
                                break;
                            case 1:
                                //Ability Bonus
                                newRace.AbiBonus = dr.GetString(ii);
                                newRace.ConvertedBonuses = DBConverter.ConvertToViewModel(dr.GetString(ii));
                                break;
                            case 2:
                                //Size
                                newRace.Size = dr.GetString(ii);
                                break;
                            case 3:
                                //Speed
                                newRace.Speed = dr.GetInt32(ii);
                                break;
                            case 4:
                                //Darkvision
                                newRace.Darkvision = dr.GetString(ii);
                                break;
                            case 5:
                                //WEAPON Proficiencies
                                if (dr.GetInt64(ii) == 0)
                                {
                                    newRace.WeaponProficiencies.Add(new EnumBase(WeaponProficiency.None));
                                }
                                WeaponProficiency allWP = (WeaponProficiency)dr.GetInt64(ii);
                                foreach (WeaponProficiency wp in allWP.GetUniqueFlags())
                                {
                                    newRace.WeaponProficiencies.Add(new EnumBase(wp));
                                }

                                break;
                            case 6:
                                //TOOL Proficiencies
                                if (dr.GetInt64(ii) == 0)
                                {
                                    newRace.ToolProficiencies.Add(new EnumBase(ToolProficiency.None));
                                }
                                ToolProficiency allTP = (ToolProficiency) dr.GetInt64(ii);
                                foreach (ToolProficiency tp in allTP.GetUniqueFlags())
                                {
                                    newRace.ToolProficiencies.Add(new EnumBase(tp));
                                }
                                break;
                            case 7:
                                //Languages
                                if (dr.GetInt32(ii) == 0) newRace.Languages.Add(new EnumBase(Language.None));
                                Language allLang = (Language)dr.GetInt32(ii);
                                foreach (Language l in allLang.GetUniqueFlags())
                                    newRace.Languages.Add(new EnumBase(l));
                                break;
                            case 8:
                                //Parent Race
                                newRace.ParentRace = dr.GetString(ii);
                                break;
                            case 9:
                                //Skill Proficiencies
                                if (dr.GetInt32(ii) == 0) newRace.SkillProficiencies.Add(new EnumBase(SkillProficiency.None));
                                SkillProficiency allSkill = (SkillProficiency)dr.GetInt32(ii);
                                foreach (SkillProficiency cs in allSkill.GetUniqueFlags()) newRace.SkillProficiencies.Add(new EnumBase(cs));
                                break;
                            case 10:
                                //Armor Proficiencies
                                if (dr.GetInt32(ii) == 0) newRace.ArmorProficiencies.Add(new EnumBase(ArmorProficiency.None));
                                ArmorProficiency allAP = (ArmorProficiency)dr.GetInt32(ii);
                                foreach (ArmorProficiency ap in allAP.GetUniqueFlags()) newRace.ArmorProficiencies.Add(new EnumBase(ap));
                                break;
                        }

                    }
                }
            }
            dr.Close();

            if (newRace.Name != newRace.ParentRace)
            {
                string mainraceQuery = String.Format("SELECT * FROM RacialTraits WHERE Race = '{0}'", newRace.ParentRace);
                SQLiteCommand mainRaceCommand = new SQLiteCommand(mainraceQuery, con);
                mainRaceCommand.ExecuteNonQuery();
                SQLiteDataReader mainRaceDR = mainRaceCommand.ExecuteReader();

                while (mainRaceDR.Read())
                {
                    newRace.RacialTraits.Add(new Feature
                    {
                        Name = mainRaceDR.GetString(1),
                        Explanation = mainRaceDR.GetString(2)
                    });


                }
            }
            string subraceQuery = String.Format("SELECT * FROM RacialTraits WHERE Race = '{0}'", query);
            
            SQLiteCommand com = new SQLiteCommand(subraceQuery, con);
            com.ExecuteNonQuery();
            SQLiteDataReader drr = com.ExecuteReader();

            while (drr.Read())
            {
                newRace.RacialTraits.Add(new Feature
                {
                    Name = drr.GetString(1),
                    Explanation = drr.GetString(2)
                });
                    
                
            }
            return newRace;
        }
示例#5
0
 public bool ContainsRace(Race race)
 {
     if (race == null)
         throw new ArgumentNullException("race");
     return _races.Contains(race);
 }
 public RaceAddedEventArgs(Race newRace)
 {
     this.NewRace = newRace;
 }
 public void AssignAbilityBonus(Race PR)
 {
     //MessageBox.Show(PR.AbiBonus);
     if (AbilityBonusViewModelList.Count > 0) AbilityBonusViewModelList.Clear();
     AbilityBonusViewModel abvm = DBConverter.ConvertToAbilityBonusView(PR.AbiBonus);
     AbilityBonusViewModelList.Add(abvm);
 }
        public void ParentSelected(object obj)
        {
            
            PR = obj as Race;
            if (PR != ParentRaceList[0])
            {
                SelectedParentRace = PR;
                Speed = PR.Speed;
                Size = Utility.ParseEnum<Size>(PR.Size);
                Darkvision = PR.Darkvision;
                AssignAbilityBonus(PR);
                //MessageBox.Show(PR.AbiBonus);


                SelectedWeaponProficiencies = PR.WeaponProficiencies;
                WeaponProficiencyViewModel = new WeaponProficiencyViewModel(SelectedWeaponProficiencies);
                SelectedArmorProficiencies = PR.ArmorProficiencies;
                ArmorProficiencyViewModel = new ArmorProficiencyViewModel(SelectedArmorProficiencies);
                SelectedToolProficiencies = PR.ToolProficiencies;
                ToolProficiencyViewModel = new ToolProficiencyViewModel(SelectedToolProficiencies);
                SelectedSkillProficiencies = PR.SkillProficiencies;
                SkillProficiencyViewModel = new SkillProficiencyViewModel(SelectedSkillProficiencies);
                SelectedLanguageProficiencies = PR.Languages;
                LanguageProficiencyViewModel = new LanguageProficiencyViewModel(SelectedLanguageProficiencies);
            }

            else resetStuff();
        }
 // CONSTRUCTORS
 public CharacterCreationViewModel()
 {
     TestCommand = new RelayCommand(Test);
     NewCharacter = new Character();
     //Strength = NewCharacter.Str.Value;
     //Dexterity = NewCharacter.Dex.Value;
     //Constitution = NewCharacter.Con.Value;
     //Intelligence = NewCharacter.Int.Value;
     //Wisdom = NewCharacter.Wis.Value;
     //Charisma = NewCharacter.Chr.Value;
     RaceViewModelTest = new RaceViewModelTest();
     SelectedRace = new Race();
     RaceViewModelTest.TestName = "Changed Name";
     //PropertyChanged += CharacterCreationViewModel_PropertyChanged;
     PropertyChanging +=CharacterCreationViewModel_PropertyChanging;
 }