Search in sources :

Example 1 with SaveGame

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

the class ScreenTest method create.

@Override
public void create() {
    Skin skin = new Skin(Gdx.files.internal("assets/skin/uiskin.json"));
    SaveGame sg = new SaveGame();
    try {
        sg.read(Constants.PARTY_SAV_BASE_FILENAME);
    } catch (Exception e) {
        e.printStackTrace();
    }
    Party party = new Party(sg);
    party.getMember(0).getPlayer().mp = 999;
    for (Constants.Spell sp : Constants.Spell.values()) {
        party.getSaveGame().mixtures[sp.ordinal()] = 99;
    }
    sg.reagents = new int[] { 90, 93, 94, 90, 90, 90, 90, 90 };
    // setScreen(new MixtureScreen(null, null, skin, party));
    setScreen(new BookScreen(null, null, skin));
}
Also used : Party(objects.Party) SaveGame(objects.SaveGame) BookScreen(ultima.BookScreen) Constants(ultima.Constants) Skin(com.badlogic.gdx.scenes.scene2d.ui.Skin)

Example 2 with SaveGame

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

the class TestJaxb method testReadSaveGame.

// @Test
public void testReadSaveGame() throws Exception {
    InputStream is = new FileInputStream(Constants.PARTY_SAV_BASE_FILENAME);
    LittleEndianDataInputStream dis = new LittleEndianDataInputStream(is);
    SaveGame sg = new SaveGame();
    sg.read(dis);
    // SaveGame.SaveGamePlayerRecord avatar = sg.new SaveGamePlayerRecord();
    // avatar.name = "paul";
    // avatar.hp = 199;
    // 
    // sg.food = 30000;
    // sg.gold = 200;
    // sg.reagents[Reagent.GINSENG.ordinal()] = 3;
    // sg.reagents[Reagent.GARLIC.ordinal()] = 4;
    // sg.reagents[Reagent.NIGHTSHADE.ordinal()] = 9;
    // sg.reagents[Reagent.MANDRAKE.ordinal()] = 6;
    // sg.torches = 2;
    // 
    // sg.players[0] = avatar;
    // 
    // sg.write(Constants.PARTY_SAV_BASE_FILENAME);
    Party p = new Party(sg);
    // for (int i=0;i<8;i++)
    // System.err.println(Virtue.get(i) + " " + sg.karma[i]);
    // System.err.println("---------------");
    p.adjustKarma(KarmaAction.ATTACKED_GOOD);
    // System.err.println(Virtue.get(i) + " " + sg.karma[i]);
    for (int i = 0; i < 8; i++) {
        Virtue v = Constants.Virtue.get(i);
        String st = ((sg.stones & (1 << i)) > 0 ? "+STONE" : "");
        String ru = ((sg.runes & (1 << i)) > 0 ? "+RUNE" : "");
    // System.err.println(v + " " + st + " " + ru);
    }
    System.err.println("---------------");
    sg.runes |= Virtue.HUMILITY.getLoc();
    for (int i = 0; i < 8; i++) {
        Virtue v = Constants.Virtue.get(i);
        String st = ((sg.stones & (1 << i)) > 0 ? "+STONE" : "");
        String ru = ((sg.runes & (1 << i)) > 0 ? "+RUNE" : "");
    // System.err.println(v + " " + st + " " + ru);
    }
    sg.items |= Item.BELL.getLoc();
    for (Item item : Constants.Item.values()) {
    // System.err.println((sg.items & (1 << item.ordinal())) > 0 ? item.getDesc() : "") ;
    }
    sg.items |= Item.PARCH.getLoc();
    for (Item item : Constants.Item.values()) {
        System.err.println((sg.items & item.getLoc()) > 0 ? item.getDesc() : "");
    }
    sg.lastrage = 1;
    sg.write("test.sav");
}
Also used : Item(ultima.Constants.Item) Party(objects.Party) LittleEndianDataInputStream(com.google.common.io.LittleEndianDataInputStream) SaveGame(objects.SaveGame) LittleEndianDataInputStream(com.google.common.io.LittleEndianDataInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) Virtue(ultima.Constants.Virtue) FileInputStream(java.io.FileInputStream)

Example 3 with SaveGame

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

the class TestMain method create.

@Override
public void create() {
    try {
        Ultima4 ult = new Ultima4();
        ult.create();
        Context context = new Context();
        SaveGame sg = new SaveGame();
        try {
            sg.read(Constants.PARTY_SAV_BASE_FILENAME);
        } catch (Exception e) {
            e.printStackTrace();
        }
        Party party = new Party(sg);
        context.setParty(party);
        context.setCurrentMap(Maps.WORLD.getMap());
        sg.players[0].hpMax = 700;
        party.join(NpcDefaults.Geoffrey.name());
        sg.items |= Constants.Item.MASK_MINAX.getLoc();
        sg.items |= Constants.Item.RAGE_GOD.getLoc();
        sg.players[0].weapon = WeaponType.SLING;
        TiledMap tmap = new UltimaTiledMapLoader(Maps.BRUSH_CON, Ultima4.standardAtlas, Maps.BRUSH_CON.getMap().getWidth(), Maps.BRUSH_CON.getMap().getHeight(), 32, 32).load();
        CombatScreen sc = new CombatScreen(null, context, Maps.WORLD, Maps.BRUSH_CON.getMap(), tmap, CreatureType.troll, Ultima4.creatures, Ultima4.standardAtlas);
        setScreen(sc);
        // atlas = a1;
        // tr = Utils.peerGem(Maps.LYCAEUM, a1);
        batch2 = new SpriteBatch();
        TextureAtlas atlas = new TextureAtlas(Gdx.files.internal("sprites-atlas.txt"));
        a1 = new Animation(0.45f, atlas.findRegions("shallows"));
        TextureRegion[] frames = a1.getKeyFrames();
        a2 = new Animation(0.45f, atlas.findRegions("water"));
    // a3 = new Animation(0.45f, atlas.findRegions("sea"));
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : Context(ultima.Context) Ultima4(ultima.Ultima4) SaveGame(objects.SaveGame) UltimaTiledMapLoader(util.UltimaTiledMapLoader) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) CombatScreen(ultima.CombatScreen) TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) Party(objects.Party) TextureAtlas(com.badlogic.gdx.graphics.g2d.TextureAtlas) Animation(com.badlogic.gdx.graphics.g2d.Animation) TiledMap(com.badlogic.gdx.maps.tiled.TiledMap)

Example 4 with SaveGame

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

the class VendorTest method testReagentVendor.

// @Test
public void testReagentVendor() 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 ReagentService(vcs.getVendor(InventoryType.REAGENT, 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) ReagentService(vendor.ReagentService) BufferedReader(java.io.BufferedReader) Unmarshaller(javax.xml.bind.Unmarshaller) File(java.io.File) VendorClassSet(vendor.VendorClassSet)

Example 5 with SaveGame

use of objects.SaveGame 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()]);
    }
}
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) WeaponVendor(vendor.WeaponVendor) WeaponType(ultima.Constants.WeaponType) BufferedReader(java.io.BufferedReader) 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