From: MadMetzger <mad...@us...> - 2012-05-13 13:22:52
|
Update of /cvsroot/arianne/stendhal/src/games/stendhal/server/entity/player In directory vz-cvs-4.sog:/tmp/cvs-serv25969/src/games/stendhal/server/entity/player Modified Files: Player.java Log Message: every time someone casts a spell, the skill for the spell's nature is increased Index: Player.java =================================================================== RCS file: /cvsroot/arianne/stendhal/src/games/stendhal/server/entity/player/Player.java,v retrieving revision 1.361 retrieving revision 1.362 diff -C2 -d -r1.361 -r1.362 *** Player.java 19 Jan 2012 23:38:52 -0000 1.361 --- Player.java 13 May 2012 13:22:50 -0000 1.362 *************** *** 24,27 **** --- 24,28 ---- import games.stendhal.common.ItemTools; import games.stendhal.common.KeyedSlotUtil; + import games.stendhal.common.Level; import games.stendhal.common.MathHelper; import games.stendhal.common.NotificationType; *************** *** 31,34 **** --- 32,36 ---- import games.stendhal.common.constants.SoundLayer; import games.stendhal.common.parser.WordList; + import games.stendhal.server.core.engine.GameEvent; import games.stendhal.server.core.engine.SingletonRepository; import games.stendhal.server.core.engine.StendhalRPZone; *************** *** 682,685 **** --- 684,727 ---- return getKeyedSlot("skills", key); } + + /** + * Get the current value for the skill of a magic nature + * @param nature the nature to get the skill for + * @return current skill value + */ + public int getMagicSkill(final Nature nature) { + int skillValue = 0; + String skill = getSkill(nature.toString()); + if(skill != null) { + try { + Integer skillInteger = Integer.parseInt(skill); + skillValue = skillInteger.intValue(); + } catch (NumberFormatException e) { + logger.error(e, e); + } + } + return skillValue; + } + + /** + * Increase the skill points for a magic nature by a given amount + * @param nature + * @param amount + */ + public void increaseMagicSkill(final Nature nature, int amount) { + int oldValue = getMagicSkill(nature); + int newValue = oldValue + amount; + // Handle level changes + final int newLevel = Level.getLevel(newValue); + final int levels = newLevel - (Level.getLevel(oldValue) - 10); + + // In case we level up several levels at a single time. + for (int i = 0; i < Math.abs(levels); i++) { + // set in map + // log event + } + setSkill(nature.toString(), + Integer.valueOf(newValue).toString()); + } /** |