Adds charismaScore and charismaModifier to Monster.

Adds tests for charismaScore and charismaModifier.
This commit is contained in:
2020-09-13 03:39:55 -07:00
parent efaf492e41
commit d66e5140e7
2 changed files with 30 additions and 2 deletions

View File

@@ -97,6 +97,11 @@
if (tempNumber != nil && [tempNumber isKindOfClass:[NSNumber class]]) { if (tempNumber != nil && [tempNumber isKindOfClass:[NSNumber class]]) {
self.wisdomScore = tempNumber.intValue; self.wisdomScore = tempNumber.intValue;
} }
tempNumber = [jsonRoot objectForKey:@"chaPoints"];
if (tempNumber != nil && [tempNumber isKindOfClass:[NSNumber class]]) {
self.charismaScore = tempNumber.intValue;
}
return self; return self;
} }
@@ -160,9 +165,10 @@
} }
-(int)charismaModifier { -(int)charismaModifier {
@throw [[NSException alloc] initWithName:@"unimplemented" reason:@"Method not implemented." userInfo:nil]; return [Monster abilityModifierForScore:self.charismaScore];
} }
//getArmorClass //getArmorClass
-(NSString*)armorClassDescription { -(NSString*)armorClassDescription {
@throw [[NSException alloc] initWithName:@"unimplemented" reason:@"Method not implemented." userInfo:nil]; @throw [[NSException alloc] initWithName:@"unimplemented" reason:@"Method not implemented." userInfo:nil];
@@ -365,6 +371,7 @@
self.constitutionScore = monster.constitutionScore; self.constitutionScore = monster.constitutionScore;
self.intelligenceScore = monster.intelligenceScore; self.intelligenceScore = monster.intelligenceScore;
self.wisdomScore = monster.wisdomScore; self.wisdomScore = monster.wisdomScore;
self.charismaScore = monster.charismaScore;
} }
@end @end

View File

@@ -25,7 +25,7 @@
- (void)setUp { - (void)setUp {
_context = nil; _context = nil;
_monster = [[Monster alloc] initWithContext:_context]; _monster = [[Monster alloc] initWithContext:_context];
_jsonString = @"{\"name\":\"Acolyte\",\"size\":\"medium\",\"type\":\"humanoid\",\"tag\":\"any race\",\"alignment\":\"any alignment\",\"strPoints\":8,\"dexPoints\":10,\"conPoints\":12,\"intPoints\":14,\"wisPoints\":16}"; _jsonString = @"{\"name\":\"Acolyte\",\"size\":\"medium\",\"type\":\"humanoid\",\"tag\":\"any race\",\"alignment\":\"any alignment\",\"strPoints\":8,\"dexPoints\":10,\"conPoints\":12,\"intPoints\":14,\"wisPoints\":16,\"chaPoints\":18}";
_jsonData = [_jsonString dataUsingEncoding:NSUTF8StringEncoding]; _jsonData = [_jsonString dataUsingEncoding:NSUTF8StringEncoding];
} }
@@ -45,6 +45,7 @@
XCTAssertEqual(0, _monster.constitutionScore); XCTAssertEqual(0, _monster.constitutionScore);
XCTAssertEqual(0, _monster.intelligenceScore); XCTAssertEqual(0, _monster.intelligenceScore);
XCTAssertEqual(0, _monster.wisdomScore); XCTAssertEqual(0, _monster.wisdomScore);
XCTAssertEqual(0, _monster.charismaScore);
} }
- (void)testInitWithJSONString { - (void)testInitWithJSONString {
@@ -61,6 +62,7 @@
XCTAssertEqual(12, _monster.constitutionScore); XCTAssertEqual(12, _monster.constitutionScore);
XCTAssertEqual(14, _monster.intelligenceScore); XCTAssertEqual(14, _monster.intelligenceScore);
XCTAssertEqual(16, _monster.wisdomScore); XCTAssertEqual(16, _monster.wisdomScore);
XCTAssertEqual(18, _monster.charismaScore);
} }
- (void)testInitWithEmptyJSONString { - (void)testInitWithEmptyJSONString {
@@ -77,6 +79,7 @@
XCTAssertEqual(0, _monster.constitutionScore); XCTAssertEqual(0, _monster.constitutionScore);
XCTAssertEqual(0, _monster.intelligenceScore); XCTAssertEqual(0, _monster.intelligenceScore);
XCTAssertEqual(0, _monster.wisdomScore); XCTAssertEqual(0, _monster.wisdomScore);
XCTAssertEqual(0, _monster.charismaScore);
} }
- (void)testInitWithJSONData { - (void)testInitWithJSONData {
_monster = [[Monster alloc] initWithJSONData:_jsonData andContext:_context]; _monster = [[Monster alloc] initWithJSONData:_jsonData andContext:_context];
@@ -92,6 +95,7 @@
XCTAssertEqual(12, _monster.constitutionScore); XCTAssertEqual(12, _monster.constitutionScore);
XCTAssertEqual(14, _monster.intelligenceScore); XCTAssertEqual(14, _monster.intelligenceScore);
XCTAssertEqual(16, _monster.wisdomScore); XCTAssertEqual(16, _monster.wisdomScore);
XCTAssertEqual(18, _monster.charismaScore);
} }
- (void)testNameGetterAndSetter { - (void)testNameGetterAndSetter {
@@ -138,6 +142,7 @@
XCTAssertEqual(12, _monster.constitutionScore); XCTAssertEqual(12, _monster.constitutionScore);
XCTAssertEqual(14, _monster.intelligenceScore); XCTAssertEqual(14, _monster.intelligenceScore);
XCTAssertEqual(16, _monster.wisdomScore); XCTAssertEqual(16, _monster.wisdomScore);
XCTAssertEqual(18, _monster.charismaScore);
} }
- (void)testMetaWithNoFieldsSet { - (void)testMetaWithNoFieldsSet {
@@ -336,4 +341,20 @@
XCTAssertEqual(1, _monster.wisdomModifier); XCTAssertEqual(1, _monster.wisdomModifier);
} }
- (void)testCharismaScoreGetterAndSetter {
_monster.charismaScore = 11;
XCTAssertEqual(11, _monster.charismaScore);
}
- (void)testCharismaModifier {
_monster.charismaScore = 9;
XCTAssertEqual(-1, _monster.charismaModifier);
_monster.charismaScore = 10;
XCTAssertEqual(0, _monster.charismaModifier);
_monster.charismaScore = 12;
XCTAssertEqual(1, _monster.charismaModifier);
}
@end @end