From: Katie R. <ky...@us...> - 2012-04-24 15:41:05
|
Update of /cvsroot/arianne/stendhal/src/games/stendhal/server/entity/npc/action In directory vz-cvs-4.sog:/tmp/cvs-serv22258/src/games/stendhal/server/entity/npc/action Modified Files: SayNPCNamesForUnstartedQuestsAction.java Log Message: format the list of npc names a bit nicer by splitting into regions. if all quests are done in a certain region/regions then those regions get listed at the end Index: SayNPCNamesForUnstartedQuestsAction.java =================================================================== RCS file: /cvsroot/arianne/stendhal/src/games/stendhal/server/entity/npc/action/SayNPCNamesForUnstartedQuestsAction.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SayNPCNamesForUnstartedQuestsAction.java 20 Apr 2012 17:24:49 -0000 1.3 --- SayNPCNamesForUnstartedQuestsAction.java 24 Apr 2012 15:41:03 -0000 1.4 *************** *** 27,31 **** /** ! * says the list of the npc names for unstarted quests in a specified region in the form npc1, npc2, and npc3 all need your help. */ public class SayNPCNamesForUnstartedQuestsAction implements ChatAction { --- 27,31 ---- /** ! * Says the list of the NPC names for unstarted quests in a specified region in the form npc1, npc2, and npc3 all need your help. */ public class SayNPCNamesForUnstartedQuestsAction implements ChatAction { *************** *** 52,69 **** public void fire(final Player player, final Sentence sentence, final EventRaiser raiser) { ! List<String> npcs = new LinkedList<String>(); for (String region: regions) { ! List<String> npcsInRegion = SingletonRepository.getStendhalQuestSystem().getNPCNamesForUnstartedQuestsInRegionForLevel(player, region); ! npcs.addAll(npcsInRegion); } ! String verb = "need"; ! if (npcs.size()==1) { ! verb = "needs"; ! } ! if (npcs.size()>0) { ! raiser.say(Grammar.enumerateCollectionWithHash(npcs) + " " + verb + " your help."); ! } else { ! raiser.say("You have already embarked upon all quests which you can handle, near " + Grammar.enumerateCollection(regions) + "."); ! } } --- 52,80 ---- public void fire(final Player player, final Sentence sentence, final EventRaiser raiser) { ! // to build up the message the npc will say ! StringBuilder sb = new StringBuilder(); ! // capture the regions with no quests remaining so that we can list them all at the end ! List<String> finishedregions = new LinkedList<String>(); ! for (String region: regions) { ! // to hold the list of npcs for each region ! List<String> npcs = SingletonRepository.getStendhalQuestSystem().getNPCNamesForUnstartedQuestsInRegionForLevel(player, region); ! String verb = "need"; ! if (npcs.size()==1) { ! verb = "needs"; ! } ! if (npcs.size()>0) { ! sb.append("In " + region + " "); ! sb.append(Grammar.enumerateCollectionWithHash(npcs)); ! sb.append(" " + verb + " your help. "); ! } else { ! finishedregions.add(region); ! } } ! if (finishedregions.size() > 0) { ! sb.append("You've already helped everyone in " + Grammar.enumerateCollection(finishedregions) + " who'd have a task you can handle. "); ! } ! raiser.say(sb.toString().trim()); ! } |