Merge branch 'release/1.4.8' of ssh://git.mnml.gg:40022/~/mnml into release/1.4.8

This commit is contained in:
Mashy 2019-09-20 15:41:09 +10:00
commit 7cd6a0979c
2 changed files with 8 additions and 5 deletions

View File

@ -238,7 +238,7 @@ impl Construct {
pub fn from_skeleton(skeleton: &ConstructSkeleton) -> Construct {
return Construct {
id: skeleton.id,
account: skeleton.id,
account: skeleton.account,
img: skeleton.img,
name: skeleton.name.clone(),
@ -249,7 +249,7 @@ impl Construct {
pub fn to_skeleton(&self) -> ConstructSkeleton {
ConstructSkeleton {
id: self.id,
account: self.id,
account: self.account,
img: self.img,
name: self.name.clone(),
}
@ -271,8 +271,11 @@ impl Construct {
self
}
pub fn new_name(self, name: String) -> Construct {
self.named(&name)
pub fn new_name(self, name: String) -> Result<Construct, Error> {
if name.len() > 20 {
return Err(err_msg("20 character name maximum"));
}
Ok(self.named(&name))
}
pub fn learn(mut self, s: Skill) -> Construct {

View File

@ -152,7 +152,7 @@ pub fn apply(tx: &mut Transaction, account: &Account, variant: MtxVariant, const
account::debit(tx, account.id, cost)?;
construct = match mtx.variant {
MtxVariant::Rename => construct.new_name(name),
MtxVariant::Rename => construct.new_name(name)?,
_ => construct.new_img(),
};