Search in sources :

Example 1 with HorseService

use of vendor.HorseService in project ultimate-java by pantinor.

the class VendorTest method testHorseVendor.

// @Test
public void testHorseVendor() throws Exception {
    File file = new File("assets/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 = 500;
    BaseVendor v = new HorseService(vcs.getVendor(InventoryType.HORSE, Maps.PAWS), 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);
}
Also used : Context(ultima.Context) JAXBContext(javax.xml.bind.JAXBContext) BaseVendor(vendor.BaseVendor) InputStreamReader(java.io.InputStreamReader) SaveGame(objects.SaveGame) JAXBContext(javax.xml.bind.JAXBContext) Party(objects.Party) BufferedReader(java.io.BufferedReader) Unmarshaller(javax.xml.bind.Unmarshaller) File(java.io.File) VendorClassSet(vendor.VendorClassSet) HorseService(vendor.HorseService)

Aggregations

BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 InputStreamReader (java.io.InputStreamReader)1 JAXBContext (javax.xml.bind.JAXBContext)1 Unmarshaller (javax.xml.bind.Unmarshaller)1 Party (objects.Party)1 SaveGame (objects.SaveGame)1 Context (ultima.Context)1 BaseVendor (vendor.BaseVendor)1 HorseService (vendor.HorseService)1 VendorClassSet (vendor.VendorClassSet)1