if([self.primitiveMaster_ship isEqual:value]) return;
// NSLog(@"Ship did change master_ship.");
+ [self willChangeValueForKey:@"master_ship"];
self.primitiveMaster_ship = value;
+ [self didChangeValueForKey:@"master_ship"];
}
- (NSManagedObject *)master_ship
{
- (NSNumber *)isMaxKaryoku
{
+ [self willAccessValueForKey:@"master_ship"];
+ [self willAccessValueForKey:@"karyoku_1"];
+ [self willAccessValueForKey:@"kyouka_0"];
NSInteger defaultValue = [[self valueForKeyPath:@"master_ship.houg_0"] integerValue];
NSInteger maxValue = [[self valueForKey:@"karyoku_1"] integerValue];
NSInteger growth = [[self valueForKey:@"kyouka_0"] integerValue];
+ [self didAccessValueForKey:@"kyouka_0"];
+ [self didAccessValueForKey:@"karyoku_1"];
+ [self didAccessValueForKey:@"master_ship"];
return @(defaultValue + growth >= maxValue);
}
- (NSNumber *)isMaxRaisou
{
+ [self willAccessValueForKey:@"master_ship"];
+ [self willAccessValueForKey:@"raisou_1"];
+ [self willAccessValueForKey:@"kyouka_1"];
NSInteger defaultValue = [[self valueForKeyPath:@"master_ship.raig_0"] integerValue];
NSInteger maxValue = [[self valueForKey:@"raisou_1"] integerValue];
NSInteger growth = [[self valueForKey:@"kyouka_1"] integerValue];
+ [self didAccessValueForKey:@"kyouka_1"];
+ [self didAccessValueForKey:@"raisou_1"];
+ [self didAccessValueForKey:@"master_ship"];
return @(defaultValue + growth >= maxValue);
}
- (NSNumber *)isMaxTaiku
{
+ [self willAccessValueForKey:@"master_ship"];
+ [self willAccessValueForKey:@"taiku_1"];
+ [self willAccessValueForKey:@"kyouka_2"];
NSInteger defaultValue = [[self valueForKeyPath:@"master_ship.tyku_0"] integerValue];
NSInteger maxValue = [[self valueForKey:@"taiku_1"] integerValue];
NSInteger growth = [[self valueForKey:@"kyouka_2"] integerValue];
+ [self didAccessValueForKey:@"kyouka_2"];
+ [self didAccessValueForKey:@"taiku_1"];
+ [self didAccessValueForKey:@"master_ship"];
return @(defaultValue + growth >= maxValue);
}
- (NSNumber *)isMaxSoukou
{
+ [self willAccessValueForKey:@"master_ship"];
+ [self willAccessValueForKey:@"soukou_1"];
+ [self willAccessValueForKey:@"kyouka_3"];
NSInteger defaultValue = [[self valueForKeyPath:@"master_ship.souk_0"] integerValue];
NSInteger maxValue = [[self valueForKey:@"soukou_1"] integerValue];
NSInteger growth = [[self valueForKey:@"kyouka_3"] integerValue];
+ [self didAccessValueForKey:@"kyouka_3"];
+ [self didAccessValueForKey:@"soukou_1"];
+ [self didAccessValueForKey:@"master_ship"];
return @(defaultValue + growth >= maxValue);
}
- (NSNumber *)isMaxLucky
{
+ [self willAccessValueForKey:@"master_ship"];
+ [self willAccessValueForKey:@"lucky_1"];
+ [self willAccessValueForKey:@"kyouka_4"];
NSInteger defaultValue = [[self valueForKeyPath:@"master_ship.luck_0"] integerValue];
NSInteger maxValue = [[self valueForKey:@"lucky_1"] integerValue];
NSInteger growth = [[self valueForKey:@"kyouka_4"] integerValue];
+ [self didAccessValueForKey:@"kyouka_4"];
+ [self didAccessValueForKey:@"lucky_1"];
+ [self didAccessValueForKey:@"master_ship"];
return @(defaultValue + growth >= maxValue);
}
}
- (NSString *)shortTypeName
{
+ [self willAccessValueForKey:@"master_ship"];
NSNumber *idValue = [self valueForKeyPath:@"master_ship.stype.id"];
+ [self didAccessValueForKey:@"master_ship"];
if(!idValue || [idValue isKindOfClass:[NSNull class]]) return nil;
if([shortSTypeNames count] < [idValue integerValue]) return nil;
- (NSNumber *)next
{
- NSUInteger nextExp = [[levelUpExps objectAtIndex:[[self valueForKey:@"lv"] integerValue]] integerValue];
+ [self willAccessValueForKey:@"lv"];
+ id lvValue = self.lv;
+ [self didAccessValueForKey:@"lv"];
+ [self willAccessValueForKey:@"exp"];
+ id expValue = self.exp;
+ [self didAccessValueForKey:@"exp"];
- return [NSNumber numberWithInteger:nextExp - [[self valueForKey:@"exp"] integerValue]];
+ NSUInteger nextExp = [[levelUpExps objectAtIndex:[lvValue integerValue]] integerValue];
+
+ return @(nextExp - [expValue integerValue]);
}
- (NSColor *)statusColor
{
#if 0
+ [self willAccessValueForKey:@"maxhp"];
+ [self willAccessValueForKey:@"nowhp"];
NSInteger maxhp = [[self valueForKey:@"maxhp"] integerValue];
CGFloat nowhp = [[self valueForKey:@"nowhp"] integerValue];
CGFloat status = nowhp / maxhp;
return [NSColor yellowColor];
}
+ [self didAccessValueForKey:@"nowhp"];
+ [self didAccessValueForKey:@"maxhp"];
#endif
return [NSColor controlTextColor];
}