use of pl.themolka.arcade.match.MatchWinner in project Arcade2 by ShootGame.
the class DestroyGame method parseMapXml.
private void parseMapXml() {
for (Element xml : this.getSettings().getChildren()) {
try {
// factory
DestroyableFactory factory = this.getFactory(xml.getName());
if (factory == null) {
continue;
}
// id
String id = xml.getAttributeValue("id");
if (id == null || id.trim().isEmpty()) {
continue;
}
// owner
String ownerId = xml.getAttributeValue("owner");
Participator owner = null;
if (ownerId != null && !ownerId.trim().isEmpty()) {
owner = this.getMatch().findWinnerById(ownerId.trim());
}
// name
String name = XMLParser.parseMessage(xml.getAttributeValue("name"));
// object
Destroyable destroyable = factory.newDestroyable(this, owner, id.trim(), name, xml);
if (destroyable == null) {
continue;
}
destroyable.setName(name);
this.addDestroyable(destroyable);
// register
if (destroyable.registerGoal()) {
for (MatchWinner winner : this.getMatch().getWinnerList()) {
if (destroyable.isCompletableBy(winner)) {
winner.addGoal(destroyable);
}
}
}
// register listeners
destroyable.registerEventListeners(this, true);
} catch (JDOMException ex) {
ex.printStackTrace();
}
}
}
use of pl.themolka.arcade.match.MatchWinner in project Arcade2 by ShootGame.
the class CaptureGame method parseMapXml.
private void parseMapXml() {
for (Element xml : this.getSettings().getChildren()) {
try {
// factory
CapturableFactory factory = this.getFactory(xml.getName());
if (factory == null) {
continue;
}
// id
String id = xml.getAttributeValue("id");
if (id == null || id.trim().isEmpty()) {
continue;
}
// owner
String ownerId = xml.getAttributeValue("owner");
Participator owner = null;
if (ownerId != null && !ownerId.trim().isEmpty()) {
owner = this.getMatch().findWinnerById(ownerId.trim());
}
// name
String name = XMLParser.parseMessage(xml.getAttributeValue("name"));
// object
Capturable capturable = factory.newCapturable(this, owner, id.trim(), name, xml);
if (capturable == null) {
continue;
}
capturable.setName(name);
this.addCapturable(capturable);
// register
if (capturable.registerGoal()) {
for (MatchWinner winner : this.getMatch().getWinnerList()) {
if (capturable.isCompletableBy(winner)) {
winner.addGoal(capturable);
}
}
}
// register listeners
capturable.registerEventListeners(this, true);
} catch (JDOMException ex) {
ex.printStackTrace();
}
}
}
use of pl.themolka.arcade.match.MatchWinner in project Arcade2 by ShootGame.
the class KillEnemiesGame method getDynamicWinners.
@Override
public List<MatchWinner> getDynamicWinners() {
double highestProgress = Goal.PROGRESS_UNTOUCHED;
List<MatchWinner> results = new ArrayList<>();
for (MatchWinner winner : this.getMatch().getWinnerList()) {
if (winner.areGoalsCompleted()) {
results.add(winner);
continue;
}
KillEnemies objective = this.getObjective(winner);
if (objective == null) {
continue;
}
double progress = objective.getProgress();
if (progress > highestProgress) {
results.clear();
highestProgress = progress;
}
if (!results.contains(winner) && progress >= highestProgress) {
results.add(winner);
}
}
if (highestProgress != Goal.PROGRESS_UNTOUCHED && !results.isEmpty()) {
return results;
}
return null;
}
use of pl.themolka.arcade.match.MatchWinner in project Arcade2 by ShootGame.
the class KillEnemiesGame method onEnable.
@Override
public void onEnable() {
MatchGame module = (MatchGame) this.getGame().getModule(MatchModule.class);
this.match = module.getMatch();
this.match.registerDynamicWinnable(this);
for (Map.Entry<Participator, KillEnemies> entry : this.byOwner.entrySet()) {
MatchWinner winner = this.match.findWinnerById(entry.getKey().getId());
if (winner == null) {
continue;
}
winner.addGoal(entry.getValue());
}
}
use of pl.themolka.arcade.match.MatchWinner in project Arcade2 by ShootGame.
the class ScoreGame method onEnable.
@Override
public void onEnable() {
MatchGame module = (MatchGame) this.getGame().getModule(MatchModule.class);
this.match = module.getMatch();
this.match.registerDynamicWinnable(this);
for (Map.Entry<Participator, Score> entry : this.byOwner.entrySet()) {
MatchWinner winner = this.match.findWinnerById(entry.getKey().getId());
if (winner == null) {
continue;
}
Score score = entry.getValue();
score.setMatch(this.match);
winner.addGoal(score);
}
}
Aggregations