use of pl.themolka.arcade.region.Region in project Arcade2 by ShootGame.
the class WoolFactory method parseWoolXml.
public Wool parseWoolXml(CaptureGame game, Element xml, Wool wool) {
DyeColor color;
try {
String input = xml.getAttributeValue("color");
if (input == null) {
return null;
}
color = DyeColor.valueOf(XMLParser.parseEnumValue(xml.getAttributeValue("color")));
} catch (IllegalArgumentException ex) {
return null;
}
Element monumentElement = xml.getChild("monument");
Region monument = monumentElement != null ? XMLRegion.parseUnion(game.getGame(), monumentElement) : null;
if (monument == null) {
return null;
}
// setup
wool.setColor(color);
wool.setCraftable(XMLParser.parseBoolean(xml.getAttributeValue("craftable"), false));
wool.setMonument(monument);
return wool;
}
use of pl.themolka.arcade.region.Region in project Arcade2 by ShootGame.
the class CoreFactory method parseCoreXml.
public Core parseCoreXml(LeakGame game, Element xml, Core core) {
String paramLiquid = xml.getAttributeValue("liquid");
String paramMaterial = xml.getAttributeValue("material");
String paramDetectorLevel = xml.getAttributeValue("detector-level");
// liquid
Liquid liquid = Core.DEFAULT_LIQUID;
if (paramLiquid != null && !paramLiquid.isEmpty()) {
Liquid type = Liquid.valueOf(XMLParser.parseEnumValue(paramLiquid));
if (type != null) {
liquid = type;
}
}
// material
List<Material> material = Collections.singletonList(Core.DEFAULT_MATERIAL);
if (paramMaterial != null) {
material = parseArray(new Attribute("material", paramMaterial), Core.DEFAULT_MATERIAL);
}
// detector
int detectorLevel = Core.DEFAULT_DETECTOR_LEVEL;
if (paramDetectorLevel != null && !paramDetectorLevel.isEmpty()) {
try {
detectorLevel = Integer.parseInt(paramDetectorLevel);
} catch (NumberFormatException ignored) {
}
}
// region
Region region = XMLRegion.parseUnion(game.getGame(), xml.getChild("region"));
if (region == null) {
return null;
}
// setup
core.setMaterial(material);
core.build(liquid, region, detectorLevel);
return core;
}
Aggregations