mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-12-26 05:17:47 +01:00
class selection now redirects you to the subclass you took last time. this does not work well with subclass nets yet but does delete data randomly at least
This commit is contained in:
parent
a30851c7d2
commit
a8ffe80e50
@ -267,6 +267,20 @@ public class PlayerClass extends PostLoadObject {
|
||||
return subclasses;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursive method which checks if the given class
|
||||
* is a child of the current class in the 'subclass tree'.
|
||||
*
|
||||
* @param profess Some player class
|
||||
* @return If given class is a subclass of the current class
|
||||
*/
|
||||
public boolean hasSubclass(PlayerClass profess) {
|
||||
for (Subclass sub : subclasses)
|
||||
if (sub.getProfess().equals(profess) || sub.getProfess().hasSubclass(profess))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasSkill(Skill skill) {
|
||||
return hasSkill(skill.getId());
|
||||
}
|
||||
|
@ -121,8 +121,33 @@ public class ClassSelect extends EditableInventory {
|
||||
return;
|
||||
}
|
||||
|
||||
InventoryManager.CLASS_CONFIRM.newInventory(playerData, profess, this).open();
|
||||
InventoryManager.CLASS_CONFIRM.newInventory(playerData, findDeepestSubclass(playerData, profess), this).open();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* When switching from a class where you had progress before,
|
||||
* you should be instantly redirected to the highest subclass
|
||||
* in the subclass tree that you chose, because your progress
|
||||
* is saved there.
|
||||
* <p>
|
||||
* It's also more RPG style to take the player back to the subclass
|
||||
* he chose because that way he can't turn back and chose another path.
|
||||
*
|
||||
* This does NOT function properly with subclass nets yet.
|
||||
*
|
||||
* @param root The root class, it's called the root because since the
|
||||
* player was able to choose it in the class GUI, it should
|
||||
* be at the bottom of the class tree.
|
||||
*/
|
||||
private PlayerClass findDeepestSubclass(PlayerData player, PlayerClass root) {
|
||||
for (String checkedName : player.getSavedClasses()) {
|
||||
PlayerClass checked = MMOCore.plugin.classManager.getOrThrow(checkedName);
|
||||
if (root.hasSubclass(checked))
|
||||
return checked;
|
||||
}
|
||||
|
||||
return root;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user