From: omero <nyl...@us...> - 2012-04-15 11:09:53
|
Update of /cvsroot/arianne/stendhal/src/games/stendhal/server/entity/npc/behaviour/journal In directory vz-cvs-4.sog:/tmp/cvs-serv11890/src/games/stendhal/server/entity/npc/behaviour/journal Modified Files: ProducerRegister.java Log Message: included multiproducers in getWorkingProducerNames() and getProductionDetails() for travel log production informations panel Index: ProducerRegister.java =================================================================== RCS file: /cvsroot/arianne/stendhal/src/games/stendhal/server/entity/npc/behaviour/journal/ProducerRegister.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** ProducerRegister.java 14 Apr 2012 18:49:42 -0000 1.14 --- ProducerRegister.java 15 Apr 2012 11:09:50 -0000 1.15 *************** *** 26,35 **** public class ProducerRegister { ! private static ProducerRegister instance; ! private final List<Pair<String, ProducerBehaviour>> producers; private final List<Pair<String, MultiProducerBehaviour>> multiproducers; ! public static ProducerRegister get() { if (instance == null) { --- 26,35 ---- public class ProducerRegister { ! private static ProducerRegister instance; ! private final List<Pair<String, ProducerBehaviour>> producers; private final List<Pair<String, MultiProducerBehaviour>> multiproducers; ! public static ProducerRegister get() { if (instance == null) { *************** *** 44,48 **** multiproducers = new LinkedList<Pair<String, MultiProducerBehaviour>>(); } ! /** * Adds an NPC to the NPCList. Does nothing if an NPC with the same name --- 44,48 ---- multiproducers = new LinkedList<Pair<String, MultiProducerBehaviour>>(); } ! /** * Adds an NPC to the NPCList. Does nothing if an NPC with the same name *************** *** 68,85 **** multiproducers.add(pair); } ! public List<Pair<String, ProducerBehaviour>> getProducers() { return producers; } ! public List<Pair<String, MultiProducerBehaviour>> getMultiProducers() { return multiproducers; } ! public String listWorkingProducers(final Player player) { final StringBuilder sb = new StringBuilder(""); // Open orders - do not state if ready to collect or not, yet - for (final Pair<String, ProducerBehaviour> producer : producers) { String npcName = producer.first(); --- 68,84 ---- multiproducers.add(pair); } ! public List<Pair<String, ProducerBehaviour>> getProducers() { return producers; } ! public List<Pair<String, MultiProducerBehaviour>> getMultiProducers() { return multiproducers; } ! public String listWorkingProducers(final Player player) { final StringBuilder sb = new StringBuilder(""); // Open orders - do not state if ready to collect or not, yet for (final Pair<String, ProducerBehaviour> producer : producers) { String npcName = producer.first(); *************** *** 100,107 **** + " " + Grammar.quantityplnoun(amount, product, "a") + " and will be ready in " + timeleft + "."); } - } } - for (final Pair<String, MultiProducerBehaviour> producer : multiproducers) { String npcName = producer.first(); --- 99,104 ---- *************** *** 109,112 **** --- 106,110 ---- String questSlot = behaviour.getQuestSlot(); String activity = behaviour.getProductionActivity(); + // Retrieve all production details from the questSlot if (player.hasQuest(questSlot) && !player.isQuestCompleted(questSlot)) { final String orderString = player.getQuest(questSlot); *************** *** 127,131 **** } } - if (!"".equals(sb.toString())) { sb.insert(0,"\r\nOrders: "); --- 125,128 ---- *************** *** 136,160 **** } - public List<String> getWorkingProducerNames(final Player player) { - List<String> res = new LinkedList<String>(); - - for (final Pair<String, ProducerBehaviour> producer : producers) { - String npcName = producer.first(); - ProducerBehaviour behaviour = producer.second(); - String questSlot = behaviour.getQuestSlot(); - if (player.hasQuest(questSlot) && !player.isQuestCompleted(questSlot)) { - if (behaviour.isOrderReady(player)) { - // put all completed orders first - player wants to collect these! - res.add(0, npcName); - } else { - res.add(npcName); - } - - } - } - - return res; - } - /** * gets description of the production --- 133,136 ---- *************** *** 175,213 **** return ""; } ! /** ! * gets details on the progress of the production * ! * @param player player to get the details for ! * @param npcName name of quest ! * @return details */ ! public List<String> getProductionDetails(final Player player, final String npcName) { ! List<String> res = new LinkedList<String>(); for (final Pair<String, ProducerBehaviour> producer : producers) { ! if(npcName.equals(producer.first())) { ! ProducerBehaviour behaviour = producer.second(); ! String questSlot = behaviour.getQuestSlot(); String activity = behaviour.getProductionActivity(); ! String product = behaviour.getProductName(); ! if (player.hasQuest(questSlot) && !player.isQuestCompleted(questSlot)) { ! int amount = behaviour.getNumberOfProductItems(player); ! if (behaviour.isOrderReady(player)) { ! // put all completed orders first - player wants to collect these! ! res.add(npcName + " has finished " + Grammar.gerundForm(activity) ! + " your " + Grammar.plnoun(amount,product) + "."); ! } else { ! String timeleft = behaviour.getApproximateRemainingTime(player); ! // put all ongoing orders last ! res.add("\n" + npcName + " is " + Grammar.gerundForm(activity) ! + " " + Grammar.quantityplnoun(amount, product, "a") + " and will be ready in " + timeleft + "."); ! } ! ! } } } ! return res; } ! /** * gets names of all items produced, which are of the given item class (i.e. food, drink) --- 151,178 ---- return ""; } ! /** ! * gets description of the produced item * ! * Note: if more than one NPC makes the item, just the details of the first NPC in the list who makes it are returned ! * ! * @param itemName produced item ! * @return details about the produced item */ ! public String getProducedItemDetails(final String itemName) { for (final Pair<String, ProducerBehaviour> producer : producers) { ! ProducerBehaviour behaviour = producer.second(); ! String product = behaviour.getProductName(); ! ! if(itemName.equals(product)) { ! String npcName = producer.first(); String activity = behaviour.getProductionActivity(); ! String resources = behaviour.getRequiredResourceNames(1); ! return npcName + " " + Grammar.plural(activity) + " " + Grammar.plural(product) + ", which need " + resources + " each."; } } ! return ""; } ! /** * gets names of all items produced, which are of the given item class (i.e. food, drink) *************** *** 228,297 **** return res; } ! ! /** ! * gets description of the produced item ! * ! * Note: if more than one NPC makes the item, just the details of the first NPC in the list who makes it are returned ! * ! * @param itemName produced item ! * @return details about the produced item ! */ ! public String getProducedItemDetails(final String itemName) { for (final Pair<String, ProducerBehaviour> producer : producers) { ProducerBehaviour behaviour = producer.second(); ! String product = behaviour.getProductName(); ! ! if(itemName.equals(product)) { ! String npcName = producer.first(); ! String activity = behaviour.getProductionActivity(); ! String resources = behaviour.getRequiredResourceNames(1); ! return npcName + " " + Grammar.plural(activity) + " " + Grammar.plural(product) + ", which need " + resources + " each."; } } - return ""; - } - - public String listWorkingMultiProducers(final Player player) { - final StringBuilder sb = new StringBuilder(""); - - // Open orders - do not state if ready to collect or not, yet - for (final Pair<String, MultiProducerBehaviour> producer : multiproducers) { String npcName = producer.first(); MultiProducerBehaviour behaviour = producer.second(); String questSlot = behaviour.getQuestSlot(); - String activity = behaviour.getProductionActivity(); - - //String product = behaviour.getProductName(); - if (player.hasQuest(questSlot) && !player.isQuestCompleted(questSlot)) { - - final String orderString = player.getQuest(questSlot); - final String[] order = orderString.split(";"); - //final long orderTime = Long.parseLong(order[2]); - final int amount = Integer.parseInt(order[0]); - final String product = order[1]; - if (behaviour.isOrderReady(player)) { // put all completed orders first - player wants to collect these! ! sb.insert(0,"\n" + npcName + " has finished " + Grammar.gerundForm(activity) ! + " your " + Grammar.plnoun(amount,product) + "."); } else { ! String timeleft = behaviour.getApproximateRemainingTime(player); ! // put all ongoing orders last ! sb.append("\n" + npcName + " is " + Grammar.gerundForm(activity) ! + " " + Grammar.quantityplnoun(amount, product, "a") + " and will be ready in " + timeleft + "."); } - } } ! if (!"".equals(sb.toString())) { ! sb.insert(0,"\r\nOrders: "); ! } else { ! sb.append("You have no ongoing or uncollected orders."); } ! return sb.toString(); } ! } --- 193,285 ---- return res; } ! ! public List<String> getWorkingProducerNames(final Player player) { ! List<String> res = new LinkedList<String>(); for (final Pair<String, ProducerBehaviour> producer : producers) { + String npcName = producer.first(); ProducerBehaviour behaviour = producer.second(); ! String questSlot = behaviour.getQuestSlot(); ! if (player.hasQuest(questSlot) && !player.isQuestCompleted(questSlot)) { ! if (behaviour.isOrderReady(player)) { ! // put all completed orders first - player wants to collect these! ! res.add(0, npcName); ! } else { ! res.add(npcName); ! } } } for (final Pair<String, MultiProducerBehaviour> producer : multiproducers) { String npcName = producer.first(); MultiProducerBehaviour behaviour = producer.second(); String questSlot = behaviour.getQuestSlot(); if (player.hasQuest(questSlot) && !player.isQuestCompleted(questSlot)) { if (behaviour.isOrderReady(player)) { // put all completed orders first - player wants to collect these! ! res.add(0, npcName); } else { ! res.add(npcName); } } } + return res; + } ! /** ! * gets details on the progress of the production ! * ! * @param player player to get the details for ! * @param npcName name of quest ! * @return details ! */ ! public List<String> getProductionDetails(final Player player, final String npcName) { ! List<String> res = new LinkedList<String>(); ! for (final Pair<String, ProducerBehaviour> producer : producers) { ! if(npcName.equals(producer.first())) { ! ProducerBehaviour behaviour = producer.second(); ! String questSlot = behaviour.getQuestSlot(); ! String activity = behaviour.getProductionActivity(); ! String product = behaviour.getProductName(); ! if (player.hasQuest(questSlot) && !player.isQuestCompleted(questSlot)) { ! int amount = behaviour.getNumberOfProductItems(player); ! if (behaviour.isOrderReady(player)) { ! // put all completed orders first - player wants to collect these! ! res.add(npcName + " has finished " + Grammar.gerundForm(activity) ! + " your " + Grammar.plnoun(amount,product) + "."); ! } else { ! String timeleft = behaviour.getApproximateRemainingTime(player); ! // put all ongoing orders last ! res.add("\n" + npcName + " is " + Grammar.gerundForm(activity) ! + " " + Grammar.quantityplnoun(amount, product, "a") + " and will be ready in " + timeleft + "."); ! } ! } ! } } ! for (final Pair<String, MultiProducerBehaviour> producer : multiproducers) { ! if(npcName.equals(producer.first())) { ! MultiProducerBehaviour behaviour = producer.second(); ! String questSlot = behaviour.getQuestSlot(); ! String activity = behaviour.getProductionActivity(); ! // Retrieve all production details from the questSlot ! if (player.hasQuest(questSlot) && !player.isQuestCompleted(questSlot)) { ! final String orderString = player.getQuest(questSlot); ! final String[] order = orderString.split(";"); ! //final long orderTime = Long.parseLong(order[2]); ! final int amount = Integer.parseInt(order[0]); ! final String product = order[1]; ! if (behaviour.isOrderReady(player)) { ! // put all completed orders first - player wants to collect these! ! res.add(npcName + " has finished " + Grammar.gerundForm(activity) ! + " your " + Grammar.plnoun(amount,product) + "."); ! } else { ! String timeleft = behaviour.getApproximateRemainingTime(player); ! // put all ongoing orders last ! res.add("\n" + npcName + " is " + Grammar.gerundForm(activity) ! + " " + Grammar.quantityplnoun(amount, product, "a") + " and will be ready in " + timeleft + "."); ! } ! } ! } ! } ! return res; } ! } |