01-26-2014, 01:32 PM
Как сделать назначение SocialClass'a в зависимости от славы? У меня сделана такая фишка:
[SRC="java"]public class FameManager
{
public static enum Rank
{
Vagabond("Новичок", 0, 1, 1),
Vassal("Солдат", 50, 3, 3),
Apprentice("Сержант", 100, 5, 5),
Heir("Лейтенант", 300, 7, 7),
Knight("Капитан", 600, 10, 10),
Elder("Герой", 1000, 25, 25);
public final String _name;
public final int needPoints;
public final int _pointsLoss, _pointsGain;
Rank(String name, int minPoints, int pointsLoss, int pointsGain)
{
_name = name;
needPoints = minPoints;
_pointsLoss = pointsLoss;
_pointsGain = pointsGain;
}
public static Rank getRankForPlayer(L2PcInstance player)
{
for(Rank r : Rank.values())
{
if(player.getFame() >= r.needPoints)
return r;
}
return Vagabond;
}
}
}[/SRC]
[SRC="java"]public class FameManager
{
public static enum Rank
{
Vagabond("Новичок", 0, 1, 1),
Vassal("Солдат", 50, 3, 3),
Apprentice("Сержант", 100, 5, 5),
Heir("Лейтенант", 300, 7, 7),
Knight("Капитан", 600, 10, 10),
Elder("Герой", 1000, 25, 25);
public final String _name;
public final int needPoints;
public final int _pointsLoss, _pointsGain;
Rank(String name, int minPoints, int pointsLoss, int pointsGain)
{
_name = name;
needPoints = minPoints;
_pointsLoss = pointsLoss;
_pointsGain = pointsGain;
}
public static Rank getRankForPlayer(L2PcInstance player)
{
for(Rank r : Rank.values())
{
if(player.getFame() >= r.needPoints)
return r;
}
return Vagabond;
}
}
}[/SRC]