From: Kimmo R. <ki...@us...> - 2009-04-01 13:17:44
|
Update of /cvsroot/arianne/stendhal/tests/games/stendhal/server/maps/quests In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv16910/tests/games/stendhal/server/maps/quests Modified Files: HouseBuyingTest.java Log Message: start testing the house buying part too Index: HouseBuyingTest.java =================================================================== RCS file: /cvsroot/arianne/stendhal/tests/games/stendhal/server/maps/quests/HouseBuyingTest.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** HouseBuyingTest.java 1 Apr 2009 11:08:49 -0000 1.9 --- HouseBuyingTest.java 1 Apr 2009 13:17:35 -0000 1.10 *************** *** 6,9 **** --- 6,13 ---- import static org.junit.Assert.assertTrue; import games.stendhal.server.core.engine.SingletonRepository; + import games.stendhal.server.entity.item.Item; + import games.stendhal.server.entity.mapstuff.chest.StoredChest; + import games.stendhal.server.entity.mapstuff.portal.HousePortal; + import games.stendhal.server.entity.mapstuff.portal.Portal; import games.stendhal.server.entity.npc.SpeakerNPC; import games.stendhal.server.entity.npc.fsm.Engine; *************** *** 16,24 **** import utilities.ZonePlayerAndNPCTestImpl; - /** - * Test buying ice cream. - * - * @author Martin Fuchs - */ public class HouseBuyingTest extends ZonePlayerAndNPCTestImpl { --- 20,23 ---- *************** *** 26,33 **** --- 25,40 ---- private static final String ZONE_NAME2 = "int_ados_town_hall_3"; private static final String ZONE_NAME3 = "int_kirdneh_townhall"; + + private static final String[] CITY_ZONES = { + "0_kalavan_city", + "0_kirdneh_city", + "0_ados_city_n", + "0_ados_city" }; @BeforeClass public static void setUpBeforeClass() throws Exception { QuestHelper.setUpBeforeClass(); + HousePortal.generateRPClass(); + StoredChest.generateRPClass(); setupZone(ZONE_NAME); *************** *** 35,38 **** --- 42,49 ---- setupZone(ZONE_NAME3); + for (String zone : CITY_ZONES) { + setupZone(zone); + } + SpeakerNPC taxman = new SpeakerNPC("Mr Taxman"); SingletonRepository.getNPCList().add(taxman); *************** *** 61,67 **** assertEquals("Goodbye.", npc.get("text")); } ! @Test ! public void testBuyHouse() { final SpeakerNPC npc = getNPC("Reg Denson"); final Engine en = npc.getEngine(); --- 72,78 ---- assertEquals("Goodbye.", npc.get("text")); } ! @Test ! public void testGeneralStuff() { final SpeakerNPC npc = getNPC("Reg Denson"); final Engine en = npc.getEngine(); *************** *** 78,81 **** --- 89,101 ---- assertTrue(en.step(player, "quest")); assertEquals("You may buy houses from me, please ask the #cost if you are interested. Perhaps you would first like to view our brochure, #http://arianne.sourceforge.net/wiki/index.php?title=StendhalHouses.", npc.get("text")); + } + + @Test + public void testBuyHouse() { + final SpeakerNPC npc = getNPC("Reg Denson"); + final Engine en = npc.getEngine(); + + assertTrue(en.step(player, "hi")); + assertEquals("Hello, player.", npc.get("text")); assertTrue(en.step(player, "cost")); *************** *** 97,122 **** + " every month. If you have a house in mind, please tell me the number now. I will check availability. " + "The Ados houses are numbered from 50 to 68.", npc.getText()); ! //TODO mf - finish house buying test ! // assertTrue(en.step(player, "really")); ! // assertEquals("Sorry, I don't sell someunknownthings.", npc.get("text")); ! // ! // assertTrue(en.step(player, "buy house")); ! // assertEquals("1 house will cost 30. Do you want to buy it?", npc.get("text")); ! // ! // assertTrue(en.step(player, "yes")); ! // assertEquals("Sorry, you don't have enough money!", npc.get("text")); ! // ! // // equip with enough money ! // assertTrue(equipWithMoney(player, 500000)); ! // ! // assertFalse(player.isEquipped("house")); ! // ! // assertTrue(en.step(player, "yes")); ! // assertEquals("Congratulations! Here is your house!", npc.get("text")); ! // assertTrue(player.isEquipped("house", 1)); ! // ! // assertTrue(en.step(player, "buy house")); ! // assertEquals("1 house will cost 30. Do you want to buy it?", npc.get("text")); } --- 117,157 ---- + " every month. If you have a house in mind, please tell me the number now. I will check availability. " + "The Ados houses are numbered from 50 to 68.", npc.getText()); + + // add a portal to the maps so that there's something to check and sell + Portal destination = new Portal(); + destination.setIdentifier("dest"); + SingletonRepository.getRPWorld().getRPZone(ZONE_NAME).add(destination); + StoredChest chest = new StoredChest(); + SingletonRepository.getRPWorld().getRPZone(ZONE_NAME).add(chest); + + for (String zone : CITY_ZONES) { + HousePortal portal = new HousePortal("Ados house 50"); + portal.setDestination(ZONE_NAME, "dest"); + SingletonRepository.getRPWorld().getRPZone(zone).add(portal); + } + + assertTrue(en.step(player, "50")); + assertEquals("You do not have enough money to buy a house!", npc.getText()); + + player.equip(SingletonRepository.getEntityManager().getItem("money"), 120000); + + // don't answer anything + assertFalse(en.step(player, "42")); + + assertTrue(en.step(player, "buy")); + assertTrue(en.step(player, "50")); + assertEquals("Congratulations, here is your key to house 50! Make sure you change the locks if you ever lose it." + + " Do you want to buy a spare key, at a price of 1000 money?", npc.getText()); ! assertTrue(player.isEquipped("house key")); ! ! Item item = player.getFirstEquipped("house key"); ! assertNotNull(item); ! assertEquals("ados house 50;0;player", item.get("infostring")); ! assertFalse(item.isBound()); ! ! assertTrue(en.step(player, "no")); ! assertEquals("No problem! Just so you know, if you need to #change your locks, I can do that, " ! + "and you can also #resell your house to me if you want to.", npc.get("text")); } |