From 940b1c762bb98a56dddc6e3e7f208867abb3ebe5 Mon Sep 17 00:00:00 2001 From: troido Date: Fri, 7 Feb 2020 19:10:13 +0100 Subject: added roomtemplate --- src/pos.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/pos.rs') diff --git a/src/pos.rs b/src/pos.rs index 12c71bb..3003b64 100644 --- a/src/pos.rs +++ b/src/pos.rs @@ -7,14 +7,14 @@ use super::util::{clamp, ToJson}; #[derive(Debug, Hash, PartialEq, Eq, Clone, Copy)] pub struct Pos { - pub x: i32, - pub y: i32 + pub x: i64, + pub y: i64 } impl Pos { - pub fn new(x: i32, y: i32) -> Pos { + pub fn new(x: i64, y: i64) -> Pos { Pos {x, y} } @@ -24,6 +24,13 @@ impl Pos { y: clamp(self.y, smaller.y, larger.y) } } + + pub fn from_json(val: &Value) -> Option{ + Some(Pos { + x: val.get(0)?.as_i64()?, + y: val.get(1)?.as_i64()? + }) + } } -- cgit