Static method Ship.roles() lists all valid roles, including [ roles. Issue #26
This commit is contained in:
parent
2aa670f4f6
commit
701a750822
@ -60,6 +60,7 @@ SOFTWARE.
|
||||
@interface OOShipRegistry (OOConveniences)
|
||||
|
||||
- (NSArray *) shipKeys;
|
||||
- (NSArray *) shipRoles;
|
||||
- (NSArray *) shipKeysWithRole:(NSString *)role;
|
||||
- (NSString *) randomShipKeyForRole:(NSString *)role;
|
||||
|
||||
|
@ -245,6 +245,11 @@ static NSString * const kVisualEffectDataCacheKey = @"visual effect data";
|
||||
return [_shipData allKeys];
|
||||
}
|
||||
|
||||
- (NSArray *) shipRoles
|
||||
{
|
||||
return [_probabilitySets allKeys];
|
||||
}
|
||||
|
||||
- (NSArray *) shipKeysWithRole:(NSString *)role
|
||||
{
|
||||
return [[self probabilitySetForRole:role] allObjects];
|
||||
|
@ -101,6 +101,7 @@ static JSBool ShipSetMaterialsInternal(JSContext *context, uintN argc, jsval *vp
|
||||
|
||||
static JSBool ShipStaticKeysForRole(JSContext *context, uintN argc, jsval *vp);
|
||||
static JSBool ShipStaticKeys(JSContext *context, uintN argc, jsval *vp);
|
||||
static JSBool ShipStaticRoles(JSContext *context, uintN argc, jsval *vp);
|
||||
|
||||
|
||||
static JSClass sShipClass =
|
||||
@ -418,6 +419,7 @@ static JSFunctionSpec sShipStaticMethods[] =
|
||||
// JS name Function min args
|
||||
{ "keys", ShipStaticKeys, 0 },
|
||||
{ "keysForRole", ShipStaticKeysForRole, 1 },
|
||||
{ "roles", ShipStaticRoles, 0 },
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
@ -2747,3 +2749,14 @@ static JSBool ShipStaticKeysForRole(JSContext *context, uintN argc, jsval *vp)
|
||||
|
||||
OOJS_NATIVE_EXIT
|
||||
}
|
||||
|
||||
static JSBool ShipStaticRoles(JSContext *context, uintN argc, jsval *vp)
|
||||
{
|
||||
OOJS_NATIVE_ENTER(context);
|
||||
OOShipRegistry *registry = [OOShipRegistry sharedRegistry];
|
||||
|
||||
NSArray *keys = [registry shipRoles];
|
||||
OOJS_RETURN_OBJECT(keys);
|
||||
|
||||
OOJS_NATIVE_EXIT
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user