}
}
protected ScriptableObject createPlayer(final String username)
throws GameEngineException {
Step step = MiniProfiler.step("API.createPlayer");
try {
// createPlayer
final ScriptableObject player = (ScriptableObject) ge.invoke(
"Player", new String[] { username, });
final LinkedHashMap<String, ScriptableObject[]> disks = new LinkedHashMap<String, ScriptableObject[]>();
// Knights
// Pikemen
disks.put("Pikemen",
new ScriptableObject[] { createPoint(-3.2, -6.2),
createPoint(-1.2, -5), createPoint(-2.6, -3.6), });
// Heavy Horse Cavalry
disks.put("Heavy Horse Cavalry", new ScriptableObject[] {
createPoint(-4.5, -4.5), createPoint(-5.7, -2.9),
createPoint(-4.1, -1.7), createPoint(-6, -.8) });
// Elf
// Deepwood Warriors x3
disks.put("Deepwood Warriors", new ScriptableObject[] {
createPoint(3.6, -6.4), createPoint(2.4, -5.4),
createPoint(3.6, -3.8), });
// Riders of the Wood x4
disks.put("Riders of the Wood", new ScriptableObject[] {
createPoint(4.6, -5.4), createPoint(6.5, -4.0),
createPoint(5.1, -2.1), createPoint(6.5, -.6) });
// Deepwood Archers x2
disks.put("Deepwood Archers",
new ScriptableObject[] { createPoint(7.5, -2.3),
createPoint(8.8, -1) });
// Dwarf
// Damlo Hammerfist
disks.put("Damlo Hammerfist",
new ScriptableObject[] { createPoint(-8.7, 1.3), });
// Grovan of the Deep
disks.put("Grovan of the Deep",
new ScriptableObject[] { createPoint(-9.7, 2.2), });
// Stalwarts x1
disks.put("Stalwarts",
new ScriptableObject[] { createPoint(-9.1, 3.8), });
// Regiment of the Anvil x5
disks.put("Regiment of the Anvil",
new ScriptableObject[] { createPoint(-7.6, 2.9),
createPoint(-6.8, 4.2), createPoint(-8.2, 5),
createPoint(-7.2, 6.5), createPoint(-5.7, 5.7), });
// Orc
// Urgg the Really Mean x1[+][-]
disks.put("Urgg the Really Mean",
new ScriptableObject[] { createPoint(9.4, 1.3), });
// Shieldgrogs x2[+][-]
disks.put("Shieldgrogs",
new ScriptableObject[] { createPoint(9.8, 3.4),
createPoint(10.5, 2.5), });
// Ghash Zzurkan x1[+][-]
disks.put("Ghash Zzurkan",
new ScriptableObject[] { createPoint(8.4, 2.5), });
// Grugs x5
disks.put("Grugs",
new ScriptableObject[] { createPoint(6.6, 6.7),
createPoint(6.6, 5), createPoint(7.9, 6.1),
createPoint(7.5, 3.8), createPoint(8.8, 4.8), });
// Dragon
// Dragonflight
disks.put(
"Dragonflight",
new ScriptableObject[] { createPoint(-3, 7),
createPoint(-3, 8.5), createPoint(-1.5, 8.5),
createPoint(-1.5, 7) });
// Drake Warriors
disks.put(
"Drake Warriors",
new ScriptableObject[] { createPoint(0, 7),
createPoint(0, 8.5), createPoint(1.5, 8.5), });
// Dragonling
disks.put("Dragonling", new ScriptableObject[] {
createPoint(1.5, 7), createPoint(3, 7),
createPoint(3, 8.5), });
final String knights = "Starter Knights";
final String elves = "Starter Elf";
final String dwarfs = "Starter Dwarf";
final String dragons = "Starter Dragons";
final String orcs = "Starter Orc";
for (final Entry<String, ScriptableObject[]> entry : disks
.entrySet()) {
final ScriptableObject disk = getDisk(entry.getKey());
if (disk.get("name") != null) {
for (final ScriptableObject location : entry.getValue()) {
// addDisk
Object diskNumber = ge.invoke(player, "addDisk",
new Object[] { disk, location });
// knight disk
if (disk.get("faction").equals("Knight")) {
ge.invoke(player, "addDiskToArmy", new Object[] {
knights, diskNumber, location });
}
// dragon disk
else if (disk.get("faction").equals("Dragon")) {
ge.invoke(player, "addDiskToArmy", new Object[] {
dragons, diskNumber, location });
}
// dwarf disk
else if (disk.get("faction").equals("Dwarf")) {
ge.invoke(player, "addDiskToArmy", new Object[] {
dwarfs, diskNumber, location });
}
// elf disk
else if (disk.get("faction").equals("Elf")) {
ge.invoke(player, "addDiskToArmy", new Object[] {
elves, diskNumber, location });
}
// orc disk
else if (disk.get("faction").equals("Orc")) {
ge.invoke(player, "addDiskToArmy", new Object[] {
orcs, diskNumber, location });
}
}
}
}
savePlayer(player);
return player;
} finally {
step.close();
}
}