166 JSCLASS_NO_OPTIONAL_MEMBERS
187 if (JSVAL_IS_OBJECT(value))
189 JSObject *
object = JSVAL_TO_OBJECT(value);
206 return [JSValueToEquipmentType(context, value) identifier];
214 NSString *result =
nil;
220 result = [objValue identifier];
223 else if ([objValue isKindOfClass:[NSString
class]])
230 if (exists || ![objValue hasSuffix:
@"_DAMAGED"])
236 if (outExists != NULL) *outExists = exists;
247 if (!JSID_IS_INT(propID))
return YES;
254 if (
EXPECT_NOT(!JSEquipmentInfoGetEquipmentType(context,
this, &eqType)))
return NO;
256 switch (JSID_TO_INT(propID))
263 result = [eqType
name];
267 if ([[eqType identifier] isEqual:
@"EQ_FUEL"])
271 else if ([[eqType identifier] isEqual:
@"EQ_RENOVATION"])
277 return JS_NewNumberValue(context, [
OOPlayerForScripting() adjustPriceByScriptForEqKey:[eqType identifier] withCurrent:[eqType price]], value);
292 return JS_NewNumberValue(context, [eqType damageProbability], value);
315 *value = INT_TO_JSVAL((int32_t)[eqType techLevel]);
319 *value = INT_TO_JSVAL((int32_t)[eqType effectiveTechLevel]);
323 return JS_NewNumberValue(context, [eqType price], value);
382 *value = INT_TO_JSVAL((int32_t)[eqType requiredCargoSpace]);
399 if (result ==
nil) result = [NSDictionary dictionary];
404 if (result ==
nil) result =
@"";
409 if (result ==
nil) result = [NSDictionary dictionary];
426 if (!JSID_IS_INT(propID))
return YES;
434 if (
EXPECT_NOT(!JSEquipmentInfoGetEquipmentType(context,
this, &eqType)))
return NO;
436 switch (JSID_TO_INT(propID))
440 if (colorForScript !=
nil || JSVAL_IS_NULL(*value))
447 OOStandardsDeprecated([NSString stringWithFormat:
@"TL99 for variable tech level is deprecated for %@",[eqType identifier]]);
450 if (JSVAL_IS_NULL(*value))
453 [OOPlayerForScripting() setMissionVariable:nil
454 forKey:[@"mission_TL_FOR_" stringByAppendingString:[eqType
identifier]]];
457 if (JS_ValueToInt32(context, *value, &iValue))
459 if (iValue < 0) iValue = 0;
461 [OOPlayerForScripting() setMissionVariable:[NSString stringWithFormat:@"%u", iValue]
462 forKey:[@"mission_TL_FOR_" stringByAppendingString:[eqType
identifier]]];
468 OOJSReportWarning(context,
@"Cannot modify effective tech level for %@, because its base tech level is not 99.", [eqType identifier]);
496@implementation OOEquipmentType (OOJavaScriptExtensions)
498- (jsval) oo_jsValueInContext:(JSContext *)context
505 if (!JS_SetPrivate(context, _jsSelf, [
self retain])) _jsSelf = NULL;
509 return OBJECT_TO_JSVAL(_jsSelf);
515 return @"EquipmentInfo";
519- (void) oo_clearJSSelf:(JSObject *)selfVal
521 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[]
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)
@ kEquipmentInfo_defaultActivateKey
@ 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_provides
@ kEquipmentInfo_requiresFullFuel
@ kEquipmentInfo_requiresNonFullFuel
@ kEquipmentInfo_requiredCargoSpace
@ kEquipmentInfo_isAvailableToNPCs
@ kEquipmentInfo_incompatibleEquipment
@ kEquipmentInfo_requiresNonCleanLegalRecord
@ kEquipmentInfo_requiresMountedPylon
@ kEquipmentInfo_requiresEmptyPylon
@ kEquipmentInfo_fastAffinityOffensive
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)
NSArray * providesForScripting()
NSString * descriptiveText()