Skip to content

Commit

Permalink
Job category and names enum
Browse files Browse the repository at this point in the history
  • Loading branch information
lastbattle committed Sep 14, 2024
1 parent ff904e4 commit abcd860
Show file tree
Hide file tree
Showing 4 changed files with 287 additions and 0 deletions.
4 changes: 4 additions & 0 deletions MapleLib/MapleLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,13 @@
<Compile Include="WzLib\WzPropertyType.cs" />
<Compile Include="WzLib\WzSerializer.cs" />
<Compile Include="WzLib\WzStructure\Data\BackgroundType.cs" />
<Compile Include="WzLib\WzStructure\Data\CharacterStructure\CharacterJob.cs" />
<Compile Include="WzLib\WzStructure\Data\CharacterStructure\CharacterJobType.cs" />
<Compile Include="WzLib\WzStructure\Data\CharacterStructure\CharacterJobTypeInfo.cs" />
<Compile Include="WzLib\WzStructure\Data\CharacterStructure\CharacterStats.cs" />
<Compile Include="WzLib\WzStructure\Data\CharacterStructure\PetSkillFlag.cs" />
<Compile Include="WzLib\WzStructure\Data\Data.cs" />
<Compile Include="WzLib\WzStructure\Data\ItemStructure\ItemIds.cs" />
<Compile Include="WzLib\WzStructure\Data\ItemStructure\ItemIdsCategory.cs" />
<Compile Include="WzLib\WzStructure\Data\MapConstants.cs" />
<Compile Include="WzLib\WzStructure\Data\FieldType.cs" />
Expand Down
107 changes: 107 additions & 0 deletions MapleLib/WzLib/WzStructure/Data/CharacterStructure/CharacterJobType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
/*Copyright(c) 2024, LastBattle https://github.com/lastbattle/Harepacker-resurrected
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.
*/

using System.Collections.Generic;
using System;
using System.Linq;

