Inventory logger
This commit is contained in:
parent
29fba4b7cb
commit
de2057789a
41 changed files with 12834 additions and 171 deletions
188
Shared/Spells/Spell.cs
Normal file
188
Shared/Spells/Spell.cs
Normal file
|
|
@ -0,0 +1,188 @@
|
|||
|
||||
namespace Mag.Shared.Spells
|
||||
{
|
||||
/// <summary>
|
||||
/// Use GetSpell() to intialize a Spell object
|
||||
/// </summary>
|
||||
public class Spell
|
||||
{
|
||||
public readonly int Id;
|
||||
public readonly string Name;
|
||||
public readonly int Difficulty;
|
||||
public readonly int Duration;
|
||||
public readonly int Family;
|
||||
|
||||
public enum BuffLevels
|
||||
{
|
||||
None,
|
||||
|
||||
I,
|
||||
II,
|
||||
III,
|
||||
IV,
|
||||
V,
|
||||
VI,
|
||||
VII,
|
||||
VIII,
|
||||
}
|
||||
public readonly BuffLevels BuffLevel;
|
||||
|
||||
public enum CantripLevels
|
||||
{
|
||||
None,
|
||||
|
||||
Feeble,
|
||||
Minor,
|
||||
Lesser,
|
||||
Moderate,
|
||||
Inner,
|
||||
Major,
|
||||
Epic,
|
||||
Legendary,
|
||||
}
|
||||
public readonly CantripLevels CantripLevel;
|
||||
|
||||
public Spell(int id, string name, int difficulty, int duration, int family)
|
||||
{
|
||||
Id = id;
|
||||
Name = name;
|
||||
Difficulty = difficulty;
|
||||
Duration = duration;
|
||||
Family = family;
|
||||
|
||||
if (name.EndsWith(" I"))
|
||||
BuffLevel = BuffLevels.I;
|
||||
else if (name.EndsWith(" II"))
|
||||
BuffLevel = BuffLevels.II;
|
||||
else if (name.EndsWith(" III"))
|
||||
BuffLevel = BuffLevels.III;
|
||||
else if (name.EndsWith(" IV"))
|
||||
BuffLevel = BuffLevels.IV;
|
||||
else if (name.EndsWith(" V"))
|
||||
BuffLevel = BuffLevels.V;
|
||||
else if (name.EndsWith(" VI"))
|
||||
BuffLevel = BuffLevels.VI;
|
||||
else if (name.EndsWith(" VII")) // This doesn't pick up every lvl 7
|
||||
BuffLevel = BuffLevels.VII;
|
||||
else if (name.StartsWith("Incantation ") || name.StartsWith("Aura of Incantation "))
|
||||
BuffLevel = BuffLevels.VIII;
|
||||
|
||||
if (name.StartsWith("Feeble "))
|
||||
CantripLevel = CantripLevels.Feeble;
|
||||
else if (name.StartsWith("Minor "))
|
||||
CantripLevel = CantripLevels.Minor;
|
||||
else if (name.StartsWith("Lesser "))
|
||||
CantripLevel = CantripLevels.Lesser;
|
||||
else if (name.StartsWith("Moderate "))
|
||||
CantripLevel = CantripLevels.Moderate;
|
||||
else if (name.StartsWith("Inner ") && name != "Inner Calm")
|
||||
CantripLevel = CantripLevels.Inner;
|
||||
else if (name.StartsWith("Major "))
|
||||
CantripLevel = CantripLevels.Major;
|
||||
else if (name.StartsWith("Epic "))
|
||||
CantripLevel = CantripLevels.Epic;
|
||||
else if (name.StartsWith("Legendary "))
|
||||
CantripLevel = CantripLevels.Legendary;
|
||||
|
||||
// Try to determine if this is a lvl x
|
||||
if (BuffLevel == BuffLevels.None && CantripLevel == CantripLevels.None)
|
||||
{
|
||||
// These spells don't have levels
|
||||
if (name.StartsWith("Prodigal ") || // Rares
|
||||
name.StartsWith("Cloaked in ") || name.StartsWith("Shroud of ")) // Cloaks
|
||||
return;
|
||||
|
||||
if (difficulty == 1 && duration == 1800)
|
||||
BuffLevel = BuffLevels.I;
|
||||
if (difficulty == 50 && duration == -1 && name.StartsWith("Evaporate "))
|
||||
BuffLevel = BuffLevels.II;
|
||||
|
||||
if (difficulty == 50 && duration == 1800)
|
||||
BuffLevel = BuffLevels.II;
|
||||
if (difficulty == 100 && duration == -1 && name.StartsWith("Extinguish "))
|
||||
BuffLevel = BuffLevels.II;
|
||||
|
||||
if (difficulty == 100 && duration == 1800)
|
||||
BuffLevel = BuffLevels.III;
|
||||
if (difficulty == 150 && duration == -1 && name.StartsWith("Cleanse "))
|
||||
BuffLevel = BuffLevels.III;
|
||||
|
||||
if (difficulty == 150 && duration == 1800)
|
||||
BuffLevel = BuffLevels.IV;
|
||||
if (difficulty == 200 && duration == -1 && name.StartsWith("Devour "))
|
||||
BuffLevel = BuffLevels.IV;
|
||||
|
||||
if (difficulty == 200 && duration == 1800)
|
||||
BuffLevel = BuffLevels.V;
|
||||
if (difficulty == 250 && duration == -1 && name.StartsWith("Purge "))
|
||||
BuffLevel = BuffLevels.V;
|
||||
|
||||
if (difficulty == 200 && duration == -1 && !name.StartsWith("Devour ")) // Ring spells
|
||||
BuffLevel = BuffLevels.VI;
|
||||
if (difficulty == 250 && duration == 2700)
|
||||
BuffLevel = BuffLevels.VI;
|
||||
if (difficulty == 300 && duration == -1 && name.StartsWith("Nullify "))
|
||||
BuffLevel = BuffLevels.VI;
|
||||
|
||||
if (difficulty == 300 && duration == -1 && !name.StartsWith("Nullify "))
|
||||
BuffLevel = BuffLevels.VII;
|
||||
if (difficulty == 300 && duration == 240)
|
||||
BuffLevel = BuffLevels.VII;
|
||||
if (difficulty == 300 && duration == 3600)
|
||||
BuffLevel = BuffLevels.VII;
|
||||
if (difficulty == 325 && duration == -1)
|
||||
BuffLevel = BuffLevels.VII;
|
||||
if (difficulty == 325 && duration == 240)
|
||||
BuffLevel = BuffLevels.VII;
|
||||
if (difficulty == 350 && duration == -1)
|
||||
BuffLevel = BuffLevels.VII;
|
||||
|
||||
if (difficulty == 400 && duration == 5400)
|
||||
BuffLevel = BuffLevels.VIII;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public bool IsOfSameFamilyAndGroup(Spell compareSpell)
|
||||
{
|
||||
if (Family != compareSpell.Family)
|
||||
return false;
|
||||
|
||||
if (BuffLevel != 0 && compareSpell.BuffLevel != 0)
|
||||
return true;
|
||||
|
||||
if (CantripLevel != 0 && compareSpell.CantripLevel != 0)
|
||||
return true;
|
||||
|
||||
// Are both spells are of an unkown group?
|
||||
if (BuffLevel == 0 && compareSpell.BuffLevel == 0 && CantripLevel == 0 && compareSpell.CantripLevel == 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool IsSameOrSurpasses(Spell compareSpell)
|
||||
{
|
||||
return (this == compareSpell || Surpasses(compareSpell));
|
||||
}
|
||||
|
||||
public bool Surpasses(Spell compareSpell)
|
||||
{
|
||||
if (Family == 0 || Family != compareSpell.Family)
|
||||
return false;
|
||||
|
||||
if (BuffLevel > 0 && compareSpell.BuffLevel > 0 && BuffLevel > compareSpell.BuffLevel)
|
||||
return true;
|
||||
|
||||
if (CantripLevel > 0 && compareSpell.CantripLevel > 0 && CantripLevel > compareSpell.CantripLevel)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
149
Shared/Spells/SpellTools.cs
Normal file
149
Shared/Spells/SpellTools.cs
Normal file
|
|
@ -0,0 +1,149 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Mag.Shared.Spells
|
||||
{
|
||||
public static class SpellTools
|
||||
{
|
||||
static readonly List<string> SpellTableHeader = new List<string>();
|
||||
static readonly Collection<string[]> SpellTable = new Collection<string[]>();
|
||||
|
||||
static readonly Dictionary<int, Spell> SpellsById = new Dictionary<int, Spell>();
|
||||
|
||||
static SpellTools()
|
||||
{
|
||||
var resourceNames = Assembly.GetExecutingAssembly().GetManifestResourceNames();
|
||||
|
||||
if (resourceNames.Length == 0)
|
||||
return;
|
||||
|
||||
var rootNameSpace = resourceNames[0].Substring(0, resourceNames[0].IndexOf('.'));
|
||||
|
||||
using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(rootNameSpace + ".Shared.Spells.Spells.csv"))
|
||||
{
|
||||
if (stream != null)
|
||||
{
|
||||
using (StreamReader reader = new StreamReader(stream))
|
||||
{
|
||||
SpellTableHeader = new List<string>(reader.ReadLine().Split(','));
|
||||
|
||||
while (!reader.EndOfStream)
|
||||
SpellTable.Add(reader.ReadLine().Split(','));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Will return null if no spell was found.
|
||||
/// </summary>
|
||||
public static Spell GetSpell(int id)
|
||||
{
|
||||
if (SpellsById.TryGetValue(id, out var spell))
|
||||
return spell;
|
||||
|
||||
int idIndex = SpellTableHeader.IndexOf("Id");
|
||||
|
||||
foreach (string[] line in SpellTable)
|
||||
{
|
||||
if (line[idIndex] == id.ToString(CultureInfo.InvariantCulture))
|
||||
return GetSpell(line);
|
||||
}
|
||||
|
||||
//throw new ArgumentException("Spell of id: " + id + " not found in Spells.csv");
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Will return null if no spell was found.
|
||||
/// </summary>
|
||||
public static Spell GetSpell(string name)
|
||||
{
|
||||
foreach (var kvp in SpellsById)
|
||||
{
|
||||
if (String.Equals(kvp.Value.Name, name, StringComparison.OrdinalIgnoreCase))
|
||||
return kvp.Value;
|
||||
}
|
||||
|
||||
int nameIndex = SpellTableHeader.IndexOf("Name");
|
||||
|
||||
foreach (string[] line in SpellTable)
|
||||
{
|
||||
if (String.Equals(line[nameIndex], name, StringComparison.OrdinalIgnoreCase))
|
||||
return GetSpell(line);
|
||||
}
|
||||
|
||||
//throw new ArgumentException("Spell of name: " + name + " not found in Spells.csv");
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Spell GetSpell(string[] splitLine)
|
||||
{
|
||||
int idIndex = SpellTableHeader.IndexOf("Id");
|
||||
int nameIndex = SpellTableHeader.IndexOf("Name");
|
||||
int difficultyIndex = SpellTableHeader.IndexOf("Difficulty");
|
||||
int durationIndex = SpellTableHeader.IndexOf("Duration");
|
||||
int familyIndex = SpellTableHeader.IndexOf("Family");
|
||||
|
||||
int id;
|
||||
int.TryParse(splitLine[idIndex], out id);
|
||||
|
||||
string name = splitLine[nameIndex];
|
||||
|
||||
int difficulty;
|
||||
int.TryParse(splitLine[difficultyIndex], out difficulty);
|
||||
|
||||
int duration;
|
||||
int.TryParse(splitLine[durationIndex], out duration);
|
||||
|
||||
int family;
|
||||
int.TryParse(splitLine[familyIndex], out family);
|
||||
|
||||
var spell = new Spell(id, name, difficulty, duration, family);
|
||||
|
||||
if (!SpellsById.ContainsKey(spell.Id))
|
||||
SpellsById.Add(spell.Id, spell);
|
||||
|
||||
return spell;
|
||||
}
|
||||
|
||||
public static bool IsAKnownSpell(int id)
|
||||
{
|
||||
if (SpellsById.ContainsKey(id))
|
||||
return true;
|
||||
|
||||
int idIndex = SpellTableHeader.IndexOf("Id");
|
||||
|
||||
foreach (string[] line in SpellTable)
|
||||
{
|
||||
if (line[idIndex] == id.ToString(CultureInfo.InvariantCulture))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool IsAKnownSpell(string name)
|
||||
{
|
||||
foreach (var kvp in SpellsById)
|
||||
{
|
||||
if (String.Equals(kvp.Value.Name, name, StringComparison.OrdinalIgnoreCase))
|
||||
return true;
|
||||
}
|
||||
|
||||
int nameIndex = SpellTableHeader.IndexOf("Name");
|
||||
|
||||
foreach (string[] line in SpellTable)
|
||||
{
|
||||
if (line[nameIndex] == name)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
6267
Shared/Spells/Spells.csv
Normal file
6267
Shared/Spells/Spells.csv
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue