use of ultima.Context 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();
}
}
use of ultima.Context 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);
}
use of ultima.Context 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()]);
}
}
use of ultima.Context 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);
}
use of ultima.Context 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);
}
Aggregations