Source/Player.m
changeset 13 db7bb080c3d5
parent 10 6c78cc6bd7a6
child 14 4585c74d809c
     1.1 --- a/Source/Player.m	Thu Jul 03 17:44:30 2008 -0700
     1.2 +++ b/Source/Player.m	Tue Jul 08 13:12:01 2008 -0700
     1.3 @@ -40,10 +40,8 @@
     1.4      if( self ) {
     1.5          _game =  [decoder decodeObjectForKey: @"game"];
     1.6          _name = [[decoder decodeObjectForKey: @"name"] copy];
     1.7 -        _uuid = [[decoder decodeObjectForKey: @"UUID"] copy];
     1.8 -        _address = [[decoder decodeObjectForKey: @"address"] copy];
     1.9 -        _addressType = [[decoder decodeObjectForKey: @"addressType"] copy];
    1.10          _local=  [decoder decodeBoolForKey:   @"local"];
    1.11 +        _extraValues = [[decoder decodeObjectForKey: @"extraValues"] mutableCopy];
    1.12      }
    1.13      return self;
    1.14  }
    1.15 @@ -52,23 +50,35 @@
    1.16  {
    1.17      [coder encodeObject: _game  forKey: @"game"];
    1.18      [coder encodeObject: _name  forKey: @"name"];
    1.19 -    [coder encodeObject: _uuid  forKey: @"UUID"];
    1.20 -    [coder encodeObject: _address forKey: @"address"];
    1.21 -    [coder encodeObject: _addressType forKey: @"addressType"];
    1.22      [coder encodeBool:   _local forKey: @"local"];
    1.23 +    [coder encodeObject: _extraValues forKey: @"extraValues"];
    1.24  }
    1.25  
    1.26  - (void) dealloc
    1.27  {
    1.28      [_name release];
    1.29 -    [_uuid release];
    1.30 -    [_address release];
    1.31 -    [_addressType release];
    1.32 +    [_extraValues release];
    1.33      [super dealloc];
    1.34  }
    1.35  
    1.36  
    1.37 -@synthesize game=_game, name=_name, UUID=_uuid, address=_address, addressType=_addressType, local=_local;
    1.38 +- (id)valueForUndefinedKey:(NSString *)key
    1.39 +{
    1.40 +    return [_extraValues objectForKey: key];
    1.41 +}
    1.42 +
    1.43 +- (void)setValue:(id)value forUndefinedKey:(NSString *)key
    1.44 +{
    1.45 +    if( ! _extraValues )
    1.46 +        _extraValues = [[NSMutableDictionary alloc] init];
    1.47 +    if( value )
    1.48 +        [_extraValues setObject: value forKey: key];
    1.49 +    else
    1.50 +        [_extraValues removeObjectForKey: key];
    1.51 +}
    1.52 +
    1.53 +
    1.54 +@synthesize game=_game, name=_name, local=_local;
    1.55  
    1.56  - (BOOL) isCurrent      {return self == _game.currentPlayer;}
    1.57  - (BOOL) isFriendly     {return self == _game.currentPlayer;}   // could be overridden for games with partners