Package org.gestern.gringotts

Examples of org.gestern.gringotts.Account


    public double getBalance(String playerName){
        AccountHolder owner = gringotts.accountHolderFactory.getAccount(playerName);
        if (owner == null) {
            return 0;
        }
        Account account = gringotts.accounting.getAccount(owner);
        return account.balance();
    }
View Full Code Here


        AccountHolder accountHolder = gringotts.accountHolderFactory.getAccount(playerName);
        if (accountHolder == null) {
            return new EconomyResponse(0, 0, ResponseType.FAILURE, playerName + " is not a valid account holder.");
        }

        Account account = gringotts.accounting.getAccount( accountHolder );

        if(account.balance() >= amount && account.remove(amount)) {
            //We has mulah!
            return new EconomyResponse(amount, account.balance(), ResponseType.SUCCESS, null);
        } else {
            //Not enough money to withdraw this much.
            return new EconomyResponse(0, account.balance(), ResponseType.FAILURE, "Insufficient funds");
        }

    }
View Full Code Here

        AccountHolder accountHolder = gringotts.accountHolderFactory.getAccount(playerName);
        if (accountHolder == null) {
            return new EconomyResponse(0, 0, ResponseType.FAILURE, playerName + " is not a valid account holder.");
        }

        Account account = gringotts.accounting.getAccount( accountHolder );

        if (account.add(amount)) {  
            return new EconomyResponse( amount, account.balance(), ResponseType.SUCCESS, null);
        } else {
            return new EconomyResponse( 0, account.balance(), ResponseType.FAILURE, "Not enough capacity to store that amount!");
        }
    }
View Full Code Here

TOP

Related Classes of org.gestern.gringotts.Account

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.