implement facade
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
package worms.facade;
|
package worms.facade;
|
||||||
|
|
||||||
|
import worms.internal.gui.game.IActionHandler;
|
||||||
import worms.model.*;
|
import worms.model.*;
|
||||||
|
import worms.programs.IProgramFactory;
|
||||||
import worms.util.IllegalNameException;
|
import worms.util.IllegalNameException;
|
||||||
import worms.util.ModelException;
|
import worms.util.ModelException;
|
||||||
import worms.util.Coordinate;
|
import worms.util.Coordinate;
|
||||||
@@ -265,6 +267,120 @@ public class Facade implements IFacade {
|
|||||||
return food.getWorld();
|
return food.getWorld();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return whether or not the given portion of food is poisonous.
|
||||||
|
*
|
||||||
|
* @param food
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean isPoisonous(Food food) throws ModelException {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Poison the given portion of food.
|
||||||
|
*
|
||||||
|
* @param food
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void poison(Food food) throws ModelException {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether the given projectile is terminated.
|
||||||
|
*
|
||||||
|
* @param projectile
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean isTerminated(Projectile projectile) throws ModelException {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the current orientation of the given projectile (in radians).
|
||||||
|
*
|
||||||
|
* @param projectile
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public double getOrientation(Projectile projectile) throws ModelException {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the current location of the given projectile.
|
||||||
|
* - The resulting array contains the the x-coordinate of the given projectile
|
||||||
|
* followed by its y-coordinate.
|
||||||
|
*
|
||||||
|
* @param projectile
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public double[] getLocation(Projectile projectile) throws ModelException {
|
||||||
|
return new double[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the radius of the given projectile.
|
||||||
|
*
|
||||||
|
* @param projectile
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public double getRadius(Projectile projectile) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the number of hit points of the given projectile.
|
||||||
|
*
|
||||||
|
* @param projectile
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int getNbHitPoints(Projectile projectile) throws ModelException {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the location on the jump trajectory of the given projectile
|
||||||
|
* after a time t.
|
||||||
|
* - The resulting location is an array with two elements,
|
||||||
|
* with the first element being the x-coordinate and the
|
||||||
|
* second element the y-coordinate.
|
||||||
|
*
|
||||||
|
* @param projectile
|
||||||
|
* @param elapsedTime
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public double[] getJumpStep(Projectile projectile, double elapsedTime) {
|
||||||
|
return new double[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the time needed by the given projectile to jump to the nearest
|
||||||
|
* location at which the projectile hits impassable terrain or a worm.
|
||||||
|
* - deltaT determines the resolution to be used in successive steps of the jump.
|
||||||
|
*
|
||||||
|
* @param projectile
|
||||||
|
* @param jumpTimeStep
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public double getJumpTime(Projectile projectile, double jumpTimeStep) throws ModelException {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make the given projectile jump using the given time step.
|
||||||
|
* - The given time step determines a time interval during which
|
||||||
|
* you may assume that the projectile will not hit impassable
|
||||||
|
* terrain nor a worm.
|
||||||
|
*
|
||||||
|
* @param projectile
|
||||||
|
* @param jumpTimeStep
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void jump(Projectile projectile, double jumpTimeStep) throws ModelException {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make the given worm eat a portion of food.
|
* Make the given worm eat a portion of food.
|
||||||
*
|
*
|
||||||
@@ -275,6 +391,17 @@ public class Facade implements IFacade {
|
|||||||
worm.checkEat();
|
worm.checkEat();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Have the give worm fire a projectile.
|
||||||
|
* - The method must return the projectile that has been fired.
|
||||||
|
*
|
||||||
|
* @param worm
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Projectile fire(Worm worm) throws ModelException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * Returns the x-coordinate of the current location of the given worm.
|
// * Returns the x-coordinate of the current location of the given worm.
|
||||||
// *
|
// *
|
||||||
@@ -868,4 +995,67 @@ public class Facade implements IFacade {
|
|||||||
public void mergeTeams(Team receivingTeam, Team supplyingTeam) throws ModelException, MustNotImplementException {
|
public void mergeTeams(Team receivingTeam, Team supplyingTeam) throws ModelException, MustNotImplementException {
|
||||||
Team.mergeTeams(receivingTeam, supplyingTeam);
|
Team.mergeTeams(receivingTeam, supplyingTeam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the program loaded on the given worm.
|
||||||
|
*
|
||||||
|
* @param worm
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Program getWormProgram(Worm worm) throws ModelException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load the given program on the given worm.
|
||||||
|
* <p>
|
||||||
|
* While executing the program, the worm must invoke the methods corresponding
|
||||||
|
* to actions through the provided ActionHandler object (e.g., actionHandler.jump(this),
|
||||||
|
* actionHandler.turn(this, 0.2), etc.) rather than invoking them directly (e.g., this.jump()).
|
||||||
|
* This executes the action as if a human player has initiated it, so the GUI can update itself.
|
||||||
|
* The GUI will also invoke the corresponding method on the worm through the facade.
|
||||||
|
*
|
||||||
|
* @param worm
|
||||||
|
* @param program
|
||||||
|
* @param actionHandler
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void loadProgramOnWorm(Worm worm, Program program, IActionHandler actionHandler) throws ModelException {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the program loaded on the given worm.
|
||||||
|
* The worm is positioned in some world. Returns null if the program
|
||||||
|
* is not completely executed. Otherwise, returns the objects that have been
|
||||||
|
* printed.
|
||||||
|
* <p>
|
||||||
|
* This method is only used in the tests. The GUI never calls this method;
|
||||||
|
* you should execute the program when the worm is activated.
|
||||||
|
*
|
||||||
|
* @param worm
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<Object> executeProgram(Worm worm) throws ModelException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new program factory.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public IProgramFactory<?, ?, ?, ? extends Program> createProgramFactory() throws ModelException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Have the wizard cast a spell over two randomly slected game objects in the given
|
||||||
|
* world.
|
||||||
|
*
|
||||||
|
* @param world
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void castSpell(World world) throws ModelException {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user