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) @JsonKey(defaultValue: false)
bool large; bool large;
@JsonKey(defaultValue: false)
bool slowWitted;
@JsonKey(defaultValue: false)
bool mount;
@JsonKey(name: 'attackanimal', defaultValue: false)
bool attackAnimal;
@JsonKey( @JsonKey(
fromJson: Unit._statsFromJson, toJson: Unit._statsToJson, required: true) fromJson: Unit._statsFromJson, toJson: Unit._statsToJson, required: true)
final Stats stats; final Stats stats;
@ -76,8 +85,11 @@ class HenchmenGroup extends Unit {
@JsonKey(fromJson: Unit._splitListFromJson, toJson: Unit._joinListToJson) @JsonKey(fromJson: Unit._splitListFromJson, toJson: Unit._joinListToJson)
final List<String> armour; final List<String> armour;
HenchmenGroup( @JsonKey(fromJson: Unit._splitListFromJson, toJson: Unit._joinListToJson)
this.header, this.stats, this.weapons, this.armour, this.large) { 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.name = this.header['name'];
this.type = this.header['type']; this.type = this.header['type'];
this.number = int.tryParse(this.header['number']) ?? 1; this.number = int.tryParse(this.header['number']) ?? 1;
@ -146,16 +158,35 @@ class Hero extends Unit {
@JsonKey(fromJson: Unit._splitListFromJson, toJson: Unit._joinListToJson) @JsonKey(fromJson: Unit._splitListFromJson, toJson: Unit._joinListToJson)
final List<String> rules; final List<String> rules;
@JsonKey(fromJson: Unit._splitListFromJson, toJson: Unit._joinListToJson)
final List<String> injuries;
@JsonKey(defaultValue: 0) @JsonKey(defaultValue: 0)
final int warbandaddition; final int warbandaddition;
@JsonKey(defaultValue: false) @JsonKey(defaultValue: false)
bool large; bool large;
@JsonKey(defaultValue: false)
bool slowWitted;
@JsonKey(defaultValue: false, name: 'hiredsword') @JsonKey(defaultValue: false, name: 'hiredsword')
final bool hiredSword; final bool hiredSword;
Hero(this.stats, this.skilllists, this.weapons, this.armour, this.rules, @JsonKey(defaultValue: false, name: 'dramatispersonae')
this.warbandaddition, this.large, this.header, this.hiredSword) { 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.name = this.header['name'];
this.type = this.header['type']; this.type = this.header['type'];
this.experience = int.tryParse(this.header['experience']) ?? 0; this.experience = int.tryParse(this.header['experience']) ?? 0;
@ -334,6 +365,10 @@ class WarbandRoster {
if (henchmenGroup.large) { if (henchmenGroup.large) {
rating += 15 * henchmenGroup.number; 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._statsFromJson(json['stats'] as String),
Unit._splitListFromJson(json['weapons'] as String), Unit._splitListFromJson(json['weapons'] as String),
Unit._splitListFromJson(json['armour'] as String), Unit._splitListFromJson(json['armour'] as String),
Unit._splitListFromJson(json['rules'] as String),
json['large'] as bool ?? false, 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>{ <String, dynamic>{
'group': HenchmenGroup._henchmengroupHeaderToJson(instance.header), 'group': HenchmenGroup._henchmengroupHeaderToJson(instance.header),
'large': instance.large, 'large': instance.large,
'slowWitted': instance.slowWitted,
'mount': instance.mount,
'attackanimal': instance.attackAnimal,
'stats': Unit._statsToJson(instance.stats), 'stats': Unit._statsToJson(instance.stats),
'weapons': Unit._joinListToJson(instance.weapons), 'weapons': Unit._joinListToJson(instance.weapons),
'armour': Unit._joinListToJson(instance.armour), 'armour': Unit._joinListToJson(instance.armour),
'rules': Unit._joinListToJson(instance.rules),
}; };
Hero _$HeroFromJson(Map json) { Hero _$HeroFromJson(Map json) {
@ -34,10 +42,13 @@ Hero _$HeroFromJson(Map json) {
Unit._splitListFromJson(json['weapons'] as String), Unit._splitListFromJson(json['weapons'] as String),
Unit._splitListFromJson(json['armour'] as String), Unit._splitListFromJson(json['armour'] as String),
Unit._splitListFromJson(json['rules'] as String), Unit._splitListFromJson(json['rules'] as String),
Unit._splitListFromJson(json['injuries'] as String),
json['warbandaddition'] as int ?? 0, json['warbandaddition'] as int ?? 0,
json['large'] as bool ?? false, json['large'] as bool ?? false,
Hero._heroHeaderFromJson(json['hero'] as String), Hero._heroHeaderFromJson(json['hero'] as String),
json['hiredsword'] as bool ?? false, 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), 'weapons': Unit._joinListToJson(instance.weapons),
'armour': Unit._joinListToJson(instance.armour), 'armour': Unit._joinListToJson(instance.armour),
'rules': Unit._joinListToJson(instance.rules), 'rules': Unit._joinListToJson(instance.rules),
'injuries': Unit._joinListToJson(instance.injuries),
'warbandaddition': instance.warbandaddition, 'warbandaddition': instance.warbandaddition,
'large': instance.large, 'large': instance.large,
'slowWitted': instance.slowWitted,
'hiredsword': instance.hiredSword, 'hiredsword': instance.hiredSword,
'dramatispersonae': instance.dramatisPersonae,
}; };
WarbandRoster _$WarbandRosterFromJson(Map json) { WarbandRoster _$WarbandRosterFromJson(Map json) {