Search in sources :

Example 1 with Item

use of ultima.Constants.Item 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)

Aggregations

LittleEndianDataInputStream (com.google.common.io.LittleEndianDataInputStream)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 Party (objects.Party)1 SaveGame (objects.SaveGame)1 Item (ultima.Constants.Item)1 Virtue (ultima.Constants.Virtue)1