Skip to content

Commit

Permalink
cleanups the constants project: (#90)
Browse files Browse the repository at this point in the history
- enforce whitespace consistency
- use object initializers
- use switch expressions
- extract check for evan job into method
  • Loading branch information
Bia10 authored Mar 12, 2024
1 parent a03dd77 commit ba5356e
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 121 deletions.
31 changes: 15 additions & 16 deletions src/common/Edelstein.Common.Constants/EXPTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,42 +20,41 @@ static EXPTable()
CharacterEXP[8] = 840;
CharacterEXP[9] = 1242;

for (var i = 10; i < 15; i++) CharacterEXP[i] = CharacterEXP[i - 1];

for (var i = 10; i < 15; i++)
CharacterEXP[i] = CharacterEXP[i - 1];
for (var i = 15; i < 30; i++)
CharacterEXP[i] = (int)(CharacterEXP[i - 1] * 1.2 + 0.5);
for (var i = 30; i < 35; i++) CharacterEXP[i] = CharacterEXP[i - 1];

for (var i = 30; i < 35; i++)
CharacterEXP[i] = CharacterEXP[i - 1];
for (var i = 35; i < 40; i++)
CharacterEXP[i] = (int)(CharacterEXP[i - 1] * 1.2 + 0.5);
for (var i = 40; i < 70; i++)
CharacterEXP[i] = (int)(CharacterEXP[i - 1] * 1.08 + 0.5);

for (var i = 70; i < 75; i++) CharacterEXP[i] = CharacterEXP[i - 1];

for (var i = 70; i < 75; i++)
CharacterEXP[i] = CharacterEXP[i - 1];
for (var i = 75; i < 120; i++)
CharacterEXP[i] = (int)(CharacterEXP[i - 1] * 1.07 + 0.5);

for (var i = 120; i < 125; i++) CharacterEXP[i] = CharacterEXP[i - 1];

for (var i = 120; i < 125; i++)
CharacterEXP[i] = CharacterEXP[i - 1];
for (var i = 125; i < 160; i++)
CharacterEXP[i] = (int)(CharacterEXP[i - 1] * 1.07 + 0.5);
for (var i = 160; i < 200; i++)
CharacterEXP[i] = (int)(CharacterEXP[i - 1] * 1.06 + 0.5);

CharacterEXP[200] = 0;

PetTameness = new[]
{
PetTameness =
[
0x1, 0x3, 0x6, 0xE, 0x1F, 0x3C, 0x6C, 0x0B5, 0x11F, 0x1B2,
0x278, 0x37B, 0x4C8, 0x66A, 0x871, 0x0AE9, 0x0DE5, 0x1173, 0x15A6, 0x1A91,
0x2047, 0x26DE, 0x2E6A, 0x3704, 0x40C2, 0x4BBF, 0x5813, 0x65DA, 0x7530, 0x0
};
TamingMobTameness = new[]
{
];

TamingMobTameness =
[
0x0, 0x14, 0x2D, 0x4B, 0x6F, 0x99, 0x0C9, 0x100, 0x13F, 0x185,
0x1D3, 0x22A, 0x28B, 0x2F5, 0x36A, 0x3EB, 0x478, 0x511, 0x5B8, 0x66E,
0x734, 0x80A, 0x8F2, 0x9ED, 0x0AFC, 0x0C21, 0x0D5C, 0x0EB0, 0x101E, 0x11A8
};
];
}
}
2 changes: 1 addition & 1 deletion src/common/Edelstein.Common.Constants/ItemConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ WeaponType.ThrowingGlove or
WeaponType.Gun => 0.15,
_ => 0.20,
};

