Added validation to Move card property.

This commit is contained in:
2020-05-29 23:09:45 +01:00
parent 355da1476e
commit 615b48f212

View File

@@ -89,6 +89,22 @@ impl Bytes for Move {
}
fn validate(&self) -> Validation {
Validation::new()
// Create the initial validation
let mut validation = Validation::new();
// If our name is longer or equal to `0x16` bytes, emit error
if self.name.len() >= 0x16 {
validation.add_error("Name must be at most 21 characters.");
}
// If the power isn't a multiple of 10, warn, as we don't know how the game handles
// powers that aren't multiples of 10.
// TODO: Verify if the game can handle non-multiple of 10 powers.
if self.power % 10 != 0 {
validation.add_warning("Powers that are not a multiple of 10 are not fully supported.");
}
// And return the validation
validation
}
}