Search in sources :

Example 6 with Context

use of ultima.Context in project ultimate-java by pantinor.

the class VendorTest method testInnVendor.

// @Test
public void testInnVendor() 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 InnService(vcs.getVendor(InventoryType.INN, Maps.TRINSIC), 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) InnService(vendor.InnService) Unmarshaller(javax.xml.bind.Unmarshaller) File(java.io.File) VendorClassSet(vendor.VendorClassSet)

Example 7 with Context

use of ultima.Context in project ultimate-java by pantinor.

the class VendorTest method testHealer.

// @Test
public void testHealer() 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;
    rec.hpMax = 400;
    rec.status = StatusType.DEAD;
    SaveGame.SaveGamePlayerRecord rec2 = sg.new SaveGamePlayerRecord();
    rec2.name = "joe";
    rec2.hp = 50;
    rec2.hpMax = 400;
    rec.status = StatusType.POISONED;
    Party party = new Party(sg);
    Context context = new Context();
    context.setParty(party);
    party.addMember(rec);
    party.addMember(rec2);
    sg.gold = 50;
    sg.food = 200;
    BaseVendor v = new HealerService(vcs.getVendor(InventoryType.HEALER, 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);
    }
    String[] s = sg.getZstats();
    System.err.println(s[0]);
}
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) HealerService(vendor.HealerService) BufferedReader(java.io.BufferedReader) Unmarshaller(javax.xml.bind.Unmarshaller) File(java.io.File) VendorClassSet(vendor.VendorClassSet)

Aggregations

Party (objects.Party)7 SaveGame (objects.SaveGame)7 Context (ultima.Context)7 BufferedReader (java.io.BufferedReader)6 File (java.io.File)6 InputStreamReader (java.io.InputStreamReader)6 JAXBContext (javax.xml.bind.JAXBContext)6 Unmarshaller (javax.xml.bind.Unmarshaller)6 BaseVendor (vendor.BaseVendor)6 VendorClassSet (vendor.VendorClassSet)6 Animation (com.badlogic.gdx.graphics.g2d.Animation)1 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)1 TextureAtlas (com.badlogic.gdx.graphics.g2d.TextureAtlas)1 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)1 TiledMap (com.badlogic.gdx.maps.tiled.TiledMap)1 CombatScreen (ultima.CombatScreen)1 WeaponType (ultima.Constants.WeaponType)1 Ultima4 (ultima.Ultima4)1 UltimaTiledMapLoader (util.UltimaTiledMapLoader)1 GuildVendor (vendor.GuildVendor)1