use of objects.SaveGame 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]);
}
use of objects.SaveGame in project ultimate-java by pantinor.
the class GameScreen method show.
@Override
public void show() {
Gdx.input.setInputProcessor(new InputMultiplexer(this, stage));
gameTimer.active = true;
// load save game if initializing
if (context == null) {
context = new Context();
SaveGame sg = new SaveGame();
try {
sg.read(PARTY_SAV_BASE_FILENAME);
} catch (Exception e) {
e.printStackTrace();
}
LordBritishConversation.saveGame = sg;
Party party = new Party(sg);
context.setParty(party);
context.loadJournalEntries();
// party.getMember(0).getPlayer().klass = ClassType.MAGE;
// party.getMember(0).getPlayer().xp = 899;
// party.getMember(0).getPlayer().hp = 999;
// party.getMember(0).getPlayer().hpMax = 999;
// party.getMember(0).getPlayer().intel = 99;
// party.getMember(0).getPlayer().mp = 999;
// sg.reagents = new int[]{90, 93, 94, 90, 90, 90, 90, 90};
// for (Spell sp : Spell.values()) {
// party.getSaveGame().mixtures[sp.ordinal()] = 99;
// }
// for (Virtue v : Virtue.values()) {
// sg.karma[v.ordinal()] = 0;
// }
//
// party.join(NpcDefaults.Geoffrey.name());
// party.join(NpcDefaults.Shamino.name());
// party.join(NpcDefaults.Katrina.name());
// party.join(NpcDefaults.Mariah.name());
// party.join(NpcDefaults.Dupre.name());
// party.join(NpcDefaults.Iolo.name());
// party.join(NpcDefaults.Julia.name());
// party.join(NpcDefaults.Jaana.name());
//
// sg.food = 30000;
// sg.gold = 999;
// sg.keys = 20;
// sg.gems = 15;
// sg.moves = 2800;
// sg.stones = 0xff;
// sg.runes = 0xff;
// sg.items = 0xff;
// sg.sextants = 1;
// party.getMember(0).getPlayer().status = StatusType.GOOD;
// party.getMember(0).getPlayer().weapon = WeaponType.MAGICAXE;
// party.getMember(0).getPlayer().armor = ArmorType.MYSTICROBE;
// for (int i = 1; i < 16; i++) {
// party.getSaveGame().weapons[i] = 2;
// }
// for (int i = 1; i < 8; i++) {
// party.getSaveGame().armor[i] = 2;
// }
// mainAvatar = shipAnim;
// sg.transport = 0x10;
// sg.items |= Constants.Item.IRON_ORE.getLoc();
// sg.items |= Constants.Item.RUNE_MOLD.getLoc();
// sg.items |= Constants.Item.BOOK.getLoc();
// load the surface world first
loadNextMap(Maps.WORLD, sg.x, sg.y);
// load the dungeon if save game starts in dungeon
if (Maps.get(sg.location) != Maps.WORLD) {
loadNextMap(Maps.get(sg.location), sg.x, sg.y, sg.x, sg.y, sg.dnglevel, Direction.getByValue(sg.orientation + 1), true);
// loadNextMap(Maps.ABYSS, 0, 0, 5, 5, 0, Direction.SOUTH, true);
// loadNextMap(Maps.DESTARD, 0, 0, 3, 5, 3, Direction.SOUTH, true);
// loadNextMap(Maps.DELVE_SORROWS, 0, 0, 3, 19, 1, Direction.EAST, true);
}
for (Virtue v : Virtue.values()) {
v.adjustProgress(sg.karma[v.ordinal()]);
}
party.setTransport(Ultima4.baseTileSet.getTileByIndex(sg.transport));
switch(sg.transport) {
case 31:
mainAvatar = avatarAnim;
break;
case 16:
case 17:
case 18:
case 19:
mainAvatar = shipAnim;
break;
case 20:
case 21:
mainAvatar = horseAnim;
break;
case 24:
mainAvatar = balloonAnim;
break;
}
if (sg.balloonfound == 1 && context.getTransportContext() != TransportContext.BALLOON) {
addBalloonActor(sg.balloonx, sg.balloony);
}
// load objects to surface stage
for (int i = 0; i < 24; i++) {
if (sg.objects_save_tileids[i] != 0 && sg.objects_save_x[i] != 0 && sg.objects_save_y[i] != 0) {
Tile t = Ultima4.baseTileSet.getTileByIndex(sg.objects_save_tileids[i] & 0xff);
Drawable d = new Drawable(Maps.WORLD.getMap(), sg.objects_save_x[i] & 0xff, sg.objects_save_y[i] & 0xff, t, Ultima4.standardAtlas);
Vector3 v = getMapPixelCoords(sg.objects_save_x[i] & 0xff, sg.objects_save_y[i] & 0xff);
d.setX(v.x);
d.setY(v.y);
mapObjectsStage.addActor(d);
}
}
// load monsters to surface map
for (int i = 0; i < 8; i++) {
if (sg.monster_save_tileids[i] != 0 && sg.monster_save_x[i] != 0 && sg.monster_save_y[i] != 0) {
Tile t = Ultima4.baseTileSet.getTileByIndex(sg.monster_save_tileids[i] & 0xff);
Creature cr = Ultima4.creatures.getInstance(CreatureType.get(t.getName()), Ultima4.standardAtlas);
cr.currentX = sg.monster_save_x[i] & 0xff;
cr.currentY = sg.monster_save_y[i] & 0xff;
cr.currentPos = getMapPixelCoords(cr.currentX, cr.currentY);
Maps.WORLD.getMap().addCreature(cr);
}
}
}
context.getParty().addObserver(this);
}
Aggregations