From: Hendrik <nh...@us...> - 2006-11-24 22:23:58
|
Update of /cvsroot/arianne/stendhal/src/games/stendhal/server/maps/ados In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv22920/src/games/stendhal/server/maps/ados Modified Files: Deathmatch.java Log Message: compiles now Index: Deathmatch.java =================================================================== RCS file: /cvsroot/arianne/stendhal/src/games/stendhal/server/maps/ados/Deathmatch.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Deathmatch.java 24 Nov 2006 16:10:44 -0000 1.1 --- Deathmatch.java 24 Nov 2006 22:23:56 -0000 1.2 *************** *** 10,14 **** --- 10,18 ---- import games.stendhal.server.scripting.*; import games.stendhal.server.entity.npc.*; + import games.stendhal.server.events.TurnListener; + import games.stendhal.server.events.TurnNotifier; import games.stendhal.server.pathfinder.Path; + import games.stendhal.server.StendhalRPAction; + import games.stendhal.server.StendhalRPRuleProcessor; import games.stendhal.server.StendhalRPWorld; import games.stendhal.server.StendhalRPZone; *************** *** 24,36 **** */ public class Deathmatch { private NPCList npcs = NPCList.get(); ! private StendhalScriptSystem scripts = StendhalScriptSystem.get(); ! class DeathmatchCondition extends ScriptCondition { ! Player player; ! public DeathmatchCondition (Player player) { this.player = player; } ! public boolean fire() { if("cancel".equals(player.getQuest("deathmatch"))) { return false; --- 28,52 ---- */ public class Deathmatch { + private static Logger logger = Logger.getLogger(Deathmatch.class); private NPCList npcs = NPCList.get(); ! private StendhalRPZone zone = null; ! class ScriptAction implements TurnListener { ! private Player player; ! private List<Creature> sortedCreatures; ! private List<Creature> spawnedCreatures = new ArrayList<Creature>(); ! private boolean keepRunning = true; ! public ScriptAction(Player player) { this.player = player; + Collection<Creature> creatures = StendhalRPWorld.get().getRuleManager().getEntityManager().getCreatures(); + sortedCreatures.addAll(creatures); + Collections.sort(sortedCreatures, new Comparator<Creature>() { + public int compare(Creature o1, Creature o2) { + return o1.getLevel() - o2.getLevel(); + } + }); } ! ! public boolean condition() { if("cancel".equals(player.getQuest("deathmatch"))) { return false; *************** *** 47,67 **** } } ! } ! /* ! class DeathmatchAction extends ScriptAction { ! Player player; ! List<Creature> sortedCreatures; ! List<Creature> spawnedCreatures = new ArrayList<Creature>(); ! public DeathmatchAction (Player player) { ! this.player = player; ! Collection<Creature> creatures = StendhalRPWorld.get().getRuleManager().getEntityManager().getCreatures(); ! sortedCreatures.addAll(creatures); ! Collections.sort(sortedCreatures, new Comparator<Creature>() { ! public int compare(Creature o1, Creature o2) { ! return o1.getLevel() - o2.getLevel(); ! } ! }); } ! public void fire() { String questInfo = player.getQuest("deathmatch"); String[] tokens = (questInfo + ";0;0").split(";"); --- 63,76 ---- } } ! public void onTurnReached(int currentTurn, String message) { ! if (condition()) { ! action(); ! } ! if (keepRunning) { ! TurnNotifier.get().notifyInTurns(0, this, null); ! } } ! ! public void action() { String questInfo = player.getQuest("deathmatch"); String[] tokens = (questInfo + ";0;0").split(";"); *************** *** 108,112 **** } // and finally remove this ScriptAction ! game.remove(this); return; } --- 117,121 ---- } // and finally remove this ScriptAction ! keepRunning = false; return; } *************** *** 135,139 **** int x = player.getX() + 1; int y = player.getY() + 1; ! game.add(creature, x, y); break; } --- 144,148 ---- int x = player.getX() + 1; int y = player.getY() + 1; ! add(zone, creature, x, y); break; } *************** *** 143,147 **** questState = "victory"; // remove this ScriptAction since we're done ! game.remove(this); } } else { --- 152,156 ---- questState = "victory"; // remove this ScriptAction since we're done ! keepRunning = false; } } else { *************** *** 171,175 **** int x = player.getX(); int y = player.getY(); ! Creature mycreature = game.add(creatureToSpawn, x, y); if (mycreature != null) { mycreature.clearDropItemList(); --- 180,184 ---- int x = player.getX(); int y = player.getY(); ! Creature mycreature = add(zone, creatureToSpawn, x, y); if (mycreature != null) { mycreature.clearDropItemList(); *************** *** 194,199 **** } player.setQuest("deathmatch", "start;"+ level + ";" + (new Date()).getTime()); ! Pair<ScriptCondition, ScriptAction> script = scripts.addScript( ! new DeathmatchCondition(player), new DeathmatchAction(player)); } } --- 203,208 ---- } player.setQuest("deathmatch", "start;"+ level + ";" + (new Date()).getTime()); ! ScriptAction scriptingAction = new ScriptAction(player); ! TurnNotifier.get().notifyInTurns(0, scriptingAction, null); } } *************** *** 293,297 **** String myZone = "int_semos_deathmatch"; StendhalRPWorld world = StendhalRPWorld.get(); ! StendhalRPZone zone = (StendhalRPZone) world.getRPZone(new IRPZone.ID(myZone)); // show the player the potential trophy --- 302,306 ---- String myZone = "int_semos_deathmatch"; StendhalRPWorld world = StendhalRPWorld.get(); ! zone = (StendhalRPZone) world.getRPZone(new IRPZone.ID(myZone)); // show the player the potential trophy *************** *** 355,358 **** zone.addNPC(npc); } ! */ } --- 364,380 ---- zone.addNPC(npc); } ! ! private Creature add(StendhalRPZone zone, Creature template, int x, int y) { ! Creature creature = template.getInstance(); ! zone.assignRPObjectID(creature); ! if (StendhalRPAction.placeat(zone, creature, x, y)) { ! zone.add(creature); ! StendhalRPRuleProcessor.get().addNPC(creature); ! } else { ! logger.info(" could not add a creature: " + creature); ! creature = null; ! } ! return creature; ! } ! } |