Oolite
Loading...
Searching...
No Matches
OOCommodities.m
Go to the documentation of this file.
1/*
2
3OOCommodities.m
4
5Oolite
6Copyright (C) 2004-2014 Giles C Williams and contributors
7
8This program is free software; you can redistribute it and/or
9modify it under the terms of the GNU General Public License
10as published by the Free Software Foundation; either version 2
11of the License, or (at your option) any later version.
12
13This program is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU General Public License for more details.
17
18You should have received a copy of the GNU General Public License
19along with this program; if not, write to the Free Software
20Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21MA 02110-1301, USA.
22
23*/
24
25#import "OOCommodities.h"
26#import "OOCommodityMarket.h"
27
29#import "OOJSScript.h"
30#import "OOStringExpander.h"
31#import "PlayerEntity.h"
32#import "ResourceManager.h"
33#import "StationEntity.h"
34#import "legacy_random.h"
35
36@interface OOCommodities (OOPrivate)
37
38- (NSDictionary*)modifyGood:(NSDictionary*)good withScript:(OOScript*)script atStation:(StationEntity*)station inSystem:(OOSystemID)system localMode:(BOOL)local;
39- (NSDictionary*)createDefinitionFrom:(NSDictionary*)good price:(OOCreditsQuantity)p andQuantity:(OOCargoQuantity)q forKey:(OOCommodityType)key atStation:(StationEntity*)station inSystem:(OOSystemID)system;
40
41- (OOCargoQuantity)generateQuantityForGood:(NSDictionary*)good inEconomy:(OOEconomyID)economy;
42- (OOCreditsQuantity)generatePriceForGood:(NSDictionary*)good inEconomy:(OOEconomyID)economy;
43
44- (float)economicBiasForGood:(NSDictionary*)good inEconomy:(OOEconomyID)economy;
45- (NSDictionary*)firstModifierForGood:(OOCommodityType)good inClasses:(NSArray*)classes fromList:(NSArray*)definitions;
46- (OOCreditsQuantity)adjustPrice:(OOCreditsQuantity)price byRule:(NSDictionary*)rule;
47- (OOCargoQuantity)adjustQuantity:(OOCargoQuantity)quantity byRule:(NSDictionary*)rule;
48- (NSDictionary*)updateInfoFor:(NSDictionary*)good byRule:(NSDictionary*)rule maxCapacity:(OOCargoQuantity)maxCapacity;
49
50@end
51
52@implementation OOCommodities
53
54/* Older save games store some commodity information by its old index. */
55+ (OOCommodityType)legacyCommodityType:(NSUInteger)i
56{
57 switch (i) {
58 case 0:
59 return @"food";
60 case 1:
61 return @"textiles";
62 case 2:
63 return @"radioactives";
64 case 3:
65 return @"slaves";
66 case 4:
67 return @"liquor_wines";
68 case 5:
69 return @"luxuries";
70 case 6:
71 return @"narcotics";
72 case 7:
73 return @"computers";
74 case 8:
75 return @"machinery";
76 case 9:
77 return @"alloys";
78 case 10:
79 return @"firearms";
80 case 11:
81 return @"furs";
82 case 12:
83 return @"minerals";
84 case 13:
85 return @"gold";
86 case 14:
87 return @"platinum";
88 case 15:
89 return @"gem_stones";
90 case 16:
91 return @"alien_items";
92 }
93 // shouldn't happen
94 return @"food";
95}
96
97- (id)init
98{
99 self = [super init];
100 if (self == nil)
101 return nil;
102
103 NSDictionary* rawCommodityLists = [ResourceManager dictionaryFromFilesNamed:@"trade-goods.plist" inFolder:@"Config" mergeMode:MERGE_SMART cache:YES];
104 /* // TODO: validation of inputs
105 // TODO: convert 't', 'kg', 'g' in quantity_unit to 0, 1, 2
106 // for now it needs them entering as the ints
107 NSMutableDictionary *validatedCommodityLists = [NSMutableDictionary dictionaryWithCapacity:[rawCommodityLists count]];
108 NSString *commodityName = nil;
109 foreachkey (commodityName, rawCommodityLists)
110 {
111 // validate
112 }
113
114 // _commodityLists = [[NSDictionary dictionaryWithDictionary:validatedCommodityLists] retain];
115 */
116
117 _commodityLists = [[NSDictionary dictionaryWithDictionary:rawCommodityLists] retain];
118
119 return self;
120}
121
122- (void)dealloc
123{
125
126 [super dealloc];
127}
128
130{
131 OOCommodityMarket* market = [[OOCommodityMarket alloc] init];
132
133 NSString* commodity = nil;
134 NSMutableDictionary* good = nil;
135 foreachkey(commodity, _commodityLists)
136 {
137 good = [NSMutableDictionary dictionaryWithDictionary:[_commodityLists oo_dictionaryForKey:commodity]];
138 [good oo_setUnsignedInteger:0 forKey:kOOCommodityPriceCurrent];
139 [good oo_setUnsignedInteger:0 forKey:kOOCommodityQuantityCurrent];
140 /* The actual capacity of the player ship is a total, not
141 * per-good, so is managed separately through PlayerEntity */
142 [good oo_setUnsignedInteger:UINT32_MAX forKey:kOOCommodityCapacity];
143 [good setObject:commodity forKey:kOOCommodityKey];
144
145 [market setGood:commodity withInfo:good];
146 }
147 return [market autorelease];
148}
149
151{
152 OOCommodityMarket* market = [[OOCommodityMarket alloc] init];
153
154 NSString* commodity = nil;
155 NSMutableDictionary* good = nil;
156 foreachkey(commodity, _commodityLists)
157 {
158 good = [NSMutableDictionary dictionaryWithDictionary:[_commodityLists oo_dictionaryForKey:commodity]];
159 [good oo_setUnsignedInteger:0 forKey:kOOCommodityPriceCurrent];
160 [good oo_setUnsignedInteger:0 forKey:kOOCommodityQuantityCurrent];
161 [good oo_setUnsignedInteger:0 forKey:kOOCommodityCapacity];
162 [good setObject:commodity forKey:kOOCommodityKey];
163
164 [market setGood:commodity withInfo:good];
165 }
166 return [market autorelease];
167}
168
169- (NSDictionary*)createDefinitionFrom:(NSDictionary*)good price:(OOCreditsQuantity)p andQuantity:(OOCargoQuantity)q forKey:(OOCommodityType)key atStation:(StationEntity*)station inSystem:(OOSystemID)system
170{
171 NSMutableDictionary* definition = [NSMutableDictionary dictionaryWithDictionary:good];
172 [definition oo_setUnsignedInteger:p forKey:kOOCommodityPriceCurrent];
173 [definition oo_setUnsignedInteger:q forKey:kOOCommodityQuantityCurrent];
174 if (station == nil && [definition objectForKey:kOOCommodityCapacity] == nil) {
175 [definition oo_setInteger:MAIN_SYSTEM_MARKET_LIMIT forKey:kOOCommodityCapacity];
176 }
177
178 [definition setObject:key forKey:kOOCommodityKey];
179 if (station != nil && ![station marketMonitored]) {
180 // clear legal status indicators if the market is not monitored
181 [definition oo_setUnsignedInteger:0 forKey:kOOCommodityLegalityExport];
182 [definition oo_setUnsignedInteger:0 forKey:kOOCommodityLegalityImport];
183 }
184
185 NSString* goodScriptName = [definition oo_stringForKey:kOOCommodityScript];
186 if (goodScriptName == nil) {
187 return definition;
188 }
189 OOScript* goodScript = [PLAYER commodityScriptNamed:goodScriptName];
190 if (goodScript == nil) {
191 return definition;
192 }
193 return [self modifyGood:definition withScript:goodScript atStation:station inSystem:system localMode:NO];
194}
195
196- (NSDictionary*)modifyGood:(NSDictionary*)good withScript:(OOScript*)script atStation:(StationEntity*)station inSystem:(OOSystemID)system localMode:(BOOL)localMode
197{
198 NSDictionary* result = nil;
199 JSContext* context = OOJSAcquireContext();
201 OOJSVal args[] = {
202 OOJSValueFromNativeObject(context, good),
203 OOJSValueFromNativeObject(context, station),
204 OOJSValueFromDouble(context, system)
205 };
206 BOOL OK = YES;
207 NSString* errorType = nil;
208
209 if (localMode) {
210 errorType = @"local";
211 OK = [script callMethod:OOJSID("updateLocalCommodityDefinition")
212 inContext:context
213 withArguments:args
214 count:3
215 result:&rval];
216 } else {
217 errorType = @"general";
218 OK = [script callMethod:OOJSID("updateGeneralCommodityDefinition")
219 inContext:context
220 withArguments:args
221 count:3
222 result:&rval];
223 }
224 OOJSFreeValue(context, args[0]);
225 OOJSFreeValue(context, args[1]);
226 OOJSFreeValue(context, args[2]);
227
228 if (!OK) {
229 OOLog(@"script.commodityScript.error", @"Could not update %@ commodity definition for %@ - unable to call updateLocalCommodityDefinition", errorType, [good oo_stringForKey:kOOCommodityName]);
230 OOJSFreeValue(context, rval);
231 OOJSRelinquishContext(context);
232 return good;
233 }
234
235#if OOJS_QUICKJS
236 if (!JS_IsObject(rval)) { // Unlike JSVAL_IS_OBJECT(), false for null, which gets the same message below.
237#else
238 if (!JSVAL_IS_OBJECT(rval)) {
239#endif
240 OOLog(@"script.commodityScript.error", @"Could not update %@ commodity definition for %@ - return value invalid", errorType, [good oo_stringForKey:kOOCommodityKey]);
241 OOJSFreeValue(context, rval);
242 OOJSRelinquishContext(context);
243 return good;
244 }
245
246#if OOJS_QUICKJS
247 result = OOJSNativeObjectFromJSObject(context, rval);
248#else
249 result = OOJSNativeObjectFromJSObject(context, JSVAL_TO_OBJECT(rval));
250#endif
251 OOJSFreeValue(context, rval);
252 OOJSRelinquishContext(context);
253 if (![result isKindOfClass:[NSDictionary class]]) {
254 OOLog(@"script.commodityScript.error", @"Could not update %@ commodity definition for %@ - return value invalid", errorType, [good oo_stringForKey:kOOCommodityKey]);
255 return good;
256 }
257
258 return result;
259}
260
261- (OOCommodityMarket*)generateMarketForSystemWithEconomy:(OOEconomyID)economy andScript:(NSString*)scriptName
262{
263 OOScript* script = [PLAYER commodityScriptNamed:scriptName];
264
265 OOCommodityMarket* market = [[OOCommodityMarket alloc] init];
266
267 NSString* commodity = nil;
268 NSDictionary* good = nil;
269 foreachkey(commodity, _commodityLists)
270 {
271 good = [_commodityLists oo_dictionaryForKey:commodity];
272 OOCargoQuantity q = [self generateQuantityForGood:good inEconomy:economy];
273 // main system market limited to 127 units of each item
274 OOCargoQuantity cap = [good oo_unsignedIntForKey:kOOCommodityCapacity defaultValue:MAIN_SYSTEM_MARKET_LIMIT];
275 if (q > cap) {
276 q = cap;
277 }
278 OOCreditsQuantity p = [self generatePriceForGood:good inEconomy:economy];
279 good = [self createDefinitionFrom:good price:p andQuantity:q forKey:commodity atStation:nil inSystem:[UNIVERSE currentSystemID]];
280
281 if (script != nil) {
282 good = [self modifyGood:good withScript:script atStation:nil inSystem:[UNIVERSE currentSystemID] localMode:YES];
283 }
284 [market setGood:commodity withInfo:good];
285 }
286 return [market autorelease];
287}
288
289- (OOCommodityMarket*)generateMarketForStation:(StationEntity*)station
290{
291 NSArray* marketDefinition = [station marketDefinition];
292 NSString* marketScriptName = [station marketScriptName];
293 OOScript* marketScript = [PLAYER commodityScriptNamed:marketScriptName];
294 if (marketDefinition == nil && marketScript == nil) {
295 OOCommodityMarket* market = [self generateBlankMarket];
296 return market;
297 }
298
299 OOCommodityMarket* market = [[OOCommodityMarket alloc] init];
301 OOCommodityMarket* mainMarket = [UNIVERSE commodityMarket];
302
303 NSString* commodity = nil;
304 NSDictionary* good = nil;
305 foreachkey(commodity, _commodityLists)
306 {
307 good = [_commodityLists oo_dictionaryForKey:commodity];
308 OOCargoQuantity baseCapacity = [good oo_unsignedIntForKey:kOOCommodityCapacity defaultValue:MAIN_SYSTEM_MARKET_LIMIT];
309
310 // important - ensure baseCapacity cannot be zero
311 if (!baseCapacity)
312 baseCapacity = MAIN_SYSTEM_MARKET_LIMIT;
313
316
317 if (marketScript == nil) {
318 NSDictionary* modifier = [self firstModifierForGood:commodity inClasses:[good oo_arrayForKey:kOOCommodityClasses] fromList:marketDefinition];
319 good = [self updateInfoFor:good byRule:modifier maxCapacity:capacity];
320 p = [self adjustPrice:p byRule:modifier];
321
322 // first, scale to this station's capacity for this good
323 OOCargoQuantity localCapacity = [good oo_unsignedIntForKey:kOOCommodityCapacity];
324 if (localCapacity > capacity) {
325 localCapacity = capacity;
326 }
327 q = (q * localCapacity) / baseCapacity;
328 q = [self adjustQuantity:q byRule:modifier];
329 if (q > localCapacity) {
330 q = localCapacity; // cap
331 }
332 } else {
333 // only scale to market at this stage
334 q = (q * capacity) / baseCapacity;
335 }
336
337 good = [self createDefinitionFrom:good price:p andQuantity:q forKey:commodity atStation:station inSystem:[UNIVERSE currentSystemID]];
338 if (marketScript != nil) {
339 good = [self modifyGood:good withScript:marketScript atStation:station inSystem:[UNIVERSE currentSystemID] localMode:YES];
340 }
341
342 [market setGood:commodity withInfo:good];
343 }
344 return [market autorelease];
345}
346
347- (NSUInteger)count
348{
349 return [_commodityLists count];
350}
351
352- (NSArray*)goods
353{
354 return [_commodityLists allKeys];
355}
356
357- (BOOL)goodDefined:(NSString*)key
358{
359 return ([_commodityLists oo_dictionaryForKey:key] != nil);
360}
361
362- (NSString*)goodNamed:(NSString*)name
363{
364 NSString* commodity = nil;
365 foreachkey(commodity, _commodityLists)
366 {
367 NSDictionary* good = [_commodityLists oo_dictionaryForKey:commodity];
368 if ([OOExpand([good oo_stringForKey:kOOCommodityName]) isEqualToString:name]) {
369 return commodity;
370 }
371 }
372 return nil;
373}
374
376{
377 NSArray* keys = [_commodityLists allKeys];
378 NSUInteger idx = Ranrot() % [keys count];
379 return [keys oo_stringAtIndex:idx];
380}
381
382- (OOMassUnit)massUnitForGood:(NSString*)good
383{
384 NSDictionary* definition = [_commodityLists oo_dictionaryForKey:good];
385 if (definition == nil) {
386 return UNITS_TONS;
387 }
388 return [definition oo_unsignedIntForKey:kOOCommodityContainer];
389}
390
391- (OOCargoQuantity)generateQuantityForGood:(NSDictionary*)good inEconomy:(OOEconomyID)economy
392{
393 float bias = [self economicBiasForGood:good inEconomy:economy];
394
395 float base = [good oo_floatForKey:kOOCommodityQuantityAverage];
396 float econ = base * [good oo_floatForKey:kOOCommodityQuantityEconomic] * bias;
397 float random = base * [good oo_floatForKey:kOOCommodityQuantityRandom] * (randf() - randf());
398 base += econ + random;
399 if (base < 0.0) {
400 return 0;
401 } else {
402 return (OOCargoQuantity)base;
403 }
404}
405
406- (OOCreditsQuantity)generatePriceForGood:(NSDictionary*)good inEconomy:(OOEconomyID)economy
407{
408 float bias = [self economicBiasForGood:good inEconomy:economy];
409
410 float base = [good oo_floatForKey:kOOCommodityPriceAverage];
411 float econ = base * [good oo_floatForKey:kOOCommodityPriceEconomic] * -bias;
412 float random = base * [good oo_floatForKey:kOOCommodityPriceRandom] * (randf() - randf());
413 base += econ + random;
414 if (base < 0.0) {
415 return 0;
416 } else {
417 return (OOCreditsQuantity)base;
418 }
419}
420
421- (OOCreditsQuantity)samplePriceForCommodity:(OOCommodityType)commodity inEconomy:(OOEconomyID)economy withScript:(NSString*)scriptName inSystem:(OOSystemID)system
422{
423 NSDictionary* good = [_commodityLists oo_dictionaryForKey:commodity];
424 if (good == nil) {
425 return 0;
426 }
427 OOCreditsQuantity p = [self generatePriceForGood:good inEconomy:economy];
428
429 good = [self createDefinitionFrom:good price:p andQuantity:0 forKey:commodity atStation:nil inSystem:system];
430 if (scriptName != nil) {
431 OOScript* script = [PLAYER commodityScriptNamed:scriptName];
432 if (script != nil) {
433 good = [self modifyGood:good withScript:script atStation:nil inSystem:system localMode:YES];
434 }
435 }
436 return [good oo_unsignedIntegerForKey:kOOCommodityPriceCurrent];
437}
438
439// positive = exporter; negative = importer; range -1.0 .. +1.0
440- (float)economicBiasForGood:(NSDictionary*)good inEconomy:(OOEconomyID)economy
441{
442 OOEconomyID exporter = [good oo_intForKey:kOOCommodityPeakExport];
443 OOEconomyID importer = [good oo_intForKey:kOOCommodityPeakImport];
444
445 // *2 and /2 to work in ints at this stage
446 int exDiff = abs(economy - exporter) * 2;
447 int imDiff = abs(economy - importer) * 2;
448 int distance = (exDiff + imDiff) / 2;
449
450 if (exDiff == imDiff) {
451 // neutral economy
452 return 0.0;
453 } else if (exDiff > imDiff) {
454 // closer to the importer, so return -ve
455 return -(1.0 - ((float)imDiff / (float)distance));
456 } else {
457 // closer to the exporter, so return +ve
458 return 1.0 - ((float)exDiff / (float)distance);
459 }
460}
461
462- (NSDictionary*)firstModifierForGood:(OOCommodityType)good inClasses:(NSArray*)classes fromList:(NSArray*)definitions
463{
464 NSUInteger i;
465 for (i = 0; i < [definitions count]; i++) {
466 NSDictionary* definition = [definitions oo_dictionaryAtIndex:i];
467 if (definition != nil) {
468 NSString* applicationType = [definition oo_stringForKey:kOOCommodityMarketType defaultValue:kOOCommodityMarketTypeValueDefault];
469 NSString* applicationName = [definition oo_stringForKey:kOOCommodityMarketName defaultValue:@""];
470
471 if (
472 [applicationType isEqualToString:kOOCommodityMarketTypeValueDefault]
473 || ([applicationType isEqualToString:kOOCommodityMarketTypeValueGood] && [applicationName isEqualToString:good])
474 || ([applicationType isEqualToString:kOOCommodityMarketTypeValueClass] && [classes containsObject:applicationName])) {
475 return definition;
476 }
477 }
478 }
479 // return a blank dictionary - default values will do the rest
480 return [NSDictionary dictionary];
481}
482
483- (OOCreditsQuantity)adjustPrice:(OOCreditsQuantity)price byRule:(NSDictionary*)rule
484{
485 float p = (float)price; // work in floats to avoid rounding problems
486 float pa = [rule oo_floatForKey:kOOCommodityMarketPriceAdder defaultValue:0.0];
487 float pm = [rule oo_floatForKey:kOOCommodityMarketPriceMultiplier defaultValue:1.0];
488 if (pm <= 0.0 && pa <= 0.0) {
489 // setting a price multiplier of 0 forces the price to zero
490 return 0;
491 }
492 float pr = [rule oo_floatForKey:kOOCommodityMarketPriceRandomiser defaultValue:0.0];
493 p += pa;
494 p = (p * pm) + (p * pr * (randf() - randf()));
495 if (p < 1.0) {
496 // random variation and non-zero price multiplier can't reduce
497 // price below 1 decicredit
498 p = 1.0;
499 }
500 return (OOCreditsQuantity)p;
501}
502
503- (OOCargoQuantity)adjustQuantity:(OOCargoQuantity)quantity byRule:(NSDictionary*)rule
504{
505 float q = (float)quantity; // work in floats to avoid rounding problems
506 float qa = [rule oo_floatForKey:kOOCommodityMarketQuantityAdder defaultValue:0.0];
507 float qm = [rule oo_floatForKey:kOOCommodityMarketQuantityMultiplier defaultValue:1.0];
508 if (qm <= 0.0 && qa <= 0.0) {
509 // setting a price multiplier of 0 forces the price to zero
510 return 0;
511 }
512 float qr = [rule oo_floatForKey:kOOCommodityMarketQuantityRandomiser defaultValue:0.0];
513 q += qa;
514 q = (q * qm) + (q * qr * (randf() - randf()));
515 if (q < 0.0) {
516 // random variation and non-zero price multiplier can't reduce
517 // quantity below zero
518 q = 0.0;
519 }
520 // may be over station capacity - that gets capped later
521 return (OOCargoQuantity)q;
522}
523
524- (NSDictionary*)updateInfoFor:(NSDictionary*)good byRule:(NSDictionary*)rule maxCapacity:(OOCargoQuantity)maxCapacity
525{
526 NSMutableDictionary* tmp = [NSMutableDictionary dictionaryWithDictionary:good];
527 NSInteger import = [rule oo_integerForKey:kOOCommodityMarketLegalityImport defaultValue:-1];
528 if (import >= 0) {
529 [tmp oo_setInteger:import forKey:kOOCommodityLegalityImport];
530 }
531
532 NSInteger export = [rule oo_integerForKey:kOOCommodityMarketLegalityExport defaultValue:-1];
533 if (export >= 0) {
534 [tmp oo_setInteger:import forKey:kOOCommodityLegalityExport];
535 }
536
537 NSInteger capacity = [rule oo_integerForKey:kOOCommodityMarketCapacity defaultValue:-1];
538 if (capacity >= 0 && capacity <= (NSInteger)maxCapacity) {
539 [tmp oo_setInteger:capacity forKey:kOOCommodityCapacity];
540 } else {
541 // set to the station max capacity
542 [tmp oo_setInteger:maxCapacity forKey:kOOCommodityCapacity];
543 }
544
545 return [[tmp copy] autorelease];
546}
547
548@end
#define MAIN_SYSTEM_MARKET_LIMIT
static NSString *const kOOCommodityCapacity
static NSString *const kOOCommodityKey
static NSString *const kOOCommodityMarketTypeValueClass
static NSString *const kOOCommodityMarketTypeValueGood
static NSString *const kOOCommodityMarketTypeValueDefault
static NSString *const kOOCommodityName
#define DESTROY(x)
#define foreachkey(VAR, DICT)
OOINLINE jsval OOJSValueFromDouble(JSContext *context, double value)
jsval OOJSVal
#define OOJSFreeValue(context, value)
#define OOJSUndefinedValue()
OOINLINE jsval OOJSValueFromNativeObject(JSContext *context, id object)
id OOJSNativeObjectFromJSObject(JSContext *context, JSObject *object)
OOINLINE JSContext * OOJSAcquireContext(void)
OOINLINE void OOJSRelinquishContext(JSContext *context)
#define OOLog(class, format,...)
Definition OOLogging.h:84
return nil
#define OOExpand(string,...)
NSString * OOCommodityType
Definition OOTypes.h:97
uint64_t OOCreditsQuantity
Definition OOTypes.h:160
int16_t OOSystemID
Definition OOTypes.h:183
uint32_t OOCargoQuantity
Definition OOTypes.h:155
OOMassUnit
Definition OOTypes.h:111
@ UNITS_TONS
Definition OOTypes.h:112
uint8_t OOEconomyID
Definition OOTypes.h:180
OOINLINE OOScalar distance(Vector v1, Vector v2) INLINE_CONST_FUNC
Definition OOVector.h:280
OOCreditsQuantity generatePriceForGood:inEconomy:(NSDictionary *good, [inEconomy] OOEconomyID economy)
NSString * getRandomCommodity()
NSDictionary * updateInfoFor:byRule:maxCapacity:(NSDictionary *good, [byRule] NSDictionary *rule, [maxCapacity] OOCargoQuantity maxCapacity)
NSDictionary * _commodityLists
OOCommodityMarket * generateManifestForPlayer()
NSArray * goods()
NSDictionary * modifyGood:withScript:atStation:inSystem:localMode:(NSDictionary *good, [withScript] OOScript *script, [atStation] StationEntity *station, [inSystem] OOSystemID system, [localMode] BOOL localMode)
OOCargoQuantity generateQuantityForGood:inEconomy:(NSDictionary *good, [inEconomy] OOEconomyID economy)
OOCargoQuantity adjustQuantity:byRule:(OOCargoQuantity quantity, [byRule] NSDictionary *rule)
NSDictionary * createDefinitionFrom:price:andQuantity:forKey:atStation:inSystem:(NSDictionary *good, [price] OOCreditsQuantity p, [andQuantity] OOCargoQuantity q, [forKey] OOCommodityType key, [atStation] StationEntity *station, [inSystem] OOSystemID system)
NSUInteger count()
NSDictionary * firstModifierForGood:inClasses:fromList:(OOCommodityType good, [inClasses] NSArray *classes, [fromList] NSArray *definitions)
OOCommodityMarket * generateBlankMarket()
float economicBiasForGood:inEconomy:(NSDictionary *good, [inEconomy] OOEconomyID economy)
OOCreditsQuantity adjustPrice:byRule:(OOCreditsQuantity price, [byRule] NSDictionary *rule)
void setGood:withInfo:(OOCommodityType key,[withInfo] NSDictionary *info)
OOCargoQuantity quantityForGood:(OOCommodityType good)
OOCreditsQuantity priceForGood:(OOCommodityType good)
BOOL callMethod:inContext:withArguments:count:result:(jsid methodID,[inContext] JSContext *context,[withArguments] jsval *argv,[count] intN argc,[result] jsval *outResult)
Definition OOJSScript.m:600
NSDictionary * dictionaryFromFilesNamed:inFolder:mergeMode:cache:(NSString *fileName,[inFolder] NSString *folderName,[mergeMode] OOResourceMergeMode mergeMode,[cache] BOOL useCache)
OOCargoQuantity marketCapacity
NSArray * marketDefinition
NSString * marketScriptName
float randf(void)
unsigned Ranrot(void)