public Character nextCharacter(int playerId, Character selectedDwarf) {
        if (mapping.isEmpty())
            return null;

        ArrayList<Character> options = new ArrayList<Character>();

        for (Character character: mapping.values())
            if (character.playerId() == playerId)
                options.add(character);

        if (options.size() == 0)
            return null;

        if ((selectedDwarf != null) && (!mapping.containsKey(selectedDwarf.id())))
            selectedDwarf = null;

        if (selectedDwarf == null) {
            Random random = new Random();
            return options.get(random.nextInt(options.size()));
        }

        Collections.sort(options, new Comparator<Character>() {
            public int compare(Character o1, Character o2) {
                return o1.id().compareTo(o2.id());
            }
        });

        int idx = 0;

        for (int i = 0; i < options.size(); ++i) {
            if (options.get(i).id().equals(selectedDwarf.id()))
                idx = i;
        }
        idx = (idx + 1) % options.size();

        return options.get(idx);
    }