/** * Let the player know he is being charged for money or that he hasn't got enough money * * @param paa the actionattachment the player is notified about * @param enough is this a notification about enough or not enough money. */ private void notifyMoney(final PoliticalActionAttachment paa, final boolean enough) { if (enough) { sendNotification("Charging " + paa.getCostPU() + " PU's to perform this action"); } else { sendNotification( "You don't have ennough money, you need " + paa.getCostPU() + " PU's to perform this action"); } }
/** * Subtract money from the players wallet * * @param paa the politicalactionattachment this the money is charged for. */ private void chargeForAction(final PoliticalActionAttachment paa) { final Resource PUs = getData().getResourceList().getResource(Constants.PUS); final int cost = paa.getCostPU(); if (cost > 0) { // don't notify user of spending money anymore // notifyMoney(paa, true); final String transcriptText = m_bridge.getPlayerID().getName() + " spend " + cost + " PU on Political Action: " + MyFormatter.attachmentNameToText(paa.getName()); m_bridge.getHistoryWriter().startEvent(transcriptText); final Change charge = ChangeFactory.changeResourcesChange(m_bridge.getPlayerID(), PUs, -cost); m_bridge.addChange(charge); } else { final String transcriptText = m_bridge.getPlayerID().getName() + " takes Political Action: " + MyFormatter.attachmentNameToText(paa.getName()); // we must start an event anyway m_bridge.getHistoryWriter().startEvent(transcriptText); } }
/** * @param paa The Political Action the player should be charged for * @return false if the player can't afford the action */ private boolean checkEnoughMoney(final PoliticalActionAttachment paa) { final Resource PUs = getData().getResourceList().getResource(Constants.PUS); final int cost = paa.getCostPU(); final int has = m_bridge.getPlayerID().getResources().getQuantity(PUs); return has >= cost; }