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);
}
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);
}
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));
}
}
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);
}
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);
}
Aggregations