From: Katie <ky...@us...> - 2008-08-20 23:00:03
|
Update of /cvsroot/arianne/stendhal/src/games/stendhal/server/entity/item/scroll In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv20653/src/games/stendhal/server/entity/item/scroll Modified Files: RainbowBeansScroll.java Log Message: Pdiddi sells the beans every 6 hours so playrs could still stockpile them if they don't use them right away, hence also store the time they were used and make player sick if they use them again too soon (with real live vomit on the ground, yummy). ensured compatibity with old versions Index: RainbowBeansScroll.java =================================================================== RCS file: /cvsroot/arianne/stendhal/src/games/stendhal/server/entity/item/scroll/RainbowBeansScroll.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** RainbowBeansScroll.java 12 Jul 2008 14:43:56 -0000 1.7 --- RainbowBeansScroll.java 20 Aug 2008 23:00:12 -0000 1.8 *************** *** 4,7 **** --- 4,12 ---- package games.stendhal.server.entity.item.scroll; + import games.stendhal.common.MathHelper; + import games.stendhal.server.core.engine.SingletonRepository; + import games.stendhal.server.entity.item.Item; + import games.stendhal.server.entity.player.Player; + import java.util.Map; *************** *** 11,15 **** */ public class RainbowBeansScroll extends TimedTeleportScroll { ! /** * Creates a new timed marked RainbowBeansScroll scroll. --- 16,22 ---- */ public class RainbowBeansScroll extends TimedTeleportScroll { ! ! private static final long DELAY = 6 * MathHelper.MILLISECONDS_IN_ONE_HOUR; ! /** * Creates a new timed marked RainbowBeansScroll scroll. *************** *** 34,38 **** super(item); } ! @Override protected String getBeforeReturnMessage() { --- 41,83 ---- super(item); } ! ! @Override ! protected boolean useTeleportScroll(final Player player) { ! final String QUEST_SLOT = "rainbow_beans"; ! long lastuse = -1; ! if (player.hasQuest(QUEST_SLOT)){ ! final String[] tokens = player.getQuest(QUEST_SLOT).split(";"); ! if (tokens.length == 4) { ! // we stored a last time (or -1) ! lastuse = Long.parseLong(tokens[3]); ! } ! final long timeRemaining = (lastuse + DELAY) - System.currentTimeMillis(); ! if (timeRemaining > 0){ ! // player used the beans within the last DELAY hours ! // so are not allowed to go yet. but don't reset the last time taken. ! // the private text doesn't get sent because events are lost on zone change. (marauroa bug) ! player.sendPrivateText("You were just sick from overuse of the rainbow beans. Classy!"); ! this.removeOne(); ! final Item sick = SingletonRepository.getEntityManager().getItem("vomit"); ! player.getZone().add(sick); ! sick.setPosition(player.getX(), player.getY()+1); ! return false; ! } else { ! // don't overwrite the last bought time from Pdiddi, this is in tokens[1] ! player.setQuest(QUEST_SLOT,"bought;"+tokens[1]+";taken;" + System.currentTimeMillis()); ! return super.useTeleportScroll(player); ! } ! } else { ! // players can only buy rainbow beans from Pdiddi who stores the time bought in quest slot ! // so if they didn't have the quest slot they got the beans ''illegally'' ! player.sendPrivateText("Those dodgy beans made you sick. Next time buy them from Pdiddi."); ! this.removeOne(); ! final Item sick = SingletonRepository.getEntityManager().getItem("vomit"); ! player.getZone().add(sick); ! sick.setPosition(player.getX(), player.getY()+1); ! return false; ! } ! } ! @Override protected String getBeforeReturnMessage() { |