Adds shieldBonus to Monster entity.

Adds tests for shieldBonus.
This commit is contained in:
2020-09-13 04:35:49 -07:00
parent 700724ce5b
commit 88927c9ddc
4 changed files with 24 additions and 5 deletions

View File

@@ -37,7 +37,6 @@ NS_ASSUME_NONNULL_BEGIN
@property NSString *truesightDistance;
@property NSString *understandsBut;
@property int shieldBonus;
@property int naturalArmorBonus;
@property int hitDice;
@property int customProficiencyBonus;

View File

@@ -27,7 +27,6 @@
@synthesize hpText;
@synthesize isBlind;
@synthesize naturalArmorBonus;
@synthesize shieldBonus;
@synthesize speed;
@synthesize swimSpeed;
@synthesize telepathy;
@@ -95,6 +94,10 @@
if (tempNumber != nil && [tempNumber isKindOfClass:[NSNumber class]]) {
self.charismaScore = tempNumber.intValue;
}
tempNumber = [jsonRoot objectForKey:@"shieldBonus"];
if (tempNumber != nil && [tempNumber isKindOfClass:[NSNumber class]]) {
self.shieldBonus = tempNumber.intValue;
}
return self;
}
@@ -368,6 +371,7 @@
self.charismaScore = monster.charismaScore;
self.armorName = monster.armorName;
self.otherArmorDescription = monster.otherArmorDescription;
self.shieldBonus = monster.shieldBonus;
}
@end

View File

@@ -9,6 +9,7 @@
<attribute name="intelligenceScore" optional="YES" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES"/>
<attribute name="name" attributeType="String" defaultValueString=""/>
<attribute name="otherArmorDescription" optional="YES" attributeType="String" defaultValueString=""/>
<attribute name="shieldBonus" optional="YES" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES"/>
<attribute name="size" attributeType="String" defaultValueString=""/>
<attribute name="strengthScore" optional="YES" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES"/>
<attribute name="subtype" attributeType="String" defaultValueString=""/>
@@ -16,6 +17,6 @@
<attribute name="wisdomScore" optional="YES" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES"/>
</entity>
<elements>
<element name="Monster" positionX="-63" positionY="-18" width="128" height="238"/>
<element name="Monster" positionX="-63" positionY="-18" width="128" height="253"/>
</elements>
</model>

View File

@@ -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,\"chaPoints\":18,\"armorName\":\"none\"}";
_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,\"armorName\":\"none\",\"otherArmorDesc\":\"10\",\"shieldBonus\":2}";
_jsonData = [_jsonString dataUsingEncoding:NSUTF8StringEncoding];
}
@@ -47,6 +47,8 @@
XCTAssertEqual(0, _monster.wisdomScore);
XCTAssertEqual(0, _monster.charismaScore);
XCTAssertEqualObjects(@"", _monster.armorName);
XCTAssertEqualObjects(@"", _monster.otherArmorDescription);
XCTAssertEqual(0, _monster.shieldBonus);
}
- (void)testInitWithJSONString {
@@ -65,6 +67,8 @@
XCTAssertEqual(16, _monster.wisdomScore);
XCTAssertEqual(18, _monster.charismaScore);
XCTAssertEqualObjects(@"none", _monster.armorName);
XCTAssertEqualObjects(@"10", _monster.otherArmorDescription);
XCTAssertEqual(2, _monster.shieldBonus);
}
- (void)testInitWithEmptyJSONString {
@@ -83,6 +87,8 @@
XCTAssertEqual(0, _monster.wisdomScore);
XCTAssertEqual(0, _monster.charismaScore);
XCTAssertEqualObjects(@"", _monster.armorName);
XCTAssertEqualObjects(@"", _monster.otherArmorDescription);
XCTAssertEqual(0, _monster.shieldBonus);
}
- (void)testInitWithJSONData {
_monster = [[Monster alloc] initWithJSONData:_jsonData andContext:_context];
@@ -100,6 +106,8 @@
XCTAssertEqual(16, _monster.wisdomScore);
XCTAssertEqual(18, _monster.charismaScore);
XCTAssertEqualObjects(@"none", _monster.armorName);
XCTAssertEqualObjects(@"10", _monster.otherArmorDescription);
XCTAssertEqual(2, _monster.shieldBonus);
}
- (void)testNameGetterAndSetter {
@@ -148,6 +156,8 @@
XCTAssertEqual(16, _monster.wisdomScore);
XCTAssertEqual(18, _monster.charismaScore);
XCTAssertEqualObjects(@"none", _monster.armorName);
XCTAssertEqualObjects(@"10", _monster.otherArmorDescription);
XCTAssertEqual(2, _monster.shieldBonus);
}
- (void)testMetaWithNoFieldsSet {
@@ -364,7 +374,12 @@
- (void)testGetterAndSetterForArmorName {
_monster.armorName = @"dandelion";
XCTAssertEqualObjects(_monster.armorName, @"dandelion");
XCTAssertEqualObjects(@"dandelion", _monster.armorName);
}
- (void)testGetterAndSetterForOtherArmorDescription {
_monster.otherArmorDescription = @"green";
XCTAssertEqualObjects(@"green", _monster.otherArmorDescription);
}
@end