Created a TicketPurchaseIntent which is broadcasted upon purchasing a ticket

This commit is contained in:
Mads Boddum
2015-09-26 02:00:30 +02:00
parent 8125f0b447
commit 28bc58a055
2 changed files with 49 additions and 0 deletions
@@ -0,0 +1,10 @@
var execute = function(galManager, player, target, args) {
var TicketPurchaseIntent = Java.type("intents.travel.TicketPurchaseIntent");
params = args.split(" ");
destinationPlanet = params[2];
destinationName = params[3].replaceAll("_", " ");
roundTrip = params[4].equals("1");
new TicketPurchaseIntent(player.getCreatureObject(), destinationPlanet, destinationName, roundTrip).broadcast();
};
@@ -0,0 +1,39 @@
package intents.travel;
import resources.control.Intent;
import resources.objects.creature.CreatureObject;
public final class TicketPurchaseIntent extends Intent {
public static final String TYPE = "TicketPurchaseIntent";
private final CreatureObject purchaser;
private final boolean roundTrip;
private final String destinationName;
private final String destinationPlanet;
public TicketPurchaseIntent(CreatureObject purchaser, String destinationPlanet, String destinationName, boolean roundTrip) {
super(TYPE);
this.purchaser = purchaser;
this.destinationPlanet = destinationPlanet;
this.destinationName = destinationName;
this.roundTrip = roundTrip;
}
public CreatureObject getPurchaser() {
return purchaser;
}
public boolean isRoundTrip() {
return roundTrip;
}
public String getDestinationPlanet() {
return destinationPlanet;
}
public String getDestinationName() {
return destinationName;
}
}