Basic spell list and character model functionality tested? Maybe.
Signed-off-by: Melissa Avery-Weir <averymd@irrsinn.net>
This commit is contained in:
@@ -1,7 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
||||
7
d20 SRD Spell Lists Tests/AppData/TestUserSpellList.xml
Normal file
7
d20 SRD Spell Lists Tests/AppData/TestUserSpellList.xml
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<spells>
|
||||
<spell>
|
||||
<name>Dummy Spell</name>
|
||||
<short_description>A short description.</short_description>
|
||||
</spell>
|
||||
</spells>
|
||||
188
d20 SRD Spell Lists Tests/CharacterTests.cs
Normal file
188
d20 SRD Spell Lists Tests/CharacterTests.cs
Normal file
@@ -0,0 +1,188 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Xunit;
|
||||
using d20_SRD_Spell_Lists.Models;
|
||||
using System.Xml.Linq;
|
||||
using System.IO;
|
||||
|
||||
namespace d20_SRD_Spell_Lists_Tests {
|
||||
public class CharacterTests {
|
||||
|
||||
private string masterSpellList;
|
||||
private string userSpellList;
|
||||
private string charFile;
|
||||
|
||||
public CharacterTests() {
|
||||
masterSpellList = "AppData/MasterSpellList.xml";
|
||||
userSpellList = "AppData/UserSpellList.xml";
|
||||
charFile = "AppData/TestCharacter.xml";
|
||||
string defaultUserSpells = "<?xml version=\"1.0\" encoding=\"utf-8\" ?><spells><spell><name>Dummy Spell</name><short_description>A short description.</short_description></spell></spells>";
|
||||
using (StreamWriter outfile = new StreamWriter(userSpellList)) {
|
||||
outfile.Write(defaultUserSpells);
|
||||
}
|
||||
|
||||
string defaultCharSpells = "<?xml version=\"1.0\" encoding=\"utf-8\" ?><character><name>Thomasina</name><class>Cleric</class><spells><spell><name>Dummy Character Spell</name><short_description>A short description.</short_description></spell></spells></character>";
|
||||
using (StreamWriter outfile = new StreamWriter(charFile)) {
|
||||
outfile.Write(defaultCharSpells);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void loadingValidCharacterShouldResultInOneCharacterSpell() {
|
||||
Character c = new Character(charFile);
|
||||
SpellSet s = new SpellSet(masterSpellList, userSpellList, c);
|
||||
Assert.Equal<int>(1, s.characterSpellCount());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void loadingValidCharacterShouldLoadAName() {
|
||||
Character c = new Character(charFile);
|
||||
Assert.Equal<string>("Thomasina", c.Name);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void loadingValidCharacterShouldLoadAClass() {
|
||||
Character c = new Character(charFile);
|
||||
Assert.Equal<string>("Cleric", c.CharacterClass.ToString());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void useCorrectAttributeModifiers() {
|
||||
Character c = new Character(charFile);
|
||||
|
||||
c.Wisdom = 8;
|
||||
Assert.Equal<int>(-1, c.WisdomMod);
|
||||
|
||||
c.Wisdom = 9;
|
||||
Assert.Equal<int>(-1, c.WisdomMod);
|
||||
|
||||
c.Wisdom = 10;
|
||||
Assert.Equal<int>(0, c.WisdomMod);
|
||||
|
||||
c.Wisdom = 11;
|
||||
Assert.Equal<int>(0, c.WisdomMod);
|
||||
|
||||
c.Wisdom = 22;
|
||||
Assert.Equal<int>(6, c.WisdomMod);
|
||||
|
||||
c.Wisdom = 17;
|
||||
Assert.Equal<int>(3, c.WisdomMod);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void useCorrectBardSpellCastingAttribute() {
|
||||
Character c = new Character(charFile);
|
||||
c.Wisdom = 22;
|
||||
c.Charisma = 19;
|
||||
c.Intelligence = 17;
|
||||
|
||||
c.CharacterClass = Character.SpellCastingClasses.Bard;
|
||||
Assert.Equal<int>(c.Charisma, c.SpellCastingAttribute);
|
||||
Assert.Equal<int>(c.CharismaMod, c.SpellCastingAttributeMod);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void useCorrectClericSpellCastingAttribute() {
|
||||
Character c = new Character(charFile);
|
||||
c.Wisdom = 22;
|
||||
c.Charisma = 19;
|
||||
c.Intelligence = 17;
|
||||
|
||||
c.CharacterClass = Character.SpellCastingClasses.Cleric;
|
||||
Assert.Equal<int>(c.Wisdom, c.SpellCastingAttribute);
|
||||
Assert.Equal<int>(c.WisdomMod, c.SpellCastingAttributeMod);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void useCorrectDruidSpellCastingAttribute() {
|
||||
Character c = new Character(charFile);
|
||||
c.Wisdom = 22;
|
||||
c.Charisma = 19;
|
||||
c.Intelligence = 17;
|
||||
|
||||
c.CharacterClass = Character.SpellCastingClasses.Druid;
|
||||
Assert.Equal<int>(c.Wisdom, c.SpellCastingAttribute);
|
||||
Assert.Equal<int>(c.WisdomMod, c.SpellCastingAttributeMod);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void useCorrectPaladinSpellCastingAttribute() {
|
||||
Character c = new Character(charFile);
|
||||
c.Wisdom = 22;
|
||||
c.Charisma = 19;
|
||||
c.Intelligence = 17;
|
||||
|
||||
c.CharacterClass = Character.SpellCastingClasses.Paladin;
|
||||
Assert.Equal<int>(c.Wisdom, c.SpellCastingAttribute);
|
||||
Assert.Equal<int>(c.WisdomMod, c.SpellCastingAttributeMod);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void useCorrectRangerSpellCastingAttribute() {
|
||||
Character c = new Character(charFile);
|
||||
c.Wisdom = 22;
|
||||
c.Charisma = 19;
|
||||
c.Intelligence = 17;
|
||||
|
||||
c.CharacterClass = Character.SpellCastingClasses.Ranger;
|
||||
Assert.Equal<int>(c.Wisdom, c.SpellCastingAttribute);
|
||||
Assert.Equal<int>(c.WisdomMod, c.SpellCastingAttributeMod);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void useCorrectSorcererSpellCastingAttribute() {
|
||||
Character c = new Character(charFile);
|
||||
c.Wisdom = 22;
|
||||
c.Charisma = 19;
|
||||
c.Intelligence = 17;
|
||||
|
||||
c.CharacterClass = Character.SpellCastingClasses.Sorcerer;
|
||||
Assert.Equal<int>(c.Charisma, c.SpellCastingAttribute);
|
||||
Assert.Equal<int>(c.CharismaMod, c.SpellCastingAttributeMod);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void useCorrectWizardSpellCastingAttribute() {
|
||||
Character c = new Character(charFile);
|
||||
c.Wisdom = 22;
|
||||
c.Charisma = 19;
|
||||
c.Intelligence = 17;
|
||||
|
||||
c.CharacterClass = Character.SpellCastingClasses.Wizard;
|
||||
Assert.Equal<int>(c.Intelligence, c.SpellCastingAttribute);
|
||||
Assert.Equal<int>(c.IntelligenceMod, c.SpellCastingAttributeMod);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void useCorrectBonusSpells() {
|
||||
Character c = new Character(charFile);
|
||||
c.Wisdom = 22;
|
||||
c.Charisma = 13;
|
||||
c.Intelligence = 17;
|
||||
|
||||
Assert.Equal<int>(10, c.BonusSpells.Length);
|
||||
|
||||
c.CharacterClass = Character.SpellCastingClasses.Wizard;
|
||||
Assert.Equal<int>(0, c.BonusSpells[0]);
|
||||
Assert.Equal<int>(1, c.BonusSpells[1]);
|
||||
Assert.Equal<int>(1, c.BonusSpells[3]);
|
||||
Assert.Equal<int>(0, c.BonusSpells[4]);
|
||||
|
||||
c.CharacterClass = Character.SpellCastingClasses.Bard;
|
||||
Assert.Equal<int>(0, c.BonusSpells[0]);
|
||||
Assert.Equal<int>(1, c.BonusSpells[1]);
|
||||
Assert.Equal<int>(0, c.BonusSpells[2]);
|
||||
Assert.Equal<int>(0, c.BonusSpells[4]);
|
||||
|
||||
c.CharacterClass = Character.SpellCastingClasses.Cleric;
|
||||
Assert.Equal<int>(0, c.BonusSpells[0]);
|
||||
Assert.Equal<int>(2, c.BonusSpells[1]);
|
||||
Assert.Equal<int>(2, c.BonusSpells[2]);
|
||||
Assert.Equal<int>(1, c.BonusSpells[4]);
|
||||
Assert.Equal<int>(1, c.BonusSpells[6]);
|
||||
Assert.Equal<int>(0, c.BonusSpells[7]);
|
||||
}
|
||||
}
|
||||
}
|
||||
36
d20 SRD Spell Lists Tests/Properties/AssemblyInfo.cs
Normal file
36
d20 SRD Spell Lists Tests/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("d20 SRD Spell Lists Tests")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Microsoft")]
|
||||
[assembly: AssemblyProduct("d20 SRD Spell Lists Tests")]
|
||||
[assembly: AssemblyCopyright("Copyright © Microsoft 2011")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("51812758-0360-49b9-b127-71fe700ce8a5")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
157
d20 SRD Spell Lists Tests/SpellsTests.cs
Normal file
157
d20 SRD Spell Lists Tests/SpellsTests.cs
Normal file
@@ -0,0 +1,157 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Xunit;
|
||||
using d20_SRD_Spell_Lists.Models;
|
||||
using System.Xml.Linq;
|
||||
using System.IO;
|
||||
|
||||
namespace d20_SRD_Spell_Lists_Tests
|
||||
{
|
||||
public class SpellsTests
|
||||
{
|
||||
private string masterSpellList;
|
||||
private string userSpellList;
|
||||
private string charFile;
|
||||
|
||||
public SpellsTests() {
|
||||
masterSpellList = "AppData/MasterSpellList.xml";
|
||||
userSpellList = "AppData/UserSpellList.xml";
|
||||
charFile = "AppData/TestCharacter.xml";
|
||||
string defaultUserSpells = "<?xml version=\"1.0\" encoding=\"utf-8\" ?><spells><spell><name>Dummy Spell</name><short_description>A short description.</short_description></spell></spells>";
|
||||
using (StreamWriter outfile = new StreamWriter(userSpellList)) {
|
||||
outfile.Write(defaultUserSpells);
|
||||
}
|
||||
|
||||
string defaultCharSpells = "<?xml version=\"1.0\" encoding=\"utf-8\" ?><character><spells><spell><name>Dummy Character Spell</name><short_description>A short description.</short_description></spell></spells></character>";
|
||||
using (StreamWriter outfile = new StreamWriter(charFile)) {
|
||||
outfile.Write(defaultCharSpells);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void loadingValidXMLShouldResultInSpells() {
|
||||
SpellSet spells = new SpellSet(masterSpellList, userSpellList);
|
||||
Assert.True(spells.totalCount() > 0);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void loadingMissingXMLFails() {
|
||||
Assert.Throws<System.IO.FileNotFoundException>(
|
||||
delegate {
|
||||
SpellSet spells = new SpellSet("phony.xml");
|
||||
});
|
||||
|
||||
Assert.Throws<System.IO.FileNotFoundException>(
|
||||
delegate {
|
||||
SpellSet spells = new SpellSet(masterSpellList, "phony.xml");
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void loadingValidMasterXMLShouldResultIn699MasterSpells() {
|
||||
SpellSet spells = new SpellSet(masterSpellList, userSpellList);
|
||||
Assert.Equal<int>(699, spells.masterSpellCount());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void loadingValidCustomSpellsShouldResultInOneUserSpells() {
|
||||
SpellSet spells = new SpellSet(masterSpellList, userSpellList);
|
||||
Assert.Equal<int>(1, spells.userSpellCount());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void savingNewSpellResultsInTwoSavedUserSpells() {
|
||||
SpellSet spells = new SpellSet(masterSpellList, userSpellList);
|
||||
spells.addUserSpell(new XElement("spell",
|
||||
new XElement("name", "custom test spell")
|
||||
));
|
||||
spells.save();
|
||||
Assert.Equal<int>(2, spells.userSpellCount());
|
||||
Assert.Equal<int>(701, spells.totalCount());
|
||||
|
||||
SpellSet reloadedSet = new SpellSet(masterSpellList, userSpellList);
|
||||
Assert.Equal<int>(2, spells.userSpellCount());
|
||||
Assert.Equal<int>(701, spells.totalCount());
|
||||
|
||||
spells.removeUserSpell("name", "custom test spell");
|
||||
spells.save();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void hidingMasterSpellGloballyResultsInHiddenUserSpell() {
|
||||
SpellSet spells = new SpellSet(masterSpellList, userSpellList);
|
||||
Assert.Equal<int>(0, spells.hiddenSpellCount());
|
||||
spells.hideMasterSpell("name", "Armor of Darkness");
|
||||
Assert.Equal<int>(1, spells.hiddenSpellCount());
|
||||
spells.save();
|
||||
|
||||
// ensure that a load preserves the hiddenness.
|
||||
spells = new SpellSet(masterSpellList, userSpellList);
|
||||
Assert.Equal<int>(1, spells.hiddenSpellCount());
|
||||
spells.showMasterSpell("name", "Armor of Darkness");
|
||||
Assert.Equal<int>(0, spells.hiddenSpellCount());
|
||||
spells.save();
|
||||
|
||||
// ensure that a load preserves the showingness.
|
||||
spells = new SpellSet(masterSpellList, userSpellList);
|
||||
Assert.Equal<int>(0, spells.hiddenSpellCount());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void hidingMasterSpellForCharacterResultsInHiddenCharSpell() {
|
||||
Character c = new Character(charFile);
|
||||
SpellSet spells = new SpellSet(masterSpellList, userSpellList, c);
|
||||
Assert.Equal<int>(0, spells.hiddenCharacterSpellCount());
|
||||
spells.hideMasterSpellForCharacter("name", "Armor of Darkness");
|
||||
Assert.Equal<int>(1, spells.hiddenCharacterSpellCount());
|
||||
spells.save();
|
||||
|
||||
// ensure that a load preserves the hiddenness.
|
||||
c = new Character(charFile);
|
||||
spells = new SpellSet(masterSpellList, userSpellList, c);
|
||||
Assert.Equal<int>(1, spells.hiddenCharacterSpellCount());
|
||||
spells.showMasterSpellForCharacter("name", "Armor of Darkness");
|
||||
Assert.Equal<int>(0, spells.hiddenCharacterSpellCount());
|
||||
spells.save();
|
||||
|
||||
// ensure that a load preserves the showingness.
|
||||
c = new Character(charFile);
|
||||
spells = new SpellSet(masterSpellList, userSpellList, c);
|
||||
Assert.Equal<int>(0, spells.hiddenCharacterSpellCount());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void thereAre237ClericSpells() {
|
||||
SpellSet spells = new SpellSet(masterSpellList);
|
||||
|
||||
Assert.Equal<int>(237, spells.byClass(Character.SpellCastingClasses.Cleric).Count());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void thereAre31Cleric1Spells() {
|
||||
SpellSet spells = new SpellSet(masterSpellList);
|
||||
|
||||
Assert.Equal<int>(31, spells.byClassAndLevel(Character.SpellCastingClasses.Cleric, 1).Count());
|
||||
|
||||
spells.addUserSpell(new XElement("spell",
|
||||
new XElement("name", "custom cleric spell"),
|
||||
new XElement("level", "Cleric 1")
|
||||
));
|
||||
|
||||
Assert.Equal<int>(32, spells.byClassAndLevel(Character.SpellCastingClasses.Cleric, 1).Count());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void thereAreFewerClericSpellsIfWeHideSome() {
|
||||
Character c = new Character(charFile);
|
||||
SpellSet spells = new SpellSet(masterSpellList, userSpellList, c);
|
||||
|
||||
spells.hideMasterSpell("name", "Dismissal");
|
||||
spells.hideMasterSpellForCharacter("name", "Darkness");
|
||||
Assert.Equal<int>(235, spells.byClass(Character.SpellCastingClasses.Cleric).Count());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
15
d20 SRD Spell Lists Tests/app.config
Normal file
15
d20 SRD Spell Lists Tests/app.config
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
|
||||
<section name="d20_SRD_Spell_Lists.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
<applicationSettings>
|
||||
<d20_SRD_Spell_Lists.Properties.Settings>
|
||||
<setting name="MasterSpells" serializeAs="String">
|
||||
<value>App_Data/SpellLists.xml</value>
|
||||
</setting>
|
||||
</d20_SRD_Spell_Lists.Properties.Settings>
|
||||
</applicationSettings>
|
||||
</configuration>
|
||||
87854
d20 SRD Spell Lists Tests/bin/Release/AppData/MasterSpellList.xml
Normal file
87854
d20 SRD Spell Lists Tests/bin/Release/AppData/MasterSpellList.xml
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?><character><name>Thomasina</name><class>Cleric</class><spells><spell><name>Dummy Character Spell</name><short_description>A short description.</short_description></spell></spells></character>
|
||||
87854
d20 SRD Spell Lists Tests/bin/Release/AppData/TestMasterSpellList.xml
Normal file
87854
d20 SRD Spell Lists Tests/bin/Release/AppData/TestMasterSpellList.xml
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<spells>
|
||||
<spell>
|
||||
<name>Dummy Spell</name>
|
||||
<short_description>A short description.</short_description>
|
||||
</spell>
|
||||
</spells>
|
||||
@@ -0,0 +1 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?><spells><spell><name>Dummy Spell</name><short_description>A short description.</short_description></spell></spells>
|
||||
Binary file not shown.
Binary file not shown.
BIN
d20 SRD Spell Lists Tests/bin/Release/d20 SRD Spell Lists.exe
Normal file
BIN
d20 SRD Spell Lists Tests/bin/Release/d20 SRD Spell Lists.exe
Normal file
Binary file not shown.
BIN
d20 SRD Spell Lists Tests/bin/Release/d20 SRD Spell Lists.pdb
Normal file
BIN
d20 SRD Spell Lists Tests/bin/Release/d20 SRD Spell Lists.pdb
Normal file
Binary file not shown.
BIN
d20 SRD Spell Lists Tests/bin/Release/xunit.dll
Normal file
BIN
d20 SRD Spell Lists Tests/bin/Release/xunit.dll
Normal file
Binary file not shown.
2439
d20 SRD Spell Lists Tests/bin/Release/xunit.xml
Normal file
2439
d20 SRD Spell Lists Tests/bin/Release/xunit.xml
Normal file
File diff suppressed because it is too large
Load Diff
72
d20 SRD Spell Lists Tests/d20SRDSpellLists.Tests.csproj
Normal file
72
d20 SRD Spell Lists Tests/d20SRDSpellLists.Tests.csproj
Normal file
@@ -0,0 +1,72 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{001431A1-A6AF-4391-B3AF-7B90DB0B26B8}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>d20_SRD_Spell_Lists_Tests</RootNamespace>
|
||||
<AssemblyName>d20 SRD Spell Lists Tests</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="xunit">
|
||||
<HintPath>..\..\xunit.net\xunit.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="CharacterTests.cs" />
|
||||
<Compile Include="SpellsTests.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="AppData\TestMasterSpellList.xml">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="AppData\TestUserSpellList.xml">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\d20 SRD Spell Lists\d20SRDSpellLists.csproj">
|
||||
<Project>{F550B743-1937-4295-9AA2-770F5E0D1FDC}</Project>
|
||||
<Name>d20SRDSpellLists</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,7 @@
|
||||
f:\spelllists\d20 SRD Spell Lists Tests\bin\Release\d20 SRD Spell Lists Tests.dll
|
||||
f:\spelllists\d20 SRD Spell Lists Tests\bin\Release\d20 SRD Spell Lists Tests.pdb
|
||||
f:\spelllists\d20 SRD Spell Lists Tests\bin\Release\xunit.dll
|
||||
f:\spelllists\d20 SRD Spell Lists Tests\bin\Release\xunit.xml
|
||||
f:\spelllists\d20 SRD Spell Lists Tests\obj\Release\ResolveAssemblyReference.cache
|
||||
f:\spelllists\d20 SRD Spell Lists Tests\obj\Release\d20 SRD Spell Lists Tests.dll
|
||||
f:\spelllists\d20 SRD Spell Lists Tests\obj\Release\d20 SRD Spell Lists Tests.pdb
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,13 @@
|
||||
F:\spelllists\d20 SRD Spell Lists Tests\bin\Release\d20 SRD Spell Lists Tests.dll
|
||||
F:\spelllists\d20 SRD Spell Lists Tests\bin\Release\d20 SRD Spell Lists Tests.pdb
|
||||
F:\spelllists\d20 SRD Spell Lists Tests\bin\Release\d20 SRD Spell Lists.exe
|
||||
F:\spelllists\d20 SRD Spell Lists Tests\bin\Release\xunit.dll
|
||||
F:\spelllists\d20 SRD Spell Lists Tests\bin\Release\d20 SRD Spell Lists.pdb
|
||||
F:\spelllists\d20 SRD Spell Lists Tests\bin\Release\xunit.xml
|
||||
F:\spelllists\d20 SRD Spell Lists Tests\obj\Release\ResolveAssemblyReference.cache
|
||||
F:\spelllists\d20 SRD Spell Lists Tests\obj\Release\d20 SRD Spell Lists Tests.dll
|
||||
F:\spelllists\d20 SRD Spell Lists Tests\obj\Release\d20 SRD Spell Lists Tests.pdb
|
||||
F:\spelllists\d20 SRD Spell Lists Tests\bin\Release\AppData\MasterSpellList.xml
|
||||
F:\spelllists\d20 SRD Spell Lists Tests\bin\Release\AppData\TestMasterSpellList.xml
|
||||
F:\spelllists\d20 SRD Spell Lists Tests\bin\Release\AppData\TestUserSpellList.xml
|
||||
F:\spelllists\d20 SRD Spell Lists Tests\bin\Release\AppData\UserSpellList.xml
|
||||
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ProjectView>ShowAllFiles</ProjectView>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -1,16 +1,38 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
# Visual C# Express 2010
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "d20 SRD Spell Lists", "d20 SRD Spell Lists.csproj", "{F550B743-1937-4295-9AA2-770F5E0D1FDC}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "d20SRDSpellLists.Tests", "d20 SRD Spell Lists Tests\d20SRDSpellLists.Tests.csproj", "{001431A1-A6AF-4391-B3AF-7B90DB0B26B8}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "d20SRDSpellLists", "d20 SRD Spell Lists\d20SRDSpellLists.csproj", "{F550B743-1937-4295-9AA2-770F5E0D1FDC}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|Mixed Platforms = Debug|Mixed Platforms
|
||||
Debug|x86 = Debug|x86
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Release|Mixed Platforms = Release|Mixed Platforms
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{001431A1-A6AF-4391-B3AF-7B90DB0B26B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{001431A1-A6AF-4391-B3AF-7B90DB0B26B8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{001431A1-A6AF-4391-B3AF-7B90DB0B26B8}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{001431A1-A6AF-4391-B3AF-7B90DB0B26B8}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{001431A1-A6AF-4391-B3AF-7B90DB0B26B8}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{001431A1-A6AF-4391-B3AF-7B90DB0B26B8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{001431A1-A6AF-4391-B3AF-7B90DB0B26B8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{001431A1-A6AF-4391-B3AF-7B90DB0B26B8}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{001431A1-A6AF-4391-B3AF-7B90DB0B26B8}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{001431A1-A6AF-4391-B3AF-7B90DB0B26B8}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{F550B743-1937-4295-9AA2-770F5E0D1FDC}.Debug|Any CPU.ActiveCfg = Debug|x86
|
||||
{F550B743-1937-4295-9AA2-770F5E0D1FDC}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
|
||||
{F550B743-1937-4295-9AA2-770F5E0D1FDC}.Debug|Mixed Platforms.Build.0 = Debug|x86
|
||||
{F550B743-1937-4295-9AA2-770F5E0D1FDC}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{F550B743-1937-4295-9AA2-770F5E0D1FDC}.Debug|x86.Build.0 = Debug|x86
|
||||
{F550B743-1937-4295-9AA2-770F5E0D1FDC}.Release|Any CPU.ActiveCfg = Release|x86
|
||||
{F550B743-1937-4295-9AA2-770F5E0D1FDC}.Release|Mixed Platforms.ActiveCfg = Release|x86
|
||||
{F550B743-1937-4295-9AA2-770F5E0D1FDC}.Release|Mixed Platforms.Build.0 = Release|x86
|
||||
{F550B743-1937-4295-9AA2-770F5E0D1FDC}.Release|x86.ActiveCfg = Release|x86
|
||||
{F550B743-1937-4295-9AA2-770F5E0D1FDC}.Release|x86.Build.0 = Release|x86
|
||||
EndGlobalSection
|
||||
|
||||
Binary file not shown.
87854
d20 SRD Spell Lists/AppData/MasterSpellList.xml
Normal file
87854
d20 SRD Spell Lists/AppData/MasterSpellList.xml
Normal file
File diff suppressed because it is too large
Load Diff
3
d20 SRD Spell Lists/AppData/UserSpellList.xml
Normal file
3
d20 SRD Spell Lists/AppData/UserSpellList.xml
Normal file
@@ -0,0 +1,3 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<spells>
|
||||
</spells>
|
||||
13
d20 SRD Spell Lists/Exceptions/NoCharacterFileException.cs
Normal file
13
d20 SRD Spell Lists/Exceptions/NoCharacterFileException.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace d20_SRD_Spell_Lists.Exceptions {
|
||||
public class NoCharacterFileException : Exception {
|
||||
|
||||
public NoCharacterFileException(string message)
|
||||
: base(message) {
|
||||
}
|
||||
}
|
||||
}
|
||||
275
d20 SRD Spell Lists/Models/Character.cs
Normal file
275
d20 SRD Spell Lists/Models/Character.cs
Normal file
@@ -0,0 +1,275 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using System.Xml.Linq;
|
||||
using d20_SRD_Spell_Lists.Exceptions;
|
||||
|
||||
namespace d20_SRD_Spell_Lists.Models {
|
||||
public class Character {
|
||||
|
||||
private string charXmlFile;
|
||||
private XElement charDetails;
|
||||
|
||||
public Character() {
|
||||
charDetails = new XElement("character");
|
||||
charDetails.Add(new XElement("spells"));
|
||||
}
|
||||
|
||||
public Character(string _charXmlFile) {
|
||||
charXmlFile = _charXmlFile;
|
||||
charDetails = XElement.Load(charXmlFile);
|
||||
}
|
||||
|
||||
internal void save() {
|
||||
if (charXmlFile == null) {
|
||||
throw new NoCharacterFileException("Don't have a file location for the character.");
|
||||
}
|
||||
charDetails.Save(charXmlFile);
|
||||
}
|
||||
|
||||
internal XElement spells() {
|
||||
return charDetails.Element("spells");
|
||||
}
|
||||
|
||||
private int modifier(int score) {
|
||||
return (int)Math.Floor((score - 10) / 2.00);
|
||||
}
|
||||
|
||||
public string Name {
|
||||
get {
|
||||
if (charDetails.Element("name") != null) {
|
||||
return charDetails.Element("name").Value;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
set {
|
||||
if (charDetails.Element("name") != null) {
|
||||
charDetails.Element("name").Value = value;
|
||||
} else {
|
||||
charDetails.Add(new XElement("name", value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int Strength {
|
||||
get {
|
||||
if (charDetails.Element("strength") != null) {
|
||||
return int.Parse(charDetails.Element("strength").Value);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
set {
|
||||
if (charDetails.Element("strength") != null) {
|
||||
charDetails.Element("strength").Value = value.ToString();
|
||||
} else {
|
||||
charDetails.Add(new XElement("strength", value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int Dexterity {
|
||||
get {
|
||||
if (charDetails.Element("dexterity") != null) {
|
||||
return int.Parse(charDetails.Element("dexterity").Value);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
set {
|
||||
if (charDetails.Element("dexterity") != null) {
|
||||
charDetails.Element("dexterity").Value = value.ToString();
|
||||
} else {
|
||||
charDetails.Add(new XElement("dexterity", value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int Constitution {
|
||||
get {
|
||||
if (charDetails.Element("constitution") != null) {
|
||||
return int.Parse(charDetails.Element("constitution").Value);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
set {
|
||||
if (charDetails.Element("constitution") != null) {
|
||||
charDetails.Element("constitution").Value = value.ToString();
|
||||
} else {
|
||||
charDetails.Add(new XElement("constitution", value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int Intelligence {
|
||||
get {
|
||||
if (charDetails.Element("intelligence") != null) {
|
||||
return int.Parse(charDetails.Element("intelligence").Value);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
set {
|
||||
if (charDetails.Element("intelligence") != null) {
|
||||
charDetails.Element("intelligence").Value = value.ToString();
|
||||
} else {
|
||||
charDetails.Add(new XElement("intelligence", value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int Wisdom {
|
||||
get {
|
||||
if (charDetails.Element("wisdom") != null) {
|
||||
return int.Parse(charDetails.Element("wisdom").Value);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
set {
|
||||
if (charDetails.Element("wisdom") != null) {
|
||||
charDetails.Element("wisdom").Value = value.ToString();
|
||||
} else {
|
||||
charDetails.Add(new XElement("wisdom", value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int Charisma {
|
||||
get {
|
||||
if (charDetails.Element("charisma") != null) {
|
||||
return int.Parse(charDetails.Element("charisma").Value);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
set {
|
||||
if (charDetails.Element("charisma") != null) {
|
||||
charDetails.Element("charisma").Value = value.ToString();
|
||||
} else {
|
||||
charDetails.Add(new XElement("charisma", value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int SpellCastingAttribute {
|
||||
get {
|
||||
switch (CharacterClass) {
|
||||
case SpellCastingClasses.Bard:
|
||||
return Charisma;
|
||||
case SpellCastingClasses.Cleric:
|
||||
return Wisdom;
|
||||
case SpellCastingClasses.Druid:
|
||||
return Wisdom;
|
||||
case SpellCastingClasses.Paladin:
|
||||
return Wisdom;
|
||||
case SpellCastingClasses.Ranger:
|
||||
return Wisdom;
|
||||
case SpellCastingClasses.Sorcerer:
|
||||
return Charisma;
|
||||
case SpellCastingClasses.Wizard:
|
||||
return Intelligence;
|
||||
default:
|
||||
return Wisdom;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int SpellCastingAttributeMod {
|
||||
get {
|
||||
switch (CharacterClass) {
|
||||
case SpellCastingClasses.Bard:
|
||||
return CharismaMod;
|
||||
case SpellCastingClasses.Cleric:
|
||||
return WisdomMod;
|
||||
case SpellCastingClasses.Druid:
|
||||
return WisdomMod;
|
||||
case SpellCastingClasses.Paladin:
|
||||
return WisdomMod;
|
||||
case SpellCastingClasses.Ranger:
|
||||
return WisdomMod;
|
||||
case SpellCastingClasses.Sorcerer:
|
||||
return CharismaMod;
|
||||
case SpellCastingClasses.Wizard:
|
||||
return IntelligenceMod;
|
||||
default:
|
||||
return WisdomMod;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public SpellCastingClasses CharacterClass {
|
||||
get {
|
||||
if (charDetails.Element("class") != null) {
|
||||
return (SpellCastingClasses)Enum.Parse(typeof(SpellCastingClasses), charDetails.Element("class").Value);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
set {
|
||||
if (charDetails.Element("class") != null) {
|
||||
charDetails.Element("class").Value = getClassName(value);
|
||||
} else {
|
||||
charDetails.Add(new XElement("class", getClassName(value)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int StrengthMod {
|
||||
get {
|
||||
return modifier(Strength);
|
||||
}
|
||||
}
|
||||
|
||||
public int DexterityMod {
|
||||
get {
|
||||
return modifier(Dexterity);
|
||||
}
|
||||
}
|
||||
|
||||
public int ConstitutionMod {
|
||||
get {
|
||||
return modifier(Constitution);
|
||||
}
|
||||
}
|
||||
|
||||
public int IntelligenceMod {
|
||||
get {
|
||||
return modifier(Intelligence);
|
||||
}
|
||||
}
|
||||
|
||||
public int WisdomMod {
|
||||
get {
|
||||
return modifier(Wisdom);
|
||||
}
|
||||
}
|
||||
|
||||
public int CharismaMod {
|
||||
get {
|
||||
return modifier(Charisma);
|
||||
}
|
||||
}
|
||||
|
||||
public enum SpellCastingClasses {
|
||||
Bard = 0,
|
||||
Cleric = 1,
|
||||
Druid = 2,
|
||||
Paladin = 3,
|
||||
Ranger = 4,
|
||||
Sorcerer = 5,
|
||||
Wizard = 6
|
||||
}
|
||||
|
||||
public static string getClassName(SpellCastingClasses spellCastingClass) {
|
||||
return Enum.GetName(typeof(SpellCastingClasses), spellCastingClass);
|
||||
}
|
||||
|
||||
public int[] BonusSpells {
|
||||
get {
|
||||
int[] bs = new int[] {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
for (int i = 1; i < bs.Length; i++ ) {
|
||||
bs[i] = (int)Math.Floor((SpellCastingAttribute - ((i + 1) * 2)) / 8.00);
|
||||
}
|
||||
return bs;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
221
d20 SRD Spell Lists/Models/SpellSet.cs
Normal file
221
d20 SRD Spell Lists/Models/SpellSet.cs
Normal file
@@ -0,0 +1,221 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using System.Xml.Linq;
|
||||
using d20_SRD_Spell_Lists.Exceptions;
|
||||
|
||||
namespace d20_SRD_Spell_Lists.Models {
|
||||
public class SpellSet {
|
||||
private XElement masterSpellList;
|
||||
private XElement userSpellList;
|
||||
private XElement charSpellList;
|
||||
private string userXmlFile;
|
||||
private Character character;
|
||||
|
||||
public SpellSet(string _masterXmlFile = null, string _userXmlFile = null, Character _character = null) {
|
||||
userXmlFile = _userXmlFile;
|
||||
character = _character;
|
||||
loadXML(ref _masterXmlFile);
|
||||
}
|
||||
|
||||
private void loadXML(ref string _masterXmlFile) {
|
||||
// Load the XML file.
|
||||
if (_masterXmlFile == null) {
|
||||
_masterXmlFile = Properties.Settings.Default.MasterSpells;
|
||||
}
|
||||
if (userXmlFile == null) {
|
||||
userXmlFile = Properties.Settings.Default.UserSpells;
|
||||
}
|
||||
masterSpellList = XElement.Load(_masterXmlFile);
|
||||
userSpellList = XElement.Load(userXmlFile);
|
||||
|
||||
if (character != null) {
|
||||
charSpellList = character.spells();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a spell to the application's list of custom spells.
|
||||
/// </summary>
|
||||
/// <param name="xElement">The XML details of the new spell.</param>
|
||||
public void addUserSpell(XElement xElement) {
|
||||
userSpellList.Add(xElement);
|
||||
}
|
||||
|
||||
public IEnumerable<XElement> byClass(Character.SpellCastingClasses spellCastingClass) {
|
||||
XElement spells = new XElement("spells");
|
||||
|
||||
filterMasterSpellsByClass(spellCastingClass, spells);
|
||||
filterUserSpellsByClass(spellCastingClass, spells);
|
||||
filterCharacterSpellsByClass(spellCastingClass, spells);
|
||||
|
||||
removeHiddenSpells(spells);
|
||||
|
||||
return spells.Elements("spell");
|
||||
}
|
||||
|
||||
private void filterMasterSpellsByClass(Character.SpellCastingClasses spellCastingClass, XElement spells) {
|
||||
spells.Add((from sp in masterSpellList.Elements("spell")
|
||||
let level = (string)sp.Element("level")
|
||||
where level != null && level.Contains(Character.getClassName(spellCastingClass))
|
||||
select sp));
|
||||
}
|
||||
|
||||
private void filterCharacterSpellsByClass(Character.SpellCastingClasses spellCastingClass, XElement spells) {
|
||||
if (characterSpellCount() > 0) {
|
||||
spells.Add((from sp in charSpellList.Elements("spell")
|
||||
let level = (string)sp.Element("level")
|
||||
where level != null && level.Contains(Character.getClassName(spellCastingClass))
|
||||
select sp));
|
||||
}
|
||||
}
|
||||
|
||||
private void filterUserSpellsByClass(Character.SpellCastingClasses spellCastingClass, XElement spells) {
|
||||
if (userSpellCount() > 0) {
|
||||
spells.Add((from sp in userSpellList.Elements("spell")
|
||||
let level = (string)sp.Element("level")
|
||||
where level != null && level.Contains(Character.getClassName(spellCastingClass))
|
||||
select sp));
|
||||
}
|
||||
}
|
||||
|
||||
private void removeHiddenSpells(XElement spells) {
|
||||
if (hiddenSpellCount() > 0) {
|
||||
foreach (string hiddenSpellName in (from hp in userSpellList.Elements("hidden_spell").Elements("spell")
|
||||
select (string)hp.Element("name"))) {
|
||||
(from sp in spells.Elements("spell")
|
||||
where (string)sp.Element("name") == hiddenSpellName
|
||||
select sp).Remove();
|
||||
}
|
||||
}
|
||||
|
||||
if (hiddenCharacterSpellCount() > 0) {
|
||||
foreach (string hiddenSpellName in (from hp in charSpellList.Elements("hidden_spell").Elements("spell")
|
||||
select (string)hp.Element("name"))) {
|
||||
(from sp in spells.Elements("spell")
|
||||
where (string)sp.Element("name") == hiddenSpellName
|
||||
select sp).Remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<XElement> byClassAndLevel(Character.SpellCastingClasses spellCastingClass, int level) {
|
||||
XElement spells = new XElement("spells");
|
||||
|
||||
filterMasterSpellsByClassAndLevel(spellCastingClass, level, spells);
|
||||
filterUserSpellsByClassAndLevel(spellCastingClass, level, spells);
|
||||
filterCharacterSpellsByClassAndLevel(spellCastingClass, level, spells);
|
||||
|
||||
removeHiddenSpells(spells);
|
||||
|
||||
return spells.Elements("spell");
|
||||
}
|
||||
|
||||
private void filterCharacterSpellsByClassAndLevel(Character.SpellCastingClasses spellCastingClass, int level, XElement spells) {
|
||||
if (characterSpellCount() > 0) {
|
||||
spells.Add((from sp in charSpellList.Elements("spell")
|
||||
let xmlLevel = (string)sp.Element("level")
|
||||
where xmlLevel != null && xmlLevel.Contains(Character.getClassName(spellCastingClass) + " " + level.ToString())
|
||||
select sp));
|
||||
}
|
||||
}
|
||||
|
||||
private void filterUserSpellsByClassAndLevel(Character.SpellCastingClasses spellCastingClass, int level, XElement spells) {
|
||||
if (userSpellCount() > 0) {
|
||||
spells.Add((from sp in userSpellList.Elements("spell")
|
||||
let xmlLevel = (string)sp.Element("level")
|
||||
where xmlLevel != null && xmlLevel.Contains(Character.getClassName(spellCastingClass) + " " + level.ToString())
|
||||
select sp));
|
||||
}
|
||||
}
|
||||
|
||||
private void filterMasterSpellsByClassAndLevel(Character.SpellCastingClasses spellCastingClass, int level, XElement spells) {
|
||||
spells.Add((from sp in masterSpellList.Elements("spell")
|
||||
let xmlLevel = (string)sp.Element("level")
|
||||
where xmlLevel != null && xmlLevel.Contains(Character.getClassName(spellCastingClass) + " " + level.ToString())
|
||||
select sp));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Saves all XML files to the system.
|
||||
/// </summary>
|
||||
public void save() {
|
||||
userSpellList.Save(userXmlFile);
|
||||
if (character != null) {
|
||||
character.save();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove a node from the application's custom spell list.
|
||||
/// </summary>
|
||||
/// <param name="nodeName">The name of the node to be searched on. Could be "name", "school", etc.</param>
|
||||
/// <param name="nodeValue">The value of the node matching the nodeName.</param>
|
||||
public void removeUserSpell(string nodeName, string nodeValue) {
|
||||
(from sp in userSpellList.Elements("spell")
|
||||
where (string)sp.Element(nodeName) == nodeValue
|
||||
select sp).Remove();
|
||||
}
|
||||
|
||||
public void hideMasterSpell(string nodeName, string nodeValue) {
|
||||
userSpellList.Add(new XElement("hidden_spell", (from msp in masterSpellList.Elements("spell")
|
||||
where (string)msp.Element(nodeName) == nodeValue
|
||||
select msp)));
|
||||
}
|
||||
|
||||
public void hideMasterSpellForCharacter(string nodeName, string nodeValue) {
|
||||
charSpellList.Add(new XElement("hidden_spell", (from msp in masterSpellList.Elements("spell")
|
||||
where (string)msp.Element(nodeName) == nodeValue
|
||||
select msp)));
|
||||
}
|
||||
|
||||
public void showMasterSpell(string nodeName, string nodeValue) {
|
||||
(from hsp in userSpellList.Elements("hidden_spell")
|
||||
where (string)hsp.Element("spell").Element(nodeName) == nodeValue
|
||||
select hsp).Remove();
|
||||
}
|
||||
|
||||
public void showMasterSpellForCharacter(string nodeName, string nodeValue) {
|
||||
(from hsp in charSpellList.Elements("hidden_spell")
|
||||
where (string)hsp.Element("spell").Element(nodeName) == nodeValue
|
||||
select hsp).Remove();
|
||||
}
|
||||
|
||||
public int hiddenSpellCount() {
|
||||
return userSpellList.Descendants("hidden_spell").Count();
|
||||
}
|
||||
|
||||
public int hiddenCharacterSpellCount() {
|
||||
if (charSpellList != null) {
|
||||
return charSpellList.Descendants("hidden_spell").Count();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int totalCount() {
|
||||
int total = masterSpellList.Elements("spell").Count() + userSpellList.Elements("spell").Count();
|
||||
if (charSpellList != null) {
|
||||
total += charSpellList.Elements("spell").Count();
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
public int masterSpellCount() {
|
||||
return masterSpellList.Elements("spell").Count();
|
||||
}
|
||||
|
||||
public int userSpellCount() {
|
||||
return userSpellList.Elements("spell").Count();
|
||||
}
|
||||
|
||||
public int characterSpellCount() {
|
||||
if (character != null) {
|
||||
return character.spells().Elements("spell").Count();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.225
|
||||
// Runtime Version:4.0.30319.235
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
@@ -9,18 +9,36 @@
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace d20_SRD_Spell_Lists.Properties {
|
||||
|
||||
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
|
||||
public static Settings Default {
|
||||
get {
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("AppData/MasterSpellList.xml")]
|
||||
public string MasterSpells {
|
||||
get {
|
||||
return ((string)(this["MasterSpells"]));
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("AppData/UserSpellList.xml")]
|
||||
public string UserSpells {
|
||||
get {
|
||||
return ((string)(this["UserSpells"]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
12
d20 SRD Spell Lists/Properties/Settings.settings
Normal file
12
d20 SRD Spell Lists/Properties/Settings.settings
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="d20_SRD_Spell_Lists.Properties" GeneratedClassName="Settings">
|
||||
<Profiles />
|
||||
<Settings>
|
||||
<Setting Name="MasterSpells" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)">AppData/MasterSpellList.xml</Value>
|
||||
</Setting>
|
||||
<Setting Name="UserSpells" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)">AppData/UserSpellList.xml</Value>
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
||||
18
d20 SRD Spell Lists/app.config
Normal file
18
d20 SRD Spell Lists/app.config
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
|
||||
<section name="d20_SRD_Spell_Lists.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
<applicationSettings>
|
||||
<d20_SRD_Spell_Lists.Properties.Settings>
|
||||
<setting name="MasterSpells" serializeAs="String">
|
||||
<value>AppData/MasterSpellList.xml</value>
|
||||
</setting>
|
||||
<setting name="UserSpells" serializeAs="String">
|
||||
<value>AppData/UserSpellList.xml</value>
|
||||
</setting>
|
||||
</d20_SRD_Spell_Lists.Properties.Settings>
|
||||
</applicationSettings>
|
||||
</configuration>
|
||||
BIN
d20 SRD Spell Lists/bin/Debug/d20 SRD Spell Lists.vshost.exe
Normal file
BIN
d20 SRD Spell Lists/bin/Debug/d20 SRD Spell Lists.vshost.exe
Normal file
Binary file not shown.
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
||||
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
|
||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
|
||||
<security>
|
||||
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
|
||||
</requestedPrivileges>
|
||||
</security>
|
||||
</trustInfo>
|
||||
</assembly>
|
||||
87854
d20 SRD Spell Lists/bin/Release/AppData/MasterSpellList.xml
Normal file
87854
d20 SRD Spell Lists/bin/Release/AppData/MasterSpellList.xml
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,3 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<spells>
|
||||
</spells>
|
||||
BIN
d20 SRD Spell Lists/bin/Release/d20 SRD Spell Lists.exe
Normal file
BIN
d20 SRD Spell Lists/bin/Release/d20 SRD Spell Lists.exe
Normal file
Binary file not shown.
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
|
||||
<section name="d20_SRD_Spell_Lists.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
<applicationSettings>
|
||||
<d20_SRD_Spell_Lists.Properties.Settings>
|
||||
<setting name="MasterSpells" serializeAs="String">
|
||||
<value>AppData/MasterSpellList.xml</value>
|
||||
</setting>
|
||||
<setting name="UserSpells" serializeAs="String">
|
||||
<value>AppData/UserSpellList.xml</value>
|
||||
</setting>
|
||||
</d20_SRD_Spell_Lists.Properties.Settings>
|
||||
</applicationSettings>
|
||||
</configuration>
|
||||
BIN
d20 SRD Spell Lists/bin/Release/d20 SRD Spell Lists.pdb
Normal file
BIN
d20 SRD Spell Lists/bin/Release/d20 SRD Spell Lists.pdb
Normal file
Binary file not shown.
@@ -13,6 +13,21 @@
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
<UpdateEnabled>false</UpdateEnabled>
|
||||
<UpdateMode>Foreground</UpdateMode>
|
||||
<UpdateInterval>7</UpdateInterval>
|
||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
@@ -46,12 +61,15 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Exceptions\NoCharacterFileException.cs" />
|
||||
<Compile Include="Form1.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Form1.Designer.cs">
|
||||
<DependentUpon>Form1.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Models\Character.cs" />
|
||||
<Compile Include="Models\SpellSet.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
@@ -63,6 +81,7 @@
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<None Include="app.config" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
@@ -74,7 +93,34 @@
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="App_Data\SpellLists.xml" />
|
||||
<Content Include="AppData\MasterSpellList.xml">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="AppData\UserSpellList.xml">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include=".NETFramework,Version=v4.0,Profile=Client">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>Microsoft .NET Framework 4 Client Profile %28x86 and x64%29</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>Windows Installer 3.1</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
14
d20 SRD Spell Lists/d20SRDSpellLists.csproj.user
Normal file
14
d20 SRD Spell Lists/d20SRDSpellLists.csproj.user
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ProjectView>ShowAllFiles</ProjectView>
|
||||
<PublishUrlHistory>publish\</PublishUrlHistory>
|
||||
<InstallUrlHistory />
|
||||
<SupportUrlHistory />
|
||||
<UpdateUrlHistory />
|
||||
<BootstrapperUrlHistory />
|
||||
<ErrorReportUrlHistory />
|
||||
<FallbackCulture>en-US</FallbackCulture>
|
||||
<VerifyUploadedFiles>false</VerifyUploadedFiles>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
d20 SRD Spell Lists/obj/x86/Release/GenerateResource.read.1.tlog
Normal file
BIN
d20 SRD Spell Lists/obj/x86/Release/GenerateResource.read.1.tlog
Normal file
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,16 @@
|
||||
F:\spelllists\bin\Release\d20 SRD Spell Lists.exe
|
||||
F:\spelllists\bin\Release\d20 SRD Spell Lists.pdb
|
||||
F:\spelllists\obj\x86\Release\ResolveAssemblyReference.cache
|
||||
F:\spelllists\obj\x86\Release\d20_SRD_Spell_Lists.Properties.Resources.resources
|
||||
F:\spelllists\obj\x86\Release\GenerateResource.read.1.tlog
|
||||
F:\spelllists\obj\x86\Release\GenerateResource.write.1.tlog
|
||||
F:\spelllists\obj\x86\Release\d20 SRD Spell Lists.exe
|
||||
F:\spelllists\obj\x86\Release\d20 SRD Spell Lists.pdb
|
||||
F:\spelllists\d20 SRD Spell Lists\bin\Release\d20 SRD Spell Lists.exe
|
||||
F:\spelllists\d20 SRD Spell Lists\bin\Release\d20 SRD Spell Lists.pdb
|
||||
F:\spelllists\d20 SRD Spell Lists\obj\x86\Release\ResolveAssemblyReference.cache
|
||||
F:\spelllists\d20 SRD Spell Lists\obj\x86\Release\d20_SRD_Spell_Lists.Properties.Resources.resources
|
||||
F:\spelllists\d20 SRD Spell Lists\obj\x86\Release\GenerateResource.read.1.tlog
|
||||
F:\spelllists\d20 SRD Spell Lists\obj\x86\Release\GenerateResource.write.1.tlog
|
||||
F:\spelllists\d20 SRD Spell Lists\obj\x86\Release\d20 SRD Spell Lists.exe
|
||||
F:\spelllists\d20 SRD Spell Lists\obj\x86\Release\d20 SRD Spell Lists.pdb
|
||||
BIN
d20 SRD Spell Lists/obj/x86/Release/d20 SRD Spell Lists.exe
Normal file
BIN
d20 SRD Spell Lists/obj/x86/Release/d20 SRD Spell Lists.exe
Normal file
Binary file not shown.
BIN
d20 SRD Spell Lists/obj/x86/Release/d20 SRD Spell Lists.pdb
Normal file
BIN
d20 SRD Spell Lists/obj/x86/Release/d20 SRD Spell Lists.pdb
Normal file
Binary file not shown.
@@ -0,0 +1,11 @@
|
||||
F:\spelllists\d20 SRD Spell Lists\bin\Release\d20 SRD Spell Lists.exe
|
||||
F:\spelllists\d20 SRD Spell Lists\bin\Release\d20 SRD Spell Lists.pdb
|
||||
F:\spelllists\d20 SRD Spell Lists\obj\x86\Release\ResolveAssemblyReference.cache
|
||||
F:\spelllists\d20 SRD Spell Lists\obj\x86\Release\d20_SRD_Spell_Lists.Properties.Resources.resources
|
||||
F:\spelllists\d20 SRD Spell Lists\obj\x86\Release\GenerateResource.read.1.tlog
|
||||
F:\spelllists\d20 SRD Spell Lists\obj\x86\Release\GenerateResource.write.1.tlog
|
||||
F:\spelllists\d20 SRD Spell Lists\obj\x86\Release\d20 SRD Spell Lists.exe
|
||||
F:\spelllists\d20 SRD Spell Lists\obj\x86\Release\d20 SRD Spell Lists.pdb
|
||||
F:\spelllists\d20 SRD Spell Lists\bin\Release\d20 SRD Spell Lists.exe.config
|
||||
F:\spelllists\d20 SRD Spell Lists\bin\Release\AppData\MasterSpellList.xml
|
||||
F:\spelllists\d20 SRD Spell Lists\bin\Release\AppData\UserSpellList.xml
|
||||
Binary file not shown.
Reference in New Issue
Block a user