не фонтан, но много более короткий вариант
[SRC="java"]
private static boolean checkAppearance(int classId, int sex, int hairStyle, int hairColor, int face)
{
if (sex < 0 || sex > 1 || face < 0 || face > 2 || hairStyle < 0 || hairStyle > 6 || hairColor < 0 || hairColor > 3)
return false;
if (!PlayerHairStyle.isAllowed(Sex.VALUES[sex], PlayerHairStyle.VALUES[hairStyle]) || !PlayerHairColor.isAllowed(ClassId.VALUES[classId].getRace(), PlayerHairColor.VALUES[hairColor]))
return false;
return true;
}
[/SRC]
и сами задействанные энумы PlayerHairStyle и PlayerHairColor
[SRC="java"]
package l2p.gameserver.enums;
import l2p.gameserver.network.serverpackets.components.SystemMsg;
import org.apache.commons.lang3.ArrayUtils;
public enum PlayerHairStyle
{
NONE(-1, null),
A(0, SystemMsg.THE_HAIR_STYLE_CHANGE_POTION__TYPE_A_IS_BEING_USED, Sex.MALE, Sex.FEMALE),
B(1, SystemMsg.THE_HAIR_STYLE_CHANGE_POTION__TYPE_B_IS_BEING_USED, Sex.MALE, Sex.FEMALE),
C(2, SystemMsg.THE_HAIR_STYLE_CHANGE_POTION__TYPE_C_IS_BEING_USED, Sex.MALE, Sex.FEMALE),
D(3, SystemMsg.THE_HAIR_STYLE_CHANGE_POTION__TYPE_D_IS_BEING_USED, Sex.MALE, Sex.FEMALE),
E(4, SystemMsg.THE_HAIR_STYLE_CHANGE_POTION__TYPE_E_IS_BEING_USED, Sex.MALE, Sex.FEMALE),
F(5, SystemMsg.THE_HAIR_STYLE_CHANGE_POTION__TYPE_F_IS_BEING_USED, Sex.FEMALE),
G(6, SystemMsg.THE_HAIR_STYLE_CHANGE_POTION__TYPE_G_IS_BEING_USED, Sex.FEMALE);
public static final PlayerHairStyle[] VALUES = values();
private final int _id;
private final SystemMsg _systemMsg;
private final Sex[] _sex;
private PlayerHairStyle(int id, SystemMsg systemMsg, Sex... sex)
{
_id = id;
_sex = sex;
_systemMsg = systemMsg;
}
public int getId()
{
return _id;
}
public SystemMsg getSystemMsg()
{
return _systemMsg;
}
public static boolean isAllowed(Sex sex, PlayerHairStyle hairStyle)
{
return ArrayUtils.contains(hairStyle._sex, sex);
}
}
package l2p.gameserver.enums;
import l2p.gameserver.network.serverpackets.components.SystemMsg;
import org.apache.commons.lang3.ArrayUtils;
public enum PlayerHairColor
{
NONE(-1, null),
A(0, SystemMsg.HAIR_DYE_POTION__TYPE_A_IS_BEING_APPLIED, Race.HUMAN, Race.ELF, Race.DARK_ELF, Race.ORC, Race.DWARF, Race.KAMAEL, Race.ERTHEIA),
B(1, SystemMsg.HAIR_DYE_POTION__TYPE_B_IS_BEING_APPLIED, Race.HUMAN, Race.ELF, Race.DARK_ELF, Race.ORC, Race.DWARF, Race.KAMAEL, Race.ERTHEIA),
C(2, SystemMsg.HAIR_DYE_POTION__TYPE_C_IS_BEING_APPLIED, Race.HUMAN, Race.ELF, Race.DARK_ELF, Race.ORC, Race.DWARF, Race.KAMAEL, Race.ERTHEIA),
D(3, SystemMsg.HAIR_DYE_POTION__TYPE_D_IS_BEING_APPLIED, Race.HUMAN, Race.ELF, Race.DARK_ELF, Race.ORC, Race.DWARF);
public static final PlayerHairColor[] VALUES = values();
private final int _id;
private final SystemMsg _systemMsg;
private final Race[] _race;
private PlayerHairColor(int id, SystemMsg systemMsg, Race... race)
{
_id = id;
_systemMsg = systemMsg;
_race = race;
}
public int getId()
{
return _id;
}
public SystemMsg getSystemMsg()
{
return _systemMsg;
}
public static boolean isAllowed(Race race, PlayerHairColor hairColor)
{
return ArrayUtils.contains(hairColor._race, race);
}
}
[/SRC]
З.Ы. эти энумы у меня изначально не для этих проверок, а задействованы в скиллах для поушнов смены причесок и т.п., потому и куча параметров и всего такого. но так как в целом эти же энумы подходят и для проверок при создании перса, то к чему плодить сущности