170 JSCLASS_NO_OPTIONAL_MEMBERS
191 if (JSVAL_IS_OBJECT(value))
193 JSObject *
object = JSVAL_TO_OBJECT(value);
218 NSString *result =
nil;
224 result = [objValue identifier];
227 else if ([objValue isKindOfClass:[NSString
class]])
234 if (exists || ![objValue hasSuffix:
@"_DAMAGED"])
240 if (outExists != NULL) *outExists = exists;
251 if (!JSID_IS_INT(propID))
return YES;
257 NSUInteger inst_time;
259 if (
EXPECT_NOT(!JSEquipmentInfoGetEquipmentType(context,
this, &eqType)))
return NO;
261 switch (JSID_TO_INT(propID))
268 result = [eqType
name];
272 if ([[eqType identifier] isEqual:
@"EQ_FUEL"])
276 else if ([[eqType identifier] isEqual:
@"EQ_RENOVATION"])
282 return JS_NewNumberValue(context, [
OOPlayerForScripting() adjustPriceByScriptForEqKey:[eqType identifier] withCurrent:[eqType price]], value);
297 return JS_NewNumberValue(context, [eqType damageProbability], value);
320 *value = INT_TO_JSVAL((int32_t)[eqType techLevel]);
324 *value = INT_TO_JSVAL((int32_t)[eqType effectiveTechLevel]);
328 return JS_NewNumberValue(context, [eqType price], value);
338 inst_time = [eqType
price] + 600;
340 *value = INT_TO_JSVAL((int32_t)inst_time);
356 *value = INT_TO_JSVAL((int32_t)[eqType repairTime]);
400 *value = INT_TO_JSVAL((int32_t)[eqType requiredCargoSpace]);
417 if (result ==
nil) result = [NSDictionary dictionary];
422 if (result ==
nil) result =
@"";
427 if (result ==
nil) result = [NSDictionary dictionary];
444 if (!JSID_IS_INT(propID))
return YES;
452 if (
EXPECT_NOT(!JSEquipmentInfoGetEquipmentType(context,
this, &eqType)))
return NO;
454 switch (JSID_TO_INT(propID))
458 if (colorForScript !=
nil || JSVAL_IS_NULL(*value))
465 OOStandardsDeprecated([NSString stringWithFormat:
@"TL99 for variable tech level is deprecated for %@",[eqType identifier]]);
468 if (JSVAL_IS_NULL(*value))
475 if (JS_ValueToInt32(context, *value, &iValue))
477 if (iValue < 0) iValue = 0;
486 OOJSReportWarning(context,
@"Cannot modify effective tech level for %@, because its base tech level is not 99.", [eqType identifier]);
514@implementation OOEquipmentType (OOJavaScriptExtensions)
516- (jsval) oo_jsValueInContext:(JSContext *)context
523 if (!JS_SetPrivate(context, _jsSelf, [
self retain])) _jsSelf = NULL;
527 return OBJECT_TO_JSVAL(_jsSelf);
533 return @"EquipmentInfo";
537- (void) oo_clearJSSelf:(JSObject *)selfVal
539 if (_jsSelf == selfVal) _jsSelf = NULL;
void OOStandardsDeprecated(NSString *message)
BOOL OOEnforceStandards(void)
#define OOJS_PROFILE_EXIT
#define OOJS_NATIVE_ENTER(cx)
#define OOJS_PROFILE_ENTER
static JSBool EquipmentInfoGetProperty(JSContext *context, JSObject *this, jsid propID, jsval *value)
OOEquipmentType * JSValueToEquipmentType(JSContext *context, jsval value)
static JSObject * sEquipmentInfoPrototype
static JSClass sEquipmentInfoClass
static JSFunctionSpec sEquipmentInfoMethods[]
@ kEquipmentInfo_defaultActivateKey
@ kEquipmentInfo_installationTime
@ kEquipmentInfo_requiresAnyEquipment
@ kEquipmentInfo_canCarryMultiple
@ kEquipmentInfo_calculatedPrice
@ kEquipmentInfo_weaponInfo
@ kEquipmentInfo_effectiveTechLevel
@ kEquipmentInfo_requiresEquipment
@ kEquipmentInfo_equipmentKey
@ kEquipmentInfo_displayColor
@ kEquipmentInfo_isAvailableToAll
@ kEquipmentInfo_requiresFreePassengerBerth
@ kEquipmentInfo_damageProbability
@ kEquipmentInfo_requiresCleanLegalRecord
@ kEquipmentInfo_isVisible
@ kEquipmentInfo_isPortableBetweenShips
@ kEquipmentInfo_defaultModeKey
@ kEquipmentInfo_fastAffinityDefensive
@ kEquipmentInfo_isExternalStore
@ kEquipmentInfo_isAvailableToPlayer
@ kEquipmentInfo_canBeDamaged
@ kEquipmentInfo_description
@ kEquipmentInfo_techLevel
@ kEquipmentInfo_scriptName
@ kEquipmentInfo_scriptInfo
@ kEquipmentInfo_repairTime
@ kEquipmentInfo_provides
@ kEquipmentInfo_requiresFullFuel
@ kEquipmentInfo_requiresNonFullFuel
@ kEquipmentInfo_requiredCargoSpace
@ kEquipmentInfo_isAvailableToNPCs
@ kEquipmentInfo_incompatibleEquipment
@ kEquipmentInfo_requiresNonCleanLegalRecord
@ kEquipmentInfo_requiresMountedPylon
@ kEquipmentInfo_requiresEmptyPylon
@ kEquipmentInfo_fastAffinityOffensive
static JSBool EquipmentInfoSetProperty(JSContext *context, JSObject *this, jsid propID, JSBool strict, jsval *value)
void InitOOJSEquipmentInfo(JSContext *context, JSObject *global)
static JSFunctionSpec sEquipmentInfoStaticMethods[]
static JSPropertySpec sEquipmentInfoProperties[]
static JSBool EquipmentInfoStaticInfoForKey(JSContext *context, uintN argc, jsval *vp)
static JSBool EquipmentInfoGetAllEqipment(JSContext *context, JSObject *this, jsid propID, jsval *value)
NSString * JSValueToEquipmentKeyRelaxed(JSContext *context, jsval value, BOOL *outExists)
NSString * JSValueToEquipmentKey(JSContext *context, jsval value)
static JSPropertySpec sEquipmentInfoStaticProperties[]
PlayerEntity * OOPlayerForScripting(void)
id OOJSNativeObjectFromJSValue(JSContext *context, jsval value)
void OOJSReportWarning(JSContext *context, NSString *format,...)
JSBool OOJSObjectWrapperToString(JSContext *context, uintN argc, jsval *vp)
#define OOJS_PROP_READWRITE_CB
void OOJSRegisterObjectConverter(JSClass *theClass, OOJSClassConverterCallback converter)
OOINLINE jsval OOJSValueFromNativeObject(JSContext *context, id object)
#define DEFINE_JS_OBJECT_GETTER(NAME, JSCLASS, JSPROTO, OBJCCLASSNAME)
void OOJSObjectWrapperFinalize(JSContext *context, JSObject *this)
#define OOJS_RETURN_OBJECT(o)
void OOJSReportBadPropertySelector(JSContext *context, JSObject *thisObj, jsid propID, JSPropertySpec *propertySpec)
NSString * OOStringFromJSValue(JSContext *context, jsval value)
JSBool OOJSUnconstructableConstruct(JSContext *context, uintN argc, jsval *vp)
OOINLINE jsval OOJSValueFromBOOL(int b) INLINE_CONST_FUNC
void OOJSReportBadPropertyValue(JSContext *context, JSObject *thisObj, jsid propID, JSPropertySpec *propertySpec, jsval value)
id OOJSBasicPrivateObjectConverter(JSContext *context, JSObject *object)
void OOJSReportBadArguments(JSContext *context, NSString *scriptClass, NSString *function, uintN argc, jsval *argv, NSString *message, NSString *expectedArgsDescription)
#define OOJS_PROP_READONLY_CB
NSString * oo_jsClassName()
OOColor * colorWithDescription:(id description)
NSArray * normalizedArray()
void setDisplayColor:(OOColor *newColor)
NSDictionary * weaponInfo()
NSSet * incompatibleEquipment()
NSDictionary * scriptInfo()
NSArray * defaultActivateKey()
NSArray * defaultModeKey()
NSSet * requiresEquipment()
NSSet * requiresAnyEquipment()
OOEquipmentType * equipmentTypeWithIdentifier:(NSString *identifier)
OOCreditsQuantity price()
NSArray * providesForScripting()
NSString * descriptiveText()
void setMissionVariable:forKey:(NSString *value,[forKey] NSString *key)