Adds charismaScore and charismaModifier to Monster.
Adds tests for charismaScore and charismaModifier.
This commit is contained in:
@@ -97,6 +97,11 @@
|
||||
if (tempNumber != nil && [tempNumber isKindOfClass:[NSNumber class]]) {
|
||||
self.wisdomScore = tempNumber.intValue;
|
||||
}
|
||||
tempNumber = [jsonRoot objectForKey:@"chaPoints"];
|
||||
if (tempNumber != nil && [tempNumber isKindOfClass:[NSNumber class]]) {
|
||||
self.charismaScore = tempNumber.intValue;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -160,9 +165,10 @@
|
||||
}
|
||||
|
||||
-(int)charismaModifier {
|
||||
@throw [[NSException alloc] initWithName:@"unimplemented" reason:@"Method not implemented." userInfo:nil];
|
||||
return [Monster abilityModifierForScore:self.charismaScore];
|
||||
}
|
||||
|
||||
|
||||
//getArmorClass
|
||||
-(NSString*)armorClassDescription {
|
||||
@throw [[NSException alloc] initWithName:@"unimplemented" reason:@"Method not implemented." userInfo:nil];
|
||||
@@ -365,6 +371,7 @@
|
||||
self.constitutionScore = monster.constitutionScore;
|
||||
self.intelligenceScore = monster.intelligenceScore;
|
||||
self.wisdomScore = monster.wisdomScore;
|
||||
self.charismaScore = monster.charismaScore;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
- (void)setUp {
|
||||
_context = nil;
|
||||
_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];
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
XCTAssertEqual(0, _monster.constitutionScore);
|
||||
XCTAssertEqual(0, _monster.intelligenceScore);
|
||||
XCTAssertEqual(0, _monster.wisdomScore);
|
||||
XCTAssertEqual(0, _monster.charismaScore);
|
||||
}
|
||||
|
||||
- (void)testInitWithJSONString {
|
||||
@@ -61,6 +62,7 @@
|
||||
XCTAssertEqual(12, _monster.constitutionScore);
|
||||
XCTAssertEqual(14, _monster.intelligenceScore);
|
||||
XCTAssertEqual(16, _monster.wisdomScore);
|
||||
XCTAssertEqual(18, _monster.charismaScore);
|
||||
}
|
||||
|
||||
- (void)testInitWithEmptyJSONString {
|
||||
@@ -77,6 +79,7 @@
|
||||
XCTAssertEqual(0, _monster.constitutionScore);
|
||||
XCTAssertEqual(0, _monster.intelligenceScore);
|
||||
XCTAssertEqual(0, _monster.wisdomScore);
|
||||
XCTAssertEqual(0, _monster.charismaScore);
|
||||
}
|
||||
- (void)testInitWithJSONData {
|
||||
_monster = [[Monster alloc] initWithJSONData:_jsonData andContext:_context];
|
||||
@@ -92,6 +95,7 @@
|
||||
XCTAssertEqual(12, _monster.constitutionScore);
|
||||
XCTAssertEqual(14, _monster.intelligenceScore);
|
||||
XCTAssertEqual(16, _monster.wisdomScore);
|
||||
XCTAssertEqual(18, _monster.charismaScore);
|
||||
}
|
||||
|
||||
- (void)testNameGetterAndSetter {
|
||||
@@ -138,6 +142,7 @@
|
||||
XCTAssertEqual(12, _monster.constitutionScore);
|
||||
XCTAssertEqual(14, _monster.intelligenceScore);
|
||||
XCTAssertEqual(16, _monster.wisdomScore);
|
||||
XCTAssertEqual(18, _monster.charismaScore);
|
||||
}
|
||||
|
||||
- (void)testMetaWithNoFieldsSet {
|
||||
@@ -336,4 +341,20 @@
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user