public static List<Mission> generateAvailableMissions(Ninja n, List<Mission> allMissions) { if (n == null || allMissions == null) return null; List<Mission> available = new ArrayList<Mission>(); for (int missionRolls = (n.getLevel() / 5) + 3; missionRolls > 0; missionRolls--) { int chance = Roller.roll(100); if (chance < 10) { continue; } else { addMission("D", allMissions, available); } } return available; }
public static Ninja levelUp(Ninja n) { if (n.getExpNeeded() > n.getExpCurrent()) return null; n.setExpCurrent(n.getExpCurrent() - n.getExpNeeded()); n.setExpNeeded(n.getExpNeeded() + ((n.getExpNeeded() * 4) / 10)); n.setLevel(n.getLevel() + 1); try { NinjaDAO dao = new NinjaDAO(); dao.update(n); dao.close(); } catch (Exception e) { e.printStackTrace(); } return n; }