public static bool IsRechargeableItem(int id)
=> id / 10000 == 207 || id / 10000 == 233;
}
2 changes: 1 addition & 1 deletion src/common/Edelstein.Common.Constants/ItemGrade.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
public static class ItemGrade
{
public const int None = 0;

public const int Rare = 13;
public const int Epic = 14;
public const int Unique = 15;
Expand Down
38 changes: 19 additions & 19 deletions src/common/Edelstein.Common.Constants/Job.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
public static class Job
{
public const int Novice = 0;

public const int Swordman = 100;
public const int Fighter = 110;
public const int Crusader = 111;
Expand All @@ -14,7 +14,7 @@ public static class Job
public const int Spearman = 130;
public const int DragonKnight = 131;
public const int DarkKnight = 132;

public const int Magician = 200;
public const int WizardFirePoison = 210;
public const int MageFirePoison = 211;
Expand All @@ -25,15 +25,15 @@ public static class Job
public const int Cleric = 230;
public const int Priest = 231;
public const int Bishop = 232;

public const int Archer = 300;
public const int Hunter = 310;
public const int Ranger = 311;
public const int Bowmaster = 312;
public const int Crossbowman = 320;
public const int Sniper = 321;
public const int Crossbowmaster = 322;

public const int Rogue = 400;
public const int Assassin = 410;
public const int Hermit = 411;
Expand All @@ -46,54 +46,54 @@ public static class Job
public const int Dual3 = 432;
public const int Dual4 = 433;
public const int Dual5 = 434;

public const int Pirate = 500;
public const int Infighter = 510;
public const int Buccaneer = 511;
public const int Viper = 512;
public const int Gunslinger = 520;
public const int Valkyrie = 521;
public const int Captain = 522;

public const int Manager = 800;
public const int Admin = 900;
public const int AdminSuperGM = 910;
public const int AdminUserGM = 920;

public const int Noblesse = 1000;

public const int Soulfighter = 1100;
public const int Soulfighter2 = 1110;
public const int Soulfighter3 = 1111;
public const int Soulfighter4 = 1112;

public const int Flamewizard = 1200;
public const int Flamewizard2 = 1210;
public const int Flamewizard3 = 1211;
public const int Flamewizard4 = 1212;

public const int Windbreaker = 1300;
public const int Windbreaker2 = 1310;
public const int Windbreaker3 = 1311;
public const int Windbreaker4 = 1312;

public const int Nightwalker = 1400;
public const int Nightwalker2 = 1410;
public const int Nightwalker3 = 1411;
public const int Nightwalker4 = 1412;

public const int Striker = 1500;
public const int Striker2 = 1510;
public const int Striker3 = 1511;
public const int Striker4 = 1512;

public const int Legend = 2000;

public const int Aran = 2100;
public const int Aran2 = 2110;
public const int Aran3 = 2111;
public const int Aran4 = 2112;

public const int EvanJr = 2001;
public const int Evan = 2200;
public const int Evan2 = 2210;
Expand All @@ -105,19 +105,19 @@ public static class Job
public const int Evan8 = 2216;
public const int Evan9 = 2217;
public const int Evan10 = 2218;

public const int Citizen = 3000;

public const int Bmage = 3200;
public const int Bmage2 = 3210;
public const int Bmage3 = 3211;
public const int Bmage4 = 3212;

public const int Wildhunter = 3300;
public const int Wildhunter2 = 3310;
public const int Wildhunter3 = 3311;
public const int Wildhunter4 = 3312;

public const int Mechanic = 3500;
public const int Mechanic2 = 3510;
public const int Mechanic3 = 3511;
Expand Down
19 changes: 12 additions & 7 deletions src/common/Edelstein.Common.Constants/JobConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ public static int GetJobLevel(int job)
? (job - 430) / 2
: job % 10
) + 2;

return job % 1000 == 0 || job == 2001 ? 0 : 1;
}

public static int GetJobRace(int job)
=> job / 1000;

Expand All @@ -23,13 +24,17 @@ public static int GetJobBranch(int job)

public static int GetBeginnerJob(int job)
{
if (GetJobRace(job) == JobRace.Third && GetJobType(job) == JobType.Magician)
return Job.EvanJr;
if (IsThirdRaceMagician(job)) return Job.EvanJr;

return GetJobRace(job) * 1000;
}

public static bool IsExtendSPJob(int job)
=> GetJobRace(job) == JobRace.Resistance ||
GetJobRace(job) == JobRace.Third && GetJobType(job) == JobType.Magician ||
job == Job.EvanJr;
=> GetJobRace(job) == JobRace.Resistance || IsEvanJob(job);

public static bool IsThirdRaceMagician(int job)
=> GetJobRace(job) == JobRace.Third && GetJobType(job) == JobType.Magician;

public static bool IsEvanJob(int job)
=> IsThirdRaceMagician(job) || job == Job.EvanJr;
}
Loading

0 comments on commit ba5356e

Please sign in to comment.