Definition at line 35 of file OORoleSet.m.
◆ initWithRolesAndProbabilities:
- (id) initWithRolesAndProbabilities: |
|
(NSDictionary *) | dict |
|
Extends class OORoleSet.
Definition at line 315 of file OORoleSet.m.
264 :(NSDictionary *)dict
265{
266 NSEnumerator *roleEnum =
nil;
267 NSString *role =
nil;
268 float prob;
269
271 {
272 [self release];
274 }
275
276 self = [super init];
277 if (
self ==
nil)
return nil;
278
279
280
281
282
283 assert(_roles ==
nil && _roleString ==
nil);
284
285 NSMutableDictionary *tDict = [[dict mutableCopy] autorelease];
286 float thargProb = [dict oo_floatForKey:@"thargon" defaultValue:0.0f];
287
288 if ( thargProb > 0.0f && [dict objectForKey:
@"EQ_THARGON"] ==
nil)
289 {
290 [tDict setObject:[NSNumber numberWithFloat:thargProb] forKey:@"EQ_THARGON"];
291 [tDict removeObjectForKey:@"thargon"];
292 }
293
294 _rolesAndProbabilities = [tDict copy];
295
296 for (roleEnum = [dict keyEnumerator]; (role = [roleEnum nextObject]); )
297 {
298 prob = [dict oo_floatForKey:role defaultValue:-1];
299 if (prob < 0)
300 {
301 OOLog(
@"roleSet.badValue",
@"Attempt to create a role set with negative or non-numerical probability for role %@.", role);
302 [self release];
304 }
305
306 _totalProb += prob;
307 }
308
309 return self;
310}
#define OOLog(class, format,...)
The documentation for this category was generated from the following file: