package dungeonmania;
import java.util.ArrayList;
import java.util.List;
Copyright By PowCoder代写 加微信 powcoder
import org.json.JSONException;
import dungeonmania.exceptions.InvalidActionException;
import dungeonmania.response.models.DungeonResponse;
import dungeonmania.response.models.ResponseBuilder;
import dungeonmania.util.Direction;
import dungeonmania.util.FileLoader;
public class DungeonManiaController {
private Game game = null;
public String getSkin() {
return “default”;
public String getLocalisation() {
return “en_US”;
* /dungeons
public static List
return FileLoader.listFileNamesInResourceDirectory(“dungeons”);
* /configs
public static List
return FileLoader.listFileNamesInResourceDirectory(“configs”);
* /game/new
public DungeonResponse newGame(String dungeonName, String configName) throws IllegalArgumentException {
if (!dungeons().contains(dungeonName)) {
throw new IllegalArgumentException(dungeonName + ” is not a dungeon that exists”);
if (!configs().contains(configName)) {
throw new IllegalArgumentException(configName + ” is not a configuration that exists”);
GameBuilder builder = new GameBuilder();
game = builder.setConfigName(configName).setDungeonName(dungeonName).buildGame();
return ResponseBuilder.getDungeonResponse(game);
} catch (JSONException e) {
return null;
* /game/dungeonResponseModel
public DungeonResponse getDungeonResponseModel() {
return null;
* /game/tick/item
public DungeonResponse tick(String itemUsedId) throws IllegalArgumentException, InvalidActionException {
return ResponseBuilder.getDungeonResponse(game.tick(itemUsedId));
* /game/tick/movement
public DungeonResponse tick(Direction movementDirection) {
return ResponseBuilder.getDungeonResponse(game.tick(movementDirection));
* /game/build
public DungeonResponse build(String buildable) throws IllegalArgumentException, InvalidActionException {
List
if (!validBuildables.contains(buildable)) {
throw new IllegalArgumentException(“Only bow, shield, midnight_armour and sceptre can be built”);
return ResponseBuilder.getDungeonResponse(game.build(buildable));
* /game/interact
public DungeonResponse interact(String entityId) throws IllegalArgumentException, InvalidActionException {
return ResponseBuilder.getDungeonResponse(game.interact(entityId));
* /game/save
public DungeonResponse saveGame(String name) throws IllegalArgumentException {
return null;
* /game/load
public DungeonResponse loadGame(String name) throws IllegalArgumentException {
return null;
* /games/all
public List
return new ArrayList<>();
* /game/new/generate
public DungeonResponse generateDungeon(
int xStart, int yStart, int xEnd, int yEnd, String configName) throws IllegalArgumentException {
return null;
* /game/rewind
public DungeonResponse rewind(int ticks) throws IllegalArgumentException {
return null;
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com