Skip to content

Commit 95b4cc4

Browse files
authored
Document createOrder's parameter properly (#269)
1 parent ec6110c commit 95b4cc4

File tree

2 files changed

+80
-14
lines changed

2 files changed

+80
-14
lines changed

dist/index.d.ts

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3079,14 +3079,16 @@ interface Market {
30793079
* it will be automatically activated and deactivated depending on the resource/credits availability.
30803080
*
30813081
* An order expires in 30 days after its creation, and the remaining market fee is returned.
3082+
*
3083+
* @param params A object describing the order.
3084+
* @returns One of the following codes:
3085+
* - OK: The operation has been scheduled successfully.
3086+
* - ERR_NOT_OWNER: You are not the owner of the room's terminal or there is no terminal.
3087+
* - ERR_NOT_ENOUGH_RESOURCES: You don't have enough credits to pay a fee.
3088+
* - ERR_FULL: You cannot create more than 50 orders.
3089+
* - ERR_INVALID_ARGS: The arguments provided are invalid.
30823090
*/
3083-
createOrder(params: {
3084-
type: ORDER_BUY | ORDER_SELL;
3085-
resourceType: MarketResourceConstant;
3086-
price: number;
3087-
totalAmount: number;
3088-
roomName?: string;
3089-
}): ScreepsReturnCode;
3091+
createOrder(params: CreateOrderParam): ScreepsReturnCode;
30903092
/**
30913093
* Execute a trade deal from your Terminal to another player's Terminal using the specified buy/sell order.
30923094
*
@@ -3186,6 +3188,37 @@ interface PriceHistory {
31863188
avgPrice: number;
31873189
stddevPrice: number;
31883190
}
3191+
3192+
/** Parameters to {@link Game.market.createOrder} */
3193+
interface CreateOrderParam {
3194+
/**
3195+
* The order type.
3196+
*/
3197+
type: ORDER_BUY | ORDER_SELL;
3198+
/**
3199+
* The resource type to trade.
3200+
*
3201+
* If your Terminal doesn't have the specified resource, the order will be temporary inactive.
3202+
*/
3203+
resourceType: MarketResourceConstant;
3204+
/**
3205+
* The price for one resource unit in credits.
3206+
*
3207+
* Can be a decimal number.
3208+
*/
3209+
price: number;
3210+
/**
3211+
* The amount of resources to be traded in total.
3212+
*/
3213+
totalAmount: number;
3214+
/**
3215+
* The room where your order will be created.
3216+
*
3217+
* You must have your own Terminal structure in this room, otherwise the created order will be temporary inactive.
3218+
* This argument is not used when `resourceType` is one of the {@link InterShardResourceConstant} resources.
3219+
*/
3220+
roomName?: string;
3221+
}
31893222
interface Memory {
31903223
creeps: { [name: string]: CreepMemory };
31913224
powerCreeps: { [name: string]: PowerCreepMemory };

src/market.ts

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,16 @@ interface Market {
5252
* it will be automatically activated and deactivated depending on the resource/credits availability.
5353
*
5454
* An order expires in 30 days after its creation, and the remaining market fee is returned.
55+
*
56+
* @param params A object describing the order.
57+
* @returns One of the following codes:
58+
* - OK: The operation has been scheduled successfully.
59+
* - ERR_NOT_OWNER: You are not the owner of the room's terminal or there is no terminal.
60+
* - ERR_NOT_ENOUGH_RESOURCES: You don't have enough credits to pay a fee.
61+
* - ERR_FULL: You cannot create more than 50 orders.
62+
* - ERR_INVALID_ARGS: The arguments provided are invalid.
5563
*/
56-
createOrder(params: {
57-
type: ORDER_BUY | ORDER_SELL;
58-
resourceType: MarketResourceConstant;
59-
price: number;
60-
totalAmount: number;
61-
roomName?: string;
62-
}): ScreepsReturnCode;
64+
createOrder(params: CreateOrderParam): ScreepsReturnCode;
6365
/**
6466
* Execute a trade deal from your Terminal to another player's Terminal using the specified buy/sell order.
6567
*
@@ -159,3 +161,34 @@ interface PriceHistory {
159161
avgPrice: number;
160162
stddevPrice: number;
161163
}
164+
165+
/** Parameters to {@link Game.market.createOrder} */
166+
interface CreateOrderParam {
167+
/**
168+
* The order type.
169+
*/
170+
type: ORDER_BUY | ORDER_SELL;
171+
/**
172+
* The resource type to trade.
173+
*
174+
* If your Terminal doesn't have the specified resource, the order will be temporary inactive.
175+
*/
176+
resourceType: MarketResourceConstant;
177+
/**
178+
* The price for one resource unit in credits.
179+
*
180+
* Can be a decimal number.
181+
*/
182+
price: number;
183+
/**
184+
* The amount of resources to be traded in total.
185+
*/
186+
totalAmount: number;
187+
/**
188+
* The room where your order will be created.
189+
*
190+
* You must have your own Terminal structure in this room, otherwise the created order will be temporary inactive.
191+
* This argument is not used when `resourceType` is one of the {@link InterShardResourceConstant} resources.
192+
*/
193+
roomName?: string;
194+
}

0 commit comments

Comments
 (0)