use of pl.themolka.arcade.config.Ref in project Arcade2 by ShootGame.
the class MatchGameParser method parseNode.
@Override
protected ParserResult<MatchGame.Config> parseNode(Node node, String name, String value) throws ParserException {
boolean autoCycle = this.autoCycleParser.parse(node.property("auto-cycle", "autocycle")).orDefault(MatchGame.Config.DEFAULT_IS_AUTO_CYCLE);
boolean autoStart = this.autoStartParser.parse(node.property("auto-start", "autostart")).orDefault(MatchGame.Config.DEFAULT_IS_AUTO_START);
Time startCountdown = this.startCountdownParser.parse(node.property("start-countdown", "startcountdown")).orDefault(MatchGame.Config.DEFAULT_START_COUNTDOWN);
Observers.Config observers = this.observersParser.parse(node.firstChild("observers")).orFail();
return ParserResult.fine(node, name, value, new MatchGame.Config() {
public boolean autoCycle() {
return autoCycle;
}
public boolean autoStart() {
return autoStart;
}
public Time startCountdown() {
return startCountdown;
}
public Ref<Observers.Config> observers() {
return Ref.ofProvided(observers);
}
});
}
use of pl.themolka.arcade.config.Ref in project Arcade2 by ShootGame.
the class FilterSetParser method parseTree.
@Override
protected ParserResult<FilterSet.Config> parseTree(Node node, String name) throws ParserException {
String id = this.parseRequiredId(node);
Set<Filter.Config<?>> filters = new HashSet<>();
for (Node filterNode : node.children()) {
filters.add(this.filterParser.parse(filterNode).orFail());
}
if (ParserUtils.ensureNotEmpty(filters)) {
throw this.fail(node, name, null, "No filters defined");
}
return ParserResult.fine(node, name, new FilterSet.Config() {
public String id() {
return id;
}
public Ref<Set<Filter.Config<?>>> filters() {
return Ref.ofProvided(filters);
}
});
}
use of pl.themolka.arcade.config.Ref in project Arcade2 by ShootGame.
the class DamageRuleParser method parsePrimitive.
@Override
protected ParserResult<DamageRule.Config> parsePrimitive(Node node, String name, String value) throws ParserException {
String id = this.parseOptionalId(node);
Ref<Filter.Config<?>> entityFilter = this.entityFilterParser.parse(node.property("entity-filter", "filter")).orDefault(Ref.empty());
Ref<Filter.Config<?>> playerFilter = this.playerFilterParser.parse(node.property("player-filter", "filter")).orDefault(Ref.empty());
boolean notDenied = this.denyParser.parse(node).orDefault(true);
double damage = notDenied ? this.damageParser.parse(node).orFail() : DamageRule.Config.DENY_DAMAGE;
Percentage multiplier = this.multiplierParser.parse(node.property("multiplier", "multiply")).orDefault(Percentage.DONE);
return ParserResult.fine(node, name, value, new DamageRule.Config() {
public String id() {
return id;
}
public double damage() {
return damage;
}
public Ref<Filter.Config<?>> entityFilter() {
return entityFilter;
}
public Percentage multiplier() {
return multiplier;
}
public Ref<Filter.Config<?>> playerFilter() {
return playerFilter;
}
});
}
use of pl.themolka.arcade.config.Ref in project Arcade2 by ShootGame.
the class LivesGameParser method parseNode.
@Override
protected ParserResult<LivesGame.Config> parseNode(Node node, String name, String value) throws ParserException {
ParserResult<Integer> livesResult = this.livesParser.parse(node);
int lives = node.getName().equals("life") ? livesResult.orDefault(1) : livesResult.orFail();
// ^ 1 is the default if the node name is singular form
Ref<Team.Config> fallbackTeam = this.fallbackParser.parse(node.property("fallback", "return")).orDefault(Ref.empty());
boolean announce = this.announceParser.parse(node.property("announce", "message")).orDefault(true);
Sound sound = this.soundParser.parse(node.property("sound")).orDefault(LivesGame.DEFAULT_SOUND);
return ParserResult.fine(node, name, value, new LivesGame.Config() {
public int lives() {
return lives;
}
public Ref<Team.Config> fallbackTeam() {
return fallbackTeam;
}
public boolean announce() {
return announce;
}
public Sound sound() {
return sound;
}
});
}
use of pl.themolka.arcade.config.Ref in project Arcade2 by ShootGame.
the class PortalParser method parseNode.
@Override
protected ParserResult<Portal.Config> parseNode(Node node, String name, String value) throws ParserException {
SpawnApply destination = this.parseDestination(node, name, value);
Ref<Filter> filter = this.filterParser.parse(node.property("filter")).orDefault(Ref.empty());
String id = this.parseOptionalId(node);
Ref<Kit> kit = this.kitParser.parse(node.property("kit")).orDefault(Ref.empty());
AbstractRegion.Config<?> region = this.regionParser.parseWithDefinition(node, name, value).orFail();
return ParserResult.fine(node, name, value, new Portal.Config() {
public SpawnApply destination() {
return destination;
}
public Ref<Filter> filter() {
return filter;
}
public String id() {
return id;
}
public Ref<Kit> kit() {
return kit;
}
public Ref<AbstractRegion.Config<?>> region() {
return Ref.ofProvided(region);
}
});
}
Aggregations