namespace MapleLib.WzLib.WzStructure.Data.CharacterStructure
{
/// <summary>
/// The job type
/// </summary>
public enum CharacterJobType
{
UltimateAdventurer = -1,
Resistance = 0,
Adventurer = 1,
Cygnus = 2,
Aran = 3,
Evan = 4,
Mercedes = 5,
Demon = 6,
Phantom = 7,
DualBlade = 8,
Mihile = 9,
Luminous = 10,
Kaiser = 11,
AngelicBuster = 12,
Cannoneer = 13,
Xenon = 14,
Zero = 15,
Shade = 16,
Zen = 17,
Jett = 17,
Hayato = 18,
Kanna = 19,
BeastTamer = 20,
PinkBean = 21,
Kinesis = 22,
NULL = 99999
}

public static class MapleJobTypeExtensions
{
/// <summary>
/// Gets all CharacterJobType enum values except NULL.
/// </summary>
/// <returns>An IEnumerable of CharacterJobType containing all enum values except NULL.</returns>
public static IEnumerable<CharacterJobType> GetAllJobTypes()
{
return Enum.GetValues(typeof(CharacterJobType))
.Cast<CharacterJobType>()
.Where(j => j != CharacterJobType.NULL);
}

/// <summary>
/// Checks if the given job bitfield matches the specified job type.
/// </summary>
/// <param name="jobBitfield">The job bitfield to check against. <int name="job" value="32800"/> </param>
/// <returns>True if the jobBitfield matches the specified job type, false otherwise.</returns>
public static List<CharacterJobType> GetMatchingJobs(int jobBitfield)
{
List<CharacterJobType> ret = new List<CharacterJobType>();

IEnumerable<CharacterJobType> jobInfo = GetAllJobTypes();
foreach (CharacterJobType job in jobInfo)
{
bool bMatch = IsJobMatching(job, jobBitfield);
if (bMatch)
{
ret.Add(job);
}
}
return ret;
}

/// <summary>
/// Checks if the given job bitfield matches the specified job type.
/// </summary>
/// <param name="job">The job selected</param>
/// <param name="jobBitfield">The job bitfield to check against. <int name="job" value="32800"/> </param>
/// <returns>True if the jobBitfield matches the specified job type, false otherwise.</returns>
public static bool IsJobMatching(CharacterJobType job, int jobBitfield)
{
bool bMatch = (jobBitfield & (1 << (int)job)) != 0;
return bMatch;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
using MapleLib.ClientLib;
using MapleLib.WzLib.WzStructure.Data.ItemStructure;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MapleLib.WzLib.WzStructure.Data.CharacterStructure
{
public class CharacterJobTypeInfo
{
public CharacterJobType Type { get; }
public bool IsCreationEnabled { get; }
public int JobId { get; }
public int Map { get; }
public int StartingETCBookItemId { get; }
public bool HairColor { get; }
public bool SkinColor { get; }
public bool FaceMark { get; }
public bool Hat { get; }
public bool Bottom { get; }
public bool Cape { get; }
public bool Ears { get; }
public bool Tail { get; }

/// <summary>
/// Character creation data
/// </summary>
/// <param name="type"></param>
/// <param name="isCreationEnabled"></param>
/// <param name="jobId"></param>
/// <param name="map"></param>
/// <param name="startingETCBookItemId"></param>
/// <param name="hairColor"></param>
/// <param name="skinColor"></param>
/// <param name="faceMark"></param>
/// <param name="hat"></param>
/// <param name="bottom"></param>
/// <param name="cape"></param>
/// <param name="ears"></param>
/// <param name="tail"></param>
public CharacterJobTypeInfo(CharacterJobType type, bool isCreationEnabled, int jobId, int map, int startingETCBookItemId,
bool hairColor, bool skinColor, bool faceMark, bool hat, bool bottom, bool cape, bool ears, bool tail)
{
Type = type;
IsCreationEnabled = isCreationEnabled;
JobId = jobId;
Map = map;
StartingETCBookItemId = startingETCBookItemId;
HairColor = hairColor;
SkinColor = skinColor;
FaceMark = faceMark;
Hat = hat;
Bottom = bottom;
Cape = cape;
Ears = ears;
Tail = tail;
}

public static CharacterJobTypeInfo[] JobTypes = new CharacterJobTypeInfo[]
{
new CharacterJobTypeInfo(CharacterJobType.UltimateAdventurer, false, 0, 100000000, ItemIds.BEGINNERS_GUIDE, true, true, false, false, true, false, false, false),
new CharacterJobTypeInfo(CharacterJobType.Resistance, true, 3000, 931000000, ItemIds.CITIZENS_GUIDE, false, true, false, false, false, false, false, false),
new CharacterJobTypeInfo(CharacterJobType.Adventurer, true, 0, 4000000, ItemIds.BEGINNERS_GUIDE, false, true, false, false, false, false, false, false),
new CharacterJobTypeInfo(CharacterJobType.Cygnus, true, 1000, 130030000, ItemIds.NOBLESS_GUIDE, false, true, false, false, false, true, false, false),
new CharacterJobTypeInfo(CharacterJobType.Aran, true, 2000, 914000000, ItemIds.LEGENDS_GUIDE, true, true, false, false, true, false, false, false),
new CharacterJobTypeInfo(CharacterJobType.Evan, true, 2001, 900010000, ItemIds.LEGENDS_GUIDE, true, true, false, false, true, false, false, false),
new CharacterJobTypeInfo(CharacterJobType.Mercedes, false, 2002, 910150000, 0, false, false, false, false, false, false, false, false),
new CharacterJobTypeInfo(CharacterJobType.Demon, false, 3001, 931050310, 0, false, false, true, false, false, false, false, false),
new CharacterJobTypeInfo(CharacterJobType.Phantom, false, 2003, 915000000, 0, false, true, false, false, false, true, false, false),
new CharacterJobTypeInfo(CharacterJobType.DualBlade, false, 0, 103050900, ItemIds.BEGINNERS_GUIDE, false, true, false, false, false, false, false, false),
new CharacterJobTypeInfo(CharacterJobType.Mihile, false, 5000, 913070000, 0, true, true, false, false, true, false, false, false),
new CharacterJobTypeInfo(CharacterJobType.Luminous, false, 2004, 931030000, 0, false, true, false, false, false, true, false, false),
new CharacterJobTypeInfo(CharacterJobType.Kaiser, false, 6000, 940001000, 0, false, true, false, false, false, false, false, false),
new CharacterJobTypeInfo(CharacterJobType.AngelicBuster, false, 6001, 940011000, 0, false, true, false, false, false, false, false, false),
new CharacterJobTypeInfo(CharacterJobType.Cannoneer, true, 0, 3000000, ItemIds.BEGINNERS_GUIDE, true, true, false, false, true, false, false, false),
new CharacterJobTypeInfo(CharacterJobType.Xenon, false, 3002, 931050920, 0, true, true, true, false, false, false, false, false),
new CharacterJobTypeInfo(CharacterJobType.Zero, false, 10112, 321000000, 0, false, true, false, false, false, true, false, false),
new CharacterJobTypeInfo(CharacterJobType.Shade, false, 2005, 927030050, 0, false, true, false, false, true, true, false, false),
new CharacterJobTypeInfo(CharacterJobType.Zen, false, 0, 552000050, 0, false, false, false, false, false, true, false, false),
new CharacterJobTypeInfo(CharacterJobType.Jett, false, 0, 552000050, 0, false, false, false, false, false, true, false, false),
new CharacterJobTypeInfo(CharacterJobType.Hayato, false, 4001, 807000000, 0, true, true, false, true, false, false, false, false),
new CharacterJobTypeInfo(CharacterJobType.Kanna, false, 4002, 807040000, 0, true, true, false, true, false, false, false, false),
new CharacterJobTypeInfo(CharacterJobType.BeastTamer, false, 11212, 866000000, 0, false, true, true, false, false, false, true, true),
new CharacterJobTypeInfo(CharacterJobType.PinkBean, false, 13100, 866000000, 0, false, false, false, false, false, false, false, false),
new CharacterJobTypeInfo(CharacterJobType.Kinesis, false, 14000, 331001110, 0, false, true, false, false, false, false, false, false),
new CharacterJobTypeInfo(CharacterJobType.NULL, false, 0, 999999999, 0, false, false, false, false, false, false, false, false)
};

/// <summary>
/// Gets the job info by jobId & maplestory localisation
/// </summary>
/// <param name="job"></param>
/// <param name="msLocalisation"></param>
/// <returns></returns>
public static CharacterJobTypeInfo GetByJobId(int job, MapleStoryLocalisation msLocalisation)
{
if (job == JobTypes[(int)CharacterJobType.Adventurer].JobId)
{
return JobTypes[(int)CharacterJobType.Adventurer];
}
if (job == 508)
{
if (msLocalisation == MapleStoryLocalisation.MapleStoryGlobal)
{
return JobTypes[(int)CharacterJobType.Jett];
}
else if (msLocalisation == MapleStoryLocalisation.MapleStorySEA)
{
return JobTypes[(int)CharacterJobType.Zen];
}
else
{
return JobTypes[(int)CharacterJobType.NULL];
}
}
foreach (var jobType in JobTypes)
{
if ((int)jobType.Type == job)
{
return jobType;
}
}
return JobTypes[(int)CharacterJobType.NULL];
}

public static CharacterJobTypeInfo GetByType(int g)
{
if (g == (int)CharacterJobType.Cannoneer)
{
return JobTypes[(int)CharacterJobType.Adventurer];
}
foreach (var jobType in JobTypes)
{
if ((int)jobType.Type == g)
{
return jobType;
}
}
return null;
}
}
}
32 changes: 32 additions & 0 deletions MapleLib/WzLib/WzStructure/Data/ItemStructure/ItemIds.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*Copyright(c) 2024, LastBattle https://github.com/lastbattle/Harepacker-resurrected
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.
*/

namespace MapleLib.WzLib.WzStructure.Data.ItemStructure
{
public class ItemIds
{
public const int
BEGINNERS_GUIDE = 4161001,
NOBLESS_GUIDE = 4161047,
LEGENDS_GUIDE = 4161048,
CITIZENS_GUIDE = 4161054;
}
}

0 comments on commit abcd860

Please sign in to comment.