use of vendor.WeaponVendor in project ultimate-java by pantinor.
the class VendorTest method testWeaponVendor.
// @Test
public void testWeaponVendor() throws Exception {
File file = new File("target/classes/xml/vendor.xml");
JAXBContext jaxbContext = JAXBContext.newInstance(VendorClassSet.class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
VendorClassSet vcs = (VendorClassSet) jaxbUnmarshaller.unmarshal(file);
vcs.init();
SaveGame sg = new SaveGame();
SaveGame.SaveGamePlayerRecord rec = sg.new SaveGamePlayerRecord();
rec.name = "avatar";
rec.hp = 200;
Party party = new Party(sg);
Context context = new Context();
context.setParty(party);
party.addMember(rec);
sg.gold = 25;
sg.food = 200;
party.getSaveGame().weapons[WeaponType.SLING.ordinal()] = 5;
party.getSaveGame().weapons[WeaponType.MAGICAXE.ordinal()] = 5;
BaseVendor v = new WeaponVendor(vcs.getVendor(InventoryType.WEAPON, Maps.BRITAIN), context);
while (true) {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
if (!v.nextDialog()) {
break;
}
String input = br.readLine();
if (input != null && input.equals("bye")) {
break;
}
v.setResponse(input);
}
System.err.println("sg gold = " + sg.gold);
for (WeaponType wt : WeaponType.values()) {
System.err.println(wt.toString() + " count=" + sg.weapons[wt.ordinal()]);
}
}
Aggregations