Skip to content

Commit

Permalink
implement json.net
Browse files Browse the repository at this point in the history
  • Loading branch information
KorGgenT committed Nov 23, 2019
1 parent 22c19ac commit 27b3bda
Show file tree
Hide file tree
Showing 26 changed files with 93,903 additions and 119 deletions.
4 changes: 4 additions & 0 deletions cdda-item-creator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
Expand Down Expand Up @@ -67,6 +70,7 @@
<EmbeddedResource Include="spell_form.resx">
<DependentUpon>spell_form.cs</DependentUpon>
</EmbeddedResource>
<None Include="packages.config" />
<None Include="Properties\DataSources\cdda_item_creator.spell.allowed_strings.datasource" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
Expand Down
4 changes: 4 additions & 0 deletions packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net472" />
</packages>
Binary file added packages/Newtonsoft.Json.12.0.3/.signature.p7s
Binary file not shown.
20 changes: 20 additions & 0 deletions packages/Newtonsoft.Json.12.0.3/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
The MIT License (MIT)

Copyright (c) 2007 James Newton-King

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Binary file not shown.
Binary file not shown.
10,298 changes: 10,298 additions & 0 deletions packages/Newtonsoft.Json.12.0.3/lib/net20/Newtonsoft.Json.xml

Large diffs are not rendered by default.

Binary file not shown.
9,446 changes: 9,446 additions & 0 deletions packages/Newtonsoft.Json.12.0.3/lib/net35/Newtonsoft.Json.xml

Large diffs are not rendered by default.

Binary file not shown.
9,646 changes: 9,646 additions & 0 deletions packages/Newtonsoft.Json.12.0.3/lib/net40/Newtonsoft.Json.xml

Large diffs are not rendered by default.

Binary file not shown.
11,262 changes: 11,262 additions & 0 deletions packages/Newtonsoft.Json.12.0.3/lib/net45/Newtonsoft.Json.xml

Large diffs are not rendered by default.

Binary file not shown.
10,950 changes: 10,950 additions & 0 deletions packages/Newtonsoft.Json.12.0.3/lib/netstandard1.0/Newtonsoft.Json.xml

Large diffs are not rendered by default.

Binary file not shown.
11,072 changes: 11,072 additions & 0 deletions packages/Newtonsoft.Json.12.0.3/lib/netstandard1.3/Newtonsoft.Json.xml

Large diffs are not rendered by default.

Binary file not shown.
11,237 changes: 11,237 additions & 0 deletions packages/Newtonsoft.Json.12.0.3/lib/netstandard2.0/Newtonsoft.Json.xml

Large diffs are not rendered by default.

Binary file not shown.

Large diffs are not rendered by default.

Binary file not shown.

Large diffs are not rendered by default.

Binary file added packages/Newtonsoft.Json.12.0.3/packageIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion spell_form.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Serialization;

namespace cdda_item_creator
{
Expand Down Expand Up @@ -63,7 +66,7 @@ private void id_textbox_TextChanged(object sender, EventArgs e)

private void clipboard_button_Click(object sender, EventArgs e)
{
Clipboard.SetText(main_spell.create_json());
Clipboard.SetText(JsonConvert.SerializeObject(main_spell, Formatting.Indented));

main_spell.spell_tags.Clear();

Expand Down
118 changes: 0 additions & 118 deletions spell_type.cs
Original file line number Diff line number Diff line change
Expand Up @@ -305,124 +305,6 @@ public spell_type() { }
public List<string> valid_targets = new List<string> { };
public List<string> affected_bps = new List<string> { };
public List<string> spell_tags = new List<string> { };

public string jsonize_as_array(List<string> string_list)
{
string ret = "";

if (string_list.Count == 0)
{
return ret;
}
ret = "[ ";
for (int i = 0; i < string_list.Count; i++)
{
ret += "\"" + string_list[i] + "\"";
if (i < string_list.Count - 1)
{
ret += ", ";
}
}
ret += " ]";

return ret;
}

public string create_json()
{
string ret = " {";

const string begin = "\n \"";

ret += begin + "id\": \"" + id + "\",";
ret += begin + "type\": \"SPELL\",";
ret += begin + "name\": \"" + name + "\",";
ret += begin + "description\": \"" + description + "\",";
ret += begin + "effect\": \"" + effect + "\",";
if (effect_str != "")
{
ret += begin + "effect_str\": \"" + effect_str + "\",";
}
if (spell_class != "NONE")
{
ret += begin + "spell_class\": \"" + spell_class + "\",";
}
if (difficulty != 0)
{
ret += begin + "difficulty\": " + difficulty.ToString() + ",";
}
if(max_level != 0)
{
ret += begin + "max_level\": " + max_level.ToString() + ",";
}

if(energy_source != "NONE")
{
ret += begin + "energy_source\": \"" + energy_source + "\",";
}

ret += begin + "base_casting_time\": " + base_casting_time.ToString() + ",";
if (casting_time_increment != 0.0f)
{
ret += begin + "casting_time_increment\": " + casting_time_increment.ToString() + ",";
}
ret += begin + "final_casting_time\": " + final_casting_time.ToString() + ",";

ret += damage.create_json();
ret += range.create_json();
ret += aoe.create_json();

if (field.Length > 0)
{
ret += begin + "field_id\": \"" + field + "\",";
ret += field_intensity.create_json();
ret += begin + "field_intensity_variance\": " + field_intensity_variance.ToString() + ",";
ret += begin + "field_chance\": " + field_chance.ToString() + ",";
}

if (sound_id.Length > 0)
{
ret += begin + "sound_id\": \"" + sound_id + "\",";
}
if (sound_description != "an explosion")
{
ret += begin + "sound_description\": \"" + sound_description + "\",";
}
if( message != "You cast %s!" )
{
ret += begin + "message\": \"" + message + "\",";
}
if(sound_type != "combat")
{
ret += begin + "sound_type\": \"" + sound_type + "\",";
}
if(sound_variant != "default")
{
ret += begin + "sound_variant\": \"" + sound_variant + "\",";
}
if (sound_ambient)
{
ret += begin + "sound_ambient\": true,";
}

if( affected_bps.Count != 0)
{
ret += begin + "affected_body_parts\": " + jsonize_as_array(affected_bps) + ",";
}
if( effect_targets.Count != 0)
{
ret += begin + "effect_filter\": " + jsonize_as_array(effect_targets) + ",";
}
// flags
if (spell_tags.Count != 0)
{
ret += begin + "flags\": " + jsonize_as_array(spell_tags) + ",";
}
ret += begin + "valid_targets\": " + jsonize_as_array(valid_targets);

ret += "\n }";
return ret;
}
}
}
}

0 comments on commit 27b3bda

Please sign in to comment.