Package org.freerealm.executor

Examples of org.freerealm.executor.CommandResult


     * @param realm Realm to execute the command
     * @return CommandResult
     */
    public CommandResult execute(Realm realm) {
        settlement.setContiuousProduction(contiuousProduction);
        return new CommandResult(CommandResult.RESULT_OK, "");
    }
View Full Code Here


     * @return CommandResult
     */
    public CommandResult execute(Realm realm) {

        System.out.println(attacker + " attacks " + defender);
        CommandResult commandResult = null;
        if (attacker.canAttack()) {
            Unit winner = null;
            Unit loser = null;
            int attackPoints = attacker.getAttackPoints();
            System.out.println("Attack points : " + attackPoints);
            int defencePoints = defender.getDefencePoints();
            System.out.println("Defense points : " + defencePoints);
            attackPoints = Utility.increaseByPercent(attackPoints, attackBonusPercentage);
            System.out.println("Actual attack points : " + attackPoints);
            defenceBonusPercentage = Utility.getCoordinateDefenceBonus(realm, defender.getCoordinate());
            defencePoints = Utility.increaseByPercent(defencePoints, defenceBonusPercentage);
            System.out.println("Actual defense points : " + defencePoints);
            int total = attackPoints + defencePoints;
            Random random = new Random(System.currentTimeMillis());
            int randomInt = random.nextInt(total);
            System.out.println("Total : " + total + " Random : " + randomInt);
            if (randomInt < attackPoints) {
                System.out.println("Attacker won!");
                loser = defender;
                winner = attacker;
            } else {
                System.out.println("Defender won!");
                loser = attacker;
                winner = defender;
            }
            winner.setMovementPoints(0);
            Executor.getInstance().execute(new RemoveUnitCommand(loser.getPlayer(), loser));
            commandResult = new CommandResult(CommandResult.RESULT_OK, "", CommandResult.UNIT_ATTACKED_UPDATE);
            commandResult.addParameter(attacker);
            commandResult.addParameter(defender);
            commandResult.addParameter(winner);
            commandResult.addParameter(defender.getCoordinate());
        } else {
            commandResult = new CommandResult(CommandResult.RESULT_OK, "", CommandResult.NO_UPDATE);
        }
        return commandResult;
    }
View Full Code Here

        while (playerIterator.hasNext()) {
            Executor.getInstance().execute(new StartPlayerTurnCommand(playerIterator.next()));
        }
        Player firstPlayer = realm.getPlayerManager().getFirstPlayer();
        Executor.getInstance().execute(new SetActivePlayerCommand(firstPlayer));
        return new CommandResult(CommandResult.RESULT_OK, "", CommandResult.NEW_TURN_UPDATE);
    }
View Full Code Here

     */
    public CommandResult execute(Realm realm) {
        Player defendingPlayer = settlement.getPlayer();
        settlement.setPlayer(unit.getPlayer());
        MoveUnitCommand moveUnitCommand = new MoveUnitCommand(unit, settlement.getCoordinate());
        CommandResult result = Executor.getInstance().execute(moveUnitCommand);
        if (result.getCode() == CommandResult.RESULT_OK) {
            defendingPlayer.removeSettlement(settlement);
            unit.getPlayer().addSettlement(settlement);
            unit.setMovementPoints(0);
            CommandResult commandResult = new CommandResult(CommandResult.RESULT_OK, "", CommandResult.SETTLEMENT_CAPTURED_UPDATE);
            commandResult.addParameter(settlement);
            commandResult.addParameter(unit.getPlayer());
            commandResult.addParameter(defendingPlayer);
            return commandResult;
        } else {
            settlement.setPlayer(defendingPlayer);
            return result;
        }
View Full Code Here

     * @param realm Realm to execute the command
     * @return CommandResult
     */
    public CommandResult execute(Realm realm) {
        player.removeMission(mission);
        CommandResult commandResult = new CommandResult(CommandResult.RESULT_OK, "", CommandResult.MISSION_REMOVED_UPDATE);
        commandResult.addParameter(player);
        commandResult.addParameter(mission);
        return commandResult;
    }
View Full Code Here

     * @param realm Realm to execute the command
     * @return CommandResult
     */
    public CommandResult execute(Realm realm) {
        realm.getWorldMap().removeUnit(unit);
        return new CommandResult(CommandResult.RESULT_OK, "");
    }
View Full Code Here

        }
        if (taxRate < 0) {
            taxRate = 0;
        }
        player.setTaxRate(taxRate);
        return new CommandResult(CommandResult.RESULT_OK, "");
    }
View Full Code Here

     * @param realm Realm to execute the command
     * @return CommandResult
     */
    public CommandResult execute(Realm realm) {
        settlement.getWorkForceManager().removeWorkForce(coordinate);
        return new CommandResult(CommandResult.RESULT_OK, "");
    }
View Full Code Here

                mapItems[i][j] = newTile;
            }
        }
        currentMap.setMapItems(mapItems);
        realm.setWorldMap(currentMap);
        return new CommandResult(CommandResult.RESULT_OK, "");
    }
View Full Code Here

     */
    public CommandResult execute(Realm realm) {
        if (unitContainer.getTotalCapacity() >= (unit.getType().getWeightForContainer() + unitContainer.getTotalContainedWeight())) {
            unit.setStatus(Unit.UNIT_SUSPENDED);
            unitContainer.addUnit(unit.getId());
            return new CommandResult(CommandResult.RESULT_OK, "");
        } else {
            return new CommandResult(CommandResult.RESULT_ERROR, "Not enough capacity");
        }
    }
View Full Code Here

TOP

Related Classes of org.freerealm.executor.CommandResult

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.