Search in sources :

Example 6 with SaveGame

use of objects.SaveGame in project ultimate-java by pantinor.

the class VendorTest method testFoodVendor.

// @Test
public void testFoodVendor() 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 = 20;
    BaseVendor v = new GuildVendor(vcs.getVendor(InventoryType.GUILDITEM, Maps.BUCCANEERS_DEN), 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) GuildVendor(vendor.GuildVendor) Unmarshaller(javax.xml.bind.Unmarshaller) File(java.io.File) VendorClassSet(vendor.VendorClassSet)

Example 7 with SaveGame

use of objects.SaveGame in project ultimate-java by pantinor.

the class TestJaxb method testCreateParty.

// @Test
public void testCreateParty() throws Exception {
    SaveGame sg = new SaveGame();
    sg.read("D:\\ultima\\ULTIMA4\\" + Constants.PARTY_SAV_BASE_FILENAME);
    Party p = new Party(sg);
    assert (true);
}
Also used : Party(objects.Party) SaveGame(objects.SaveGame)

Example 8 with SaveGame

use of objects.SaveGame in project ultimate-java by pantinor.

the class TestJaxb method testStartQuestions.

// @Test
public void testStartQuestions() throws Exception {
    Map<ClassType, Integer> dist = new HashMap<>();
    for (ClassType ct : ClassType.values()) {
        dist.put(ct, 0);
    }
    for (int z = 0; z < 100; z++) {
        StartScreen.questionRound = 0;
        StartScreen.initQuestionTree();
        System.out.println("INIT\n");
        for (int i = 0; i < 15; i++) {
            System.out.println(i + ") " + Virtue.get(StartScreen.questionTree[i]));
        }
        while (!StartScreen.doQuestion(new Random().nextInt(2))) {
            printQuestionDesc(StartScreen.questionRound);
        }
        // System.out.println("\nANSWERS\n");
        // for (int i = 0; i < 15; i++) {
        // System.out.println(i + ") " +Virtue.get(StartScreen.questionTree[i]));
        // }
        SaveGame sg = new SaveGame();
        SaveGame.SaveGamePlayerRecord avatar = sg.new SaveGamePlayerRecord();
        avatar.adjuestAttribsPerKarma(StartScreen.questionTree);
        avatar.klass = ClassType.get(StartScreen.questionTree[14]);
        int[] questionTree = StartScreen.questionTree;
        // System.out.println(avatar.klass);
        dist.put(avatar.klass, dist.get(avatar.klass) + 1);
    }
    for (ClassType ct : ClassType.values()) {
        System.out.println(ct + " " + dist.get(ct));
    }
}
Also used : Random(java.util.Random) XORShiftRandom(util.XORShiftRandom) HashMap(java.util.HashMap) SaveGame(objects.SaveGame) ClassType(ultima.Constants.ClassType)

Example 9 with SaveGame

use of objects.SaveGame 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)

Example 10 with SaveGame

use of objects.SaveGame 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)

Aggregations

SaveGame (objects.SaveGame)12 Party (objects.Party)11 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 InputMultiplexer (com.badlogic.gdx.InputMultiplexer)1 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 TiledMapTile (com.badlogic.gdx.maps.tiled.TiledMapTile)1 StaticTiledMapTile (com.badlogic.gdx.maps.tiled.tiles.StaticTiledMapTile)1 Vector3 (com.badlogic.gdx.math.Vector3)1 Skin (com.badlogic.gdx.scenes.scene2d.ui.Skin)1