Suggestions on improving the marketing API



  • With the current marketplace API featuring createOrder(), deal() and getAllOrders(), making a deal typically involves writing some code like:
    //Iterate through the orders
    var orders = Game.market.getAllOrders(...)
    //Pick an optimal one if possible
    var order = _.filter(...)
    //Make the deal
    if (order != undefined ) {...}

    As we can see there's a lot of boilerplate here. IMHO, a better API should substitute a single function, as is described below, for all these three functions:
    sendOrder(type, resourceType, filter, totalAmount, roomName)
    in which "filter" is a function that has 1 argument, "object", the opposing order, and returns true when the order is acceptable.
    On the server side, the deals are automatically matched every tick.
    This system has IMHO two upsides:
    1. Less boilerplate and less code
    2. Better scalability, due to the fact that the global orders list may eventually get much longer, and filtering through them script-side, using the current API, would take up quite some CPU.
    Hope the suggested API can be implemented 🙂


  • Dev Team

    When you create an order, you pay the 5% market fee in credits. When you accept someone else's order, you don't pay the fee, but you pay the energy transaction cost. These concepts cannot be mixed in one single API.