Package Managers

Examples of Managers.GameManager


    public static Result deleteStock() {
        User user = UserManager.getCurrentLoggedInUser();
        if (user != null && user.isAdmin()) {

            boolean success = true;
            GameManager gm = new GameManager();
            Form<StockForm> stockForm = Form.form(StockForm.class).bindFromRequest();
            if (stockForm.hasErrors()) {
                success = false;
            } else {
                try {
                    success = gm.deleteStock(stockForm.get().ticker);
                } catch (Exception e) {
                    success = false; //can not add into database
                }
            }
            if (success) {
                return ok(management.render(gm.getStockList(), "stock successfully deleted", "stockTab")); //return message indicating success
            } else {
                return ok(management.render(gm.getStockList(), "Failed deleting stock", "stockTab"));//not success in general
            }

        } else {
            return ok("You don't have acess to Admin DashBoard!");
        }
View Full Code Here


    public static Result toggleStock() {
        User user = UserManager.getCurrentLoggedInUser();
        if (user != null && user.isAdmin()) {

            boolean success = true;
            GameManager gm = new GameManager();
            int rs = 1;
            Form<StockForm> stockForm = Form.form(StockForm.class).bindFromRequest();
            if (stockForm.hasErrors()) {
                success = false;
            } else {
                try {
                    rs = gm.flipEnableStock(stockForm.get().ticker);
                    if (rs == 2) {
                        success = false;
                    }
                } catch (Exception e) {
                    success = false; //can not add into database
                }
            }
            if (success) {
                return ok(management.render(gm.getStockList(), "stock successfully " + (rs == 1 ? "enabled" : "disabled"), "stockTab")); //return message indicating success
            } else {
                return ok(management.render(gm.getStockList(), "Failed enable/disable stock", "stockTab"));//not success in general
            }

        } else {
            return ok("You don't have acess to Admin DashBoard!");
        }
View Full Code Here

    }

    public static Result playerToggle() {
        User user = UserManager.getCurrentLoggedInUser();
        if (user != null && user.isAdmin()) {
            GameManager gm = new GameManager();
            Form<UserForm> userForm = Form.form(UserForm.class).bindFromRequest();
            if (userForm.hasErrors()) {
                return ok(management.render(gm.getStockList(), "Failed enable/disable User", "userTab"));
            } else {
                return ok(management.render(gm.getStockList(), "User successfully " + (User.findByEmail(userForm.get().email).getIsEnabled() == 1 ? "enabled" : "disabled"), "userTab"));
            }
        } else {
            return ok("You don't have acess to Admin DashBoard!");
        }
    }
View Full Code Here

public class GameController extends Controller {

    public static Result create() {
        //create a game
        GameManager gm = new GameManager();

        Form<GameForm> gameForm = Form.form(GameForm.class).bindFromRequest();
        if (gameForm.hasErrors()) { //form contains error
            return badRequest(application_dashboard.render(gm.getListOfAvailableGames(), gameForm));
        }
        //no error     
        Game newGame = gm.createFixedTimeChallengeGame(gameForm.get());
        if (newGame != null) {
            flash("game_created", "Game has been successfully created!");
            return redirect(routes.GameController.playGame(newGame.getId()));
        } else {
            gameForm.reject("Can not create game");
            return badRequest(application_dashboard.render(gm.getListOfAvailableGames(), gameForm));
        }

    }
View Full Code Here

        response().setContentType("application/json");
        return ok(GameStateJSONFormatter.getGameStateJson(gameId));
    }

    public static Result start(int gameId) {
        GameManager gm = new GameManager();
        response().setContentType("application/json");

        if (gm.startGame(gameId)) {
            return ok(GameStateJSONFormatter.getGameStateJson(gameId).toString());
        } else {
            return badRequest("{error: \"failed to start game...\"}");
        }
    }
View Full Code Here

TOP

Related Classes of Managers.GameManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.