本文整理匯總了Java中net.sf.freecol.common.model.MarketWas.fireChanges方法的典型用法代碼示例。如果您正苦於以下問題:Java MarketWas.fireChanges方法的具體用法?Java MarketWas.fireChanges怎麽用?Java MarketWas.fireChanges使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.sf.freecol.common.model.MarketWas
的用法示例。
在下文中一共展示了MarketWas.fireChanges方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: askUnloadGoods
import net.sf.freecol.common.model.MarketWas; //導入方法依賴的package包/類
/**
* Unload some goods from a carrier.
*
* @param type The {@code GoodsType} to unload.
* @param amount The amount of goods to unload.
* @param carrier The {@code Unit} carrying the goods.
* @return True if the unload succeeded.
*/
private boolean askUnloadGoods(GoodsType type, int amount, Unit carrier) {
// Do not check for trade location, unloading can include dumping
// which can happen anywhere
final Player player = getMyPlayer();
final Market market = player.getMarket();
MarketWas marketWas = (market != null) ? new MarketWas(player) : null;
int oldAmount = carrier.getGoodsContainer().getGoodsCount(type);
if (askServer().unloadGoods(type, amount, carrier)
&& !(carrier.isInEurope() && !player.canTrade(type))
&& carrier.getGoodsContainer().getGoodsCount(type) != oldAmount) {
if (marketWas != null) marketWas.fireChanges(type, -amount);
return true;
}
return false;
}
示例2: askLoadGoods
import net.sf.freecol.common.model.MarketWas; //導入方法依賴的package包/類
/**
* Load some goods onto a carrier.
*
* @param loc The {@code Location} to load from.
* @param type The {@code GoodsType} to load.
* @param amount The amount of goods to load.
* @param carrier The {@code Unit} to load onto.
* @return True if the load succeeded.
*/
private boolean askLoadGoods(Location loc, GoodsType type, int amount,
Unit carrier) {
TradeLocation trl = carrier.getTradeLocation();
if (trl == null) return false;
// Size check, if there are spare holds they can be filled, but...
int loadable = carrier.getLoadableAmount(type);
if (amount > loadable) amount = loadable;
final Player player = carrier.getOwner();
final Market market = player.getMarket();
MarketWas marketWas = (market != null) ? new MarketWas(player) : null;
if (carrier.isInEurope()) {
// Are the goods boycotted?
if (!player.canTrade(type)) return false;
// Check that the purchase is funded.
if (!player.checkGold(market.getBidPrice(type, amount))) {
getGUI().showInformationMessage("info.notEnoughGold");
return false;
}
}
// Try to purchase.
int oldAmount = carrier.getGoodsContainer().getGoodsCount(type);
if (askServer().loadGoods(loc, type, amount, carrier)
&& carrier.getGoodsContainer().getGoodsCount(type) != oldAmount) {
if (marketWas != null) marketWas.fireChanges(type, amount);
return true;
}
return false;
}