add missing fields

This commit is contained in:
Aaron Fischer 2019-08-11 23:52:30 +02:00
parent 814e270eef
commit 429ffe7c75
2 changed files with 53 additions and 4 deletions

View file

@ -66,6 +66,15 @@ class HenchmenGroup extends Unit {
@JsonKey(defaultValue: false)
bool large;
@JsonKey(defaultValue: false)
bool slowWitted;
@JsonKey(defaultValue: false)
bool mount;
@JsonKey(name: 'attackanimal', defaultValue: false)
bool attackAnimal;
@JsonKey(
fromJson: Unit._statsFromJson, toJson: Unit._statsToJson, required: true)
final Stats stats;
@ -76,8 +85,11 @@ class HenchmenGroup extends Unit {
@JsonKey(fromJson: Unit._splitListFromJson, toJson: Unit._joinListToJson)
final List<String> armour;
HenchmenGroup(
this.header, this.stats, this.weapons, this.armour, this.large) {
@JsonKey(fromJson: Unit._splitListFromJson, toJson: Unit._joinListToJson)
final List<String> rules;
HenchmenGroup(this.header, this.stats, this.weapons, this.armour, this.rules,
this.large, this.slowWitted, this.mount, this.attackAnimal) {
this.name = this.header['name'];
this.type = this.header['type'];
this.number = int.tryParse(this.header['number']) ?? 1;
@ -146,16 +158,35 @@ class Hero extends Unit {
@JsonKey(fromJson: Unit._splitListFromJson, toJson: Unit._joinListToJson)
final List<String> rules;
@JsonKey(fromJson: Unit._splitListFromJson, toJson: Unit._joinListToJson)
final List<String> injuries;
@JsonKey(defaultValue: 0)
final int warbandaddition;
@JsonKey(defaultValue: false)
bool large;
@JsonKey(defaultValue: false)
bool slowWitted;
@JsonKey(defaultValue: false, name: 'hiredsword')
final bool hiredSword;
Hero(this.stats, this.skilllists, this.weapons, this.armour, this.rules,
this.warbandaddition, this.large, this.header, this.hiredSword) {
@JsonKey(defaultValue: false, name: 'dramatispersonae')
final bool dramatisPersonae;
Hero(
this.stats,
this.skilllists,
this.weapons,
this.armour,
this.rules,
this.injuries,
this.warbandaddition,
this.large,
this.header,
this.hiredSword,
this.dramatisPersonae,
this.slowWitted) {
this.name = this.header['name'];
this.type = this.header['type'];
this.experience = int.tryParse(this.header['experience']) ?? 0;
@ -334,6 +365,10 @@ class WarbandRoster {
if (henchmenGroup.large) {
rating += 15 * henchmenGroup.number;
} else {
if (henchmenGroup.mount || henchmenGroup.attackAnimal) {
rating += 5 * henchmenGroup.number;
}
}
});

View file

@ -13,7 +13,11 @@ HenchmenGroup _$HenchmenGroupFromJson(Map json) {
Unit._statsFromJson(json['stats'] as String),
Unit._splitListFromJson(json['weapons'] as String),
Unit._splitListFromJson(json['armour'] as String),
Unit._splitListFromJson(json['rules'] as String),
json['large'] as bool ?? false,
json['slowWitted'] as bool ?? false,
json['mount'] as bool ?? false,
json['attackanimal'] as bool ?? false,
);
}
@ -21,9 +25,13 @@ Map<String, dynamic> _$HenchmenGroupToJson(HenchmenGroup instance) =>
<String, dynamic>{
'group': HenchmenGroup._henchmengroupHeaderToJson(instance.header),
'large': instance.large,
'slowWitted': instance.slowWitted,
'mount': instance.mount,
'attackanimal': instance.attackAnimal,
'stats': Unit._statsToJson(instance.stats),
'weapons': Unit._joinListToJson(instance.weapons),
'armour': Unit._joinListToJson(instance.armour),
'rules': Unit._joinListToJson(instance.rules),
};
Hero _$HeroFromJson(Map json) {
@ -34,10 +42,13 @@ Hero _$HeroFromJson(Map json) {
Unit._splitListFromJson(json['weapons'] as String),
Unit._splitListFromJson(json['armour'] as String),
Unit._splitListFromJson(json['rules'] as String),
Unit._splitListFromJson(json['injuries'] as String),
json['warbandaddition'] as int ?? 0,
json['large'] as bool ?? false,
Hero._heroHeaderFromJson(json['hero'] as String),
json['hiredsword'] as bool ?? false,
json['dramatispersonae'] as bool ?? false,
json['slowWitted'] as bool ?? false,
);
}
@ -48,9 +59,12 @@ Map<String, dynamic> _$HeroToJson(Hero instance) => <String, dynamic>{
'weapons': Unit._joinListToJson(instance.weapons),
'armour': Unit._joinListToJson(instance.armour),
'rules': Unit._joinListToJson(instance.rules),
'injuries': Unit._joinListToJson(instance.injuries),
'warbandaddition': instance.warbandaddition,
'large': instance.large,
'slowWitted': instance.slowWitted,
'hiredsword': instance.hiredSword,
'dramatispersonae': instance.dramatisPersonae,
};
WarbandRoster _$WarbandRosterFromJson(Map json) {