private void updateMageByReveal(Reveal r) { Kingdom kd = Kingdom.loadByName(r.getKingdom()); if (kd == null) { kd = new Kingdom(); kd.setName(r.getKingdom()); kd.saveOrUpdate(); } Mage m = r.getMage(); m.setCq2class(r.getMageClass()); m.setLevel(r.getLevel()); m.setKingdom(kd); m.saveOrUpdate(); }
public Reveal addReveal( User user, Mage mage, String cq2class, Integer level, String kingdom, Integer forestSkill, Integer deathSkill, Integer airSkill, Integer earthSkill, String reveal) throws SimException { Reveal entity = null; makeOld(mage.getName()); entity = new Reveal(); entity.setUser(user); entity.setMage(mage); entity.setKingdom(kingdom); entity.setMageClass(cq2class); entity.setLevel(level); entity.setForestSkill(forestSkill); entity.setDeathSkill(deathSkill); entity.setAirSkill(airSkill); entity.setEarthSkill(earthSkill); entity.setUnparsed(reveal); entity.setTime(new Date()); entity.saveOrUpdate(); entity.getCreatures().clear(); for (RevealCrit crit : PageParser.parseReveal(entity.getUnparsed())) { entity.addCreature(crit); } updateMageByReveal(entity); return entity; }
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); }