From 615b48f212f300b68f94d1e343dcdf5309ca2f96 Mon Sep 17 00:00:00 2001 From: Filipe Rodrigues Date: Fri, 29 May 2020 23:09:45 +0100 Subject: [PATCH] Added validation to `Move` card property. --- src/game/card/property/moves.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/game/card/property/moves.rs b/src/game/card/property/moves.rs index b33ca5a..6599f26 100644 --- a/src/game/card/property/moves.rs +++ b/src/game/card/property/moves.rs @@ -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 } }