Skip to content

Commit

Permalink
rename ClassBase -> ClassDescriptor
Browse files Browse the repository at this point in the history
migrations for ClassBase -> ClassDescriptor
  • Loading branch information
lodicolo committed Feb 27, 2025
1 parent ead8390 commit f581b0d
Show file tree
Hide file tree
Showing 29 changed files with 3,623 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public enum GameObjectType
[GameObjectInfo(typeof(AnimationDescriptor), "animations")]
Animation = 0,

[GameObjectInfo(typeof(ClassBase), "classes")]
[GameObjectInfo(typeof(ClassDescriptor), "classes")]
Class,

[GameObjectInfo(typeof(ItemBase), "items")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace Intersect.GameObjects;

public partial class ClassBase : DatabaseObject<ClassBase>, IFolderable
public partial class ClassDescriptor : DatabaseObject<ClassDescriptor>, IFolderable
{
public const long DEFAULT_BASE_EXPERIENCE = 100;

Expand Down Expand Up @@ -128,7 +128,7 @@ public IReadOnlyDictionary<Stat, int> StatIncreaseLookup
public long[] VitalRegen { get; set; } = new long[Enum.GetValues<Vital>().Length];

[JsonConstructor]
public ClassBase(Guid id) : base(id)
public ClassDescriptor(Guid id) : base(id)
{
Name = "New Class";

Expand All @@ -139,7 +139,7 @@ public ClassBase(Guid id) : base(id)
}

//Parameterless constructor for EF
public ClassBase()
public ClassDescriptor()
{
Name = "New Class";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public override Dictionary<string, SanitizedValue<object>> Sanitize()

var sanitizer = new Sanitizer();

var classDescriptor = ClassBase.Get(ClassId);
var classDescriptor = ClassDescriptor.Get(ClassId);
if (classDescriptor != null)
{
Sprite = sanitizer.Clamp(nameof(Sprite), Sprite, 0, classDescriptor.Sprites?.Count ?? 0);
Expand Down
2 changes: 1 addition & 1 deletion Intersect.Client.Core/Entities/Entity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2224,7 +2224,7 @@ protected virtual void LoadAnimationTexture(string textureName, SpriteAnimations
break;

case SpriteAnimations.Attack:
if (this is Player player && ClassBase.TryGet(player.Class, out var classDescriptor))
if (this is Player player && ClassDescriptor.TryGet(player.Class, out var classDescriptor))
{
textureOverride = classDescriptor.AttackSpriteOverride;
}
Expand Down
2 changes: 1 addition & 1 deletion Intersect.Client.Core/Entities/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2350,7 +2350,7 @@ public override int CalculateAttackTime()
ItemBase? weapon = null;
var attackTime = base.CalculateAttackTime();

var cls = ClassBase.Get(Class);
var cls = ClassDescriptor.Get(Class);
if (cls != null && cls.AttackSpeedModifier == 1) //Static
{
attackTime = cls.AttackSpeedValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public partial class CharacterWindow
public int Y;

//Extra Buffs
ClassBase mPlayer;
ClassDescriptor mPlayer;

Label mHpRegen;

Expand Down Expand Up @@ -218,7 +218,7 @@ public void Update()

mCharacterName.Text = Globals.Me.Name;
mCharacterLevelAndClass.Text = Strings.Character.LevelAndClass.ToString(
Globals.Me.Level, ClassBase.GetName(Globals.Me.Class)
Globals.Me.Level, ClassDescriptor.GetName(Globals.Me.Class)
);

//Load Portrait
Expand Down Expand Up @@ -406,7 +406,7 @@ public void Update()
/// </summary>
public void UpdateExtraBuffs()
{
mPlayer = ClassBase.Get(Globals.Me?.Class ?? Guid.Empty);
mPlayer = ClassDescriptor.Get(Globals.Me?.Class ?? Guid.Empty);

//Getting HP and Mana Regen
if (mPlayer != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ protected override void EnsureInitialized()

_classCombobox.ClearItems();

var classDescriptors = ClassBase.Lookup.Values.OfType<ClassBase>()
var classDescriptors = ClassDescriptor.Lookup.Values.OfType<ClassDescriptor>()
.Where(classDescriptor => !classDescriptor.Locked)
.ToArray();

Expand Down Expand Up @@ -368,14 +368,14 @@ private void UpdateDisplay()
}
}

private ClassBase? GetClass()
private ClassDescriptor? GetClass()
{
if (_classCombobox.SelectedItem == null)
{
return null;
}

return ClassBase.Lookup.Values.OfType<ClassBase>().FirstOrDefault(
return ClassDescriptor.Lookup.Values.OfType<ClassDescriptor>().FirstOrDefault(
descriptor =>
!descriptor.Locked &&
string.Equals(_classCombobox.SelectedItem.Text, descriptor.Name, StringComparison.Ordinal)
Expand Down
2 changes: 1 addition & 1 deletion Intersect.Editor/Forms/Editors/Events/CommandPrinter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1225,7 +1225,7 @@ private static string GetCommandText(OpenCraftingTableCommand command, MapInstan

private static string GetCommandText(SetClassCommand command, MapInstance map)
{
return Strings.EventCommandList.setclass.ToString(ClassBase.GetName(command.ClassId));
return Strings.EventCommandList.setclass.ToString(ClassDescriptor.GetName(command.ClassId));
}

private static string GetCommandText(StartQuestCommand command, MapInstance map)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ private void UpdateFormElements(ConditionTypes type)
case ConditionTypes.ClassIs:
grpClass.Show();
cmbClass.Items.Clear();
cmbClass.Items.AddRange(ClassBase.Names);
cmbClass.Items.AddRange(ClassDescriptor.Names);

break;
case ConditionTypes.KnowsSpell:
Expand Down Expand Up @@ -1269,7 +1269,7 @@ private void SetupFormValues(HasItemCondition condition)

private void SetupFormValues(ClassIsCondition condition)
{
cmbClass.SelectedIndex = ClassBase.ListIndex(condition.ClassId);
cmbClass.SelectedIndex = ClassDescriptor.ListIndex(condition.ClassId);
}

private void SetupFormValues(KnowsSpellCondition condition)
Expand Down Expand Up @@ -1467,7 +1467,7 @@ private void SaveFormValues(HasItemCondition condition)

private void SaveFormValues(ClassIsCondition condition)
{
condition.ClassId = ClassBase.IdFromList(cmbClass.SelectedIndex);
condition.ClassId = ClassDescriptor.IdFromList(cmbClass.SelectedIndex);
}

private void SaveFormValues(KnowsSpellCondition condition)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ public EventCommandSetClass(SetClassCommand refCommand, FrmEvent editor)
mEventEditor = editor;
InitLocalization();
cmbClass.Items.Clear();
cmbClass.Items.AddRange(ClassBase.Names);
cmbClass.SelectedIndex = ClassBase.ListIndex(mMyCommand.ClassId);
cmbClass.Items.AddRange(ClassDescriptor.Names);
cmbClass.SelectedIndex = ClassDescriptor.ListIndex(mMyCommand.ClassId);
}

private void InitLocalization()
Expand All @@ -35,7 +35,7 @@ private void btnSave_Click(object sender, EventArgs e)
{
if (cmbClass.SelectedIndex > -1)
{
mMyCommand.ClassId = ClassBase.IdFromList(cmbClass.SelectedIndex);
mMyCommand.ClassId = ClassDescriptor.IdFromList(cmbClass.SelectedIndex);
}

mEventEditor.FinishCommandEdit();
Expand Down
24 changes: 12 additions & 12 deletions Intersect.Editor/Forms/Editors/frmClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ namespace Intersect.Editor.Forms.Editors;
public partial class FrmClass : EditorForm
{

private List<ClassBase> mChanged = new List<ClassBase>();
private List<ClassDescriptor> mChanged = new List<ClassDescriptor>();

private string mCopiedItem;

private ClassBase mEditorItem;
private ClassDescriptor mEditorItem;

private List<string> mKnownFolders = new List<string>();

Expand All @@ -41,7 +41,7 @@ public FrmClass()
}
private void AssignEditorItem(Guid id)
{
mEditorItem = ClassBase.Get(id);
mEditorItem = ClassDescriptor.Get(id);
UpdateEditor();
}

Expand All @@ -50,7 +50,7 @@ protected override void GameObjectUpdatedDelegate(GameObjectType type)
if (type == GameObjectType.Class)
{
InitEditor();
if (mEditorItem != null && !ClassBase.Lookup.Values.Contains(mEditorItem))
if (mEditorItem != null && !ClassDescriptor.Lookup.Values.Contains(mEditorItem))
{
mEditorItem = null;
UpdateEditor();
Expand Down Expand Up @@ -484,15 +484,15 @@ public void InitEditor()
{
//Collect folders
var mFolders = new List<string>();
foreach (var itm in ClassBase.Lookup)
foreach (var itm in ClassDescriptor.Lookup)
{
if (!string.IsNullOrEmpty(((ClassBase) itm.Value).Folder) &&
!mFolders.Contains(((ClassBase) itm.Value).Folder))
if (!string.IsNullOrEmpty(((ClassDescriptor) itm.Value).Folder) &&
!mFolders.Contains(((ClassDescriptor) itm.Value).Folder))
{
mFolders.Add(((ClassBase) itm.Value).Folder);
if (!mKnownFolders.Contains(((ClassBase) itm.Value).Folder))
mFolders.Add(((ClassDescriptor) itm.Value).Folder);
if (!mKnownFolders.Contains(((ClassDescriptor) itm.Value).Folder))
{
mKnownFolders.Add(((ClassBase) itm.Value).Folder);
mKnownFolders.Add(((ClassDescriptor) itm.Value).Folder);
}
}
}
Expand All @@ -503,8 +503,8 @@ public void InitEditor()
cmbFolder.Items.Add("");
cmbFolder.Items.AddRange(mKnownFolders.ToArray());

var items = ClassBase.Lookup.OrderBy(p => p.Value?.Name).Select(pair => new KeyValuePair<Guid, KeyValuePair<string, string>>(pair.Key,
new KeyValuePair<string, string>(((ClassBase)pair.Value)?.Name ?? Models.DatabaseObject<ClassBase>.Deleted, ((ClassBase)pair.Value)?.Folder ?? ""))).ToArray();
var items = ClassDescriptor.Lookup.OrderBy(p => p.Value?.Name).Select(pair => new KeyValuePair<Guid, KeyValuePair<string, string>>(pair.Key,
new KeyValuePair<string, string>(((ClassDescriptor)pair.Value)?.Name ?? Models.DatabaseObject<ClassDescriptor>.Deleted, ((ClassDescriptor)pair.Value)?.Folder ?? ""))).ToArray();
lstGameObjects.Repopulate(items, mFolders, btnAlphabetical.Checked, CustomSearch(), txtSearch.Text);
}

Expand Down
2 changes: 1 addition & 1 deletion Intersect.Editor/Localization/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public static string GetEventConditionalDesc(IsItemEquippedCondition condition)

public static string GetEventConditionalDesc(ClassIsCondition condition)
{
return EventConditionDesc.Class.ToString(ClassBase.GetName(condition.ClassId));
return EventConditionDesc.Class.ToString(ClassDescriptor.GetName(condition.ClassId));
}

public static string GetEventConditionalDesc(KnowsSpellCondition condition)
Expand Down
6 changes: 3 additions & 3 deletions Intersect.Editor/Networking/PacketHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -482,14 +482,14 @@ public void HandlePacket(IPacketSender packetSender, GameObjectPacket packet)
case GameObjectType.Class:
if (deleted)
{
var cls = ClassBase.Get(id);
var cls = ClassDescriptor.Get(id);
cls.Delete();
}
else
{
var cls = new ClassBase(id);
var cls = new ClassDescriptor(id);
cls.Load(json);
ClassBase.Lookup.Set(id, cls);
ClassDescriptor.Lookup.Set(id, cls);
}

break;
Expand Down
18 changes: 9 additions & 9 deletions Intersect.Server.Core/Database/DbInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ private static void ClearGameObjects(GameObjectType type)

break;
case GameObjectType.Class:
ClassBase.Lookup.Clear();
ClassDescriptor.Lookup.Clear();

break;
case GameObjectType.Item:
Expand Down Expand Up @@ -735,7 +735,7 @@ private static void LoadGameObjects(GameObjectType gameObjectType)
case GameObjectType.Class:
foreach (var cls in context.Classes)
{
ClassBase.Lookup.Set(cls.Id, cls);
ClassDescriptor.Lookup.Set(cls.Id, cls);
}

break;
Expand Down Expand Up @@ -998,7 +998,7 @@ public static IDatabaseObject AddGameObject(GameObjectType gameObjectType, Guid

break;
case GameObjectType.Class:
dbObj = new ClassBase(predefinedid);
dbObj = new ClassDescriptor(predefinedid);

break;
case GameObjectType.Item:
Expand Down Expand Up @@ -1097,8 +1097,8 @@ public static IDatabaseObject AddGameObject(GameObjectType gameObjectType, IData
break;

case GameObjectType.Class:
context.Classes.Add((ClassBase)dbObj);
ClassBase.Lookup.Set(dbObj.Id, dbObj);
context.Classes.Add((ClassDescriptor)dbObj);
ClassDescriptor.Lookup.Set(dbObj.Id, dbObj);

break;

Expand Down Expand Up @@ -1235,7 +1235,7 @@ public static void DeleteGameObject(IDatabaseObject gameObject)

break;
case GameObjectType.Class:
context.Classes.Remove((ClassBase)gameObject);
context.Classes.Remove((ClassDescriptor)gameObject);

break;
case GameObjectType.Item:
Expand Down Expand Up @@ -1381,7 +1381,7 @@ public static void SaveGameObject(IDatabaseObject gameObject)

break;
case GameObjectType.Class:
context.Classes.Update((ClassBase)gameObject);
context.Classes.Update((ClassDescriptor)gameObject);

break;
case GameObjectType.Item:
Expand Down Expand Up @@ -1534,10 +1534,10 @@ private static void OnMapsLoaded()

private static void OnClassesLoaded()
{
if (ClassBase.Lookup.Count == 0)
if (ClassDescriptor.Lookup.Count == 0)
{
Console.WriteLine(Strings.Database.NoClasses);
var cls = (ClassBase)AddGameObject(GameObjectType.Class);
var cls = (ClassDescriptor)AddGameObject(GameObjectType.Class);
cls.Name = Strings.Database.Default;
var defaultMale = new ClassSprite()
{
Expand Down
2 changes: 1 addition & 1 deletion Intersect.Server.Core/Database/GameData/GameContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ protected GameContext(DatabaseContextOptions databaseContextOptions) : base(data
public DbSet<CraftingTableBase> CraftingTables { get; set; }

//Classes
public DbSet<ClassBase> Classes { get; set; }
public DbSet<ClassDescriptor> Classes { get; set; }

//Events
public DbSet<EventBase> Events { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion Intersect.Server.Core/Database/GameData/IGameContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public interface IGameContext : IDbContext

DbSet<CraftingTableBase> CraftingTables { get; set; }

DbSet<ClassBase> Classes { get; set; }
DbSet<ClassDescriptor> Classes { get; set; }

DbSet<EventBase> Events { get; set; }

Expand Down
2 changes: 1 addition & 1 deletion Intersect.Server.Core/Database/PlayerData/Players/Guild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public static Guild LoadGuild(Guid id)
foreach (var (memberId, membership) in members)
{
var (memberName, memberRank, memberLevel, memberClassId, memberMapId) = membership;
var className = ClassBase.GetName(memberClassId);
var className = ClassDescriptor.GetName(memberClassId);
var mapName = MapBase.GetName(memberMapId);
var guildMember = new GuildMember(
memberId,
Expand Down
2 changes: 1 addition & 1 deletion Intersect.Server.Core/Entities/Events/CommandProcessing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1276,7 +1276,7 @@ private static void ProcessCommand(
Stack<CommandInstance> callStack
)
{
if (ClassBase.Get(command.ClassId) != null)
if (ClassDescriptor.Get(command.ClassId) != null)
{
player.ClassId = command.ClassId;
player.RecalculateStatsAndPoints();
Expand Down
Loading

0 comments on commit f581b0d

Please sign in to comment.