Skip to content

Commit d4a74ca

Browse files
authored
Add GetSpellLevelByClass replacement/overload to match base game function. (#845)
1 parent 71fa64a commit d4a74ca

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

NWN.Anvil/src/main/API/Ruleset/NwSpell.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Linq;
4+
using NWN.Core;
45
using NWN.Native.API;
56

67
namespace Anvil.API
@@ -333,9 +334,30 @@ public SpellComponents SpellComponents
333334
/// </summary>
334335
/// <param name="nwClass">The class to query.</param>
335336
/// <returns>The spell level for the specified class.</returns>
337+
[Obsolete("Use GetSpellLevelByClass instead.")]
336338
public byte GetSpellLevelForClass(NwClass nwClass)
337339
{
338340
return spellInfo.GetSpellLevel(nwClass.Id);
339341
}
342+
343+
/// <summary>
344+
/// Gets the spell class level for the specified class.
345+
/// </summary>
346+
/// <param name="classType">The class to query.</param>
347+
/// <param name="includeMasterSpell">If true, will use the <see cref="MasterSpell"/> class level if this spell has no class level configured.</param>
348+
/// <returns>The spell level for the specified class. Returns null if no spell level is defined for the specified class.</returns>
349+
public int? GetSpellLevelByClass(NwClass classType, bool includeMasterSpell = true)
350+
{
351+
if (includeMasterSpell)
352+
{
353+
int retVal = NWScript.GetSpellLevelByClass(classType.Id, Id);
354+
return retVal == -1 ? null : retVal;
355+
}
356+
else
357+
{
358+
byte retVal = spellInfo.GetSpellLevel(classType.Id);
359+
return retVal == byte.MaxValue ? null : retVal;
360+
}
361+
}
340362
}
341363
}

0 commit comments

Comments
 (0)