Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: Shop

[13:7] extends: FxObj

Wraps FXGL's Shop (com.almasb.fxgl.trade.Shop), a container of TradeItems with a money balance. A Shop can buy items from another Shop using buyFrom; the money balance moves with the trade and a registered ShopListener fires for both sides.

Methods

  • Shop (int InitialMoney = 0, ItemsList = null)

    Creates a new Shop with the given starting money and initial item list. Pass null for ItemsList to construct an empty wrapper for adopt.

    • @p InitialMoney is the starting money balance.
    • @p ItemsList is an Aussom list of TradeItem wrappers.
  • adopt (object Ajo)

    Wraps an existing Shop AussomJavaObject.

    • @p Ajo is an AussomJavaObject around a Shop.
    • @r A new wrapper.
  • getMoney ()

    Returns the current money balance. @r An int.

  • setMoney (int Money)

    Sets the money balance.

    • @p Money is the new balance.
    • @r this object
  • moneyProperty ()

    Returns the IntegerProperty backing the money balance for binding to a UI label.

    • @r An AussomJavaObject around an IntegerProperty.
  • getItems ()

    Returns the underlying ObservableList of TradeItems.

    • @r An AussomJavaObject around an ObservableList.
  • setListener (object ListenerObj)

    Sets the ShopListener that fires on buy and sell events.

    • @p ListenerObj is a ShopListener wrapper.
    • @r this object
  • getListener ()

    Returns the currently-registered ShopListener AJO, or null.

    • @r An AussomJavaObject around a ShopListener, or null.
  • buyFrom (object OtherShopObj, object TradeItemObj, int Qty)

    Buys Qty of the given TradeItem from Other. Moves money and the item between shops; fires both listeners.

    • @p OtherShopObj is the seller Shop wrapper.
    • @p TradeItemObj is the TradeItem wrapper to buy.
    • @p Qty is the quantity to buy.
    • @r A bool — true on success, false if the buyer has too little money or the seller has too few items.