public Reveal reparse(User user, int revealId) { if (user.hasAccess(SimConstants.RIGHTS_SITEADMIN)) { Reveal r = (Reveal) Reveal.get(Reveal.class, revealId); r.getCreatures().clear(); for (RevealCrit crit : PageParser.parseReveal(r.getUnparsed())) { r.addCreature(crit); } return r; } else { throw new SimException("access denied"); } }
public Reveal addReveal(User user, String character, String reveal) throws SimException { Reveal entity = null; Mage mage; String cq2class; Integer level; String kingdom; Integer forestSkill; Integer deathSkill; Integer airSkill; Integer earthSkill; Matcher match = Pattern.compile(PageParser.REGEXP_PLAYERINFO_REQUIRED, Pattern.DOTALL).matcher(character); if (match.find()) { mage = Mage.getOrCreateMage(match.group(1).replaceAll(",", "")); kingdom = match.group(2).replaceAll(",", ""); cq2class = match.group(3); level = Integer.parseInt(match.group(4)); } else if (user.getMage() != null && !user.getMage().equals("") && user.getMage().getKingdom() != null) { match = Pattern.compile(PageParser.REGEXP_CHARACTER_REQUIRED, Pattern.DOTALL).matcher(character); if (match.find()) { if (entity == null) { makeOld(user.getMage().getName()); entity = new Reveal(); } mage = user.getMage(); kingdom = user.getMage().getKingdom().getName(); cq2class = match.group(1); level = Integer.parseInt(match.group(2)); } else { throw new SimException( "Could not parse general mage information. Make sure you included the skills when you copy/paste!"); } } else { throw new SimException( "Could not parse general mage information. Make sure you included the skills when you copy/paste!"); } match = Pattern.compile(PageParser.REGEXP_PLAYERINFO_SKILLS, Pattern.DOTALL).matcher(character); if (match.find()) { forestSkill = Integer.parseInt(match.group(1)); deathSkill = Integer.parseInt(match.group(2)); airSkill = Integer.parseInt(match.group(3)); earthSkill = Integer.parseInt(match.group(4)); } else if (user.getMage() != null && !user.getMage().equals("") && user.getMage().getKingdom() != null) { match = Pattern.compile(PageParser.REGEXP_CHARACTER_SKILLS, Pattern.DOTALL).matcher(character); if (match.find()) { forestSkill = Integer.parseInt(match.group(1)); deathSkill = Integer.parseInt(match.group(2)); airSkill = Integer.parseInt(match.group(3)); earthSkill = Integer.parseInt(match.group(4)); } else { throw new SimException( "Could not parse general mage information. Make sure you included the skills when you copy/paste!"); } } else { throw new SimException( "Could not parse general mage information. Make sure you included the skills when you copy/paste!"); } return addReveal( user, mage, cq2class, level, kingdom, forestSkill, deathSkill, airSkill, earthSkill, reveal); }