max skills
This commit is contained in:
parent
e566bbc7e9
commit
fa603009a1
@ -359,6 +359,12 @@ pub fn cryp_spawn(params: CrypSpawnParams, tx: &mut Transaction, account: &Accou
|
|||||||
|
|
||||||
pub fn cryp_learn(params: CrypLearnParams, tx: &mut Transaction, account: &Account) -> Result<Cryp, Error> {
|
pub fn cryp_learn(params: CrypLearnParams, tx: &mut Transaction, account: &Account) -> Result<Cryp, Error> {
|
||||||
let mut cryp = cryp_get(tx, params.id, account.id)?;
|
let mut cryp = cryp_get(tx, params.id, account.id)?;
|
||||||
|
|
||||||
|
let max_skills = 4;
|
||||||
|
if cryp.skills.len() >= max_skills {
|
||||||
|
return Err(format_err!("cryp at max skills ({:?})", max_skills));
|
||||||
|
}
|
||||||
|
|
||||||
cryp = cryp.learn(params.skill);
|
cryp = cryp.learn(params.skill);
|
||||||
return cryp_write(cryp, tx);
|
return cryp_write(cryp, tx);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -747,7 +747,7 @@ mod tests {
|
|||||||
use cryp::*;
|
use cryp::*;
|
||||||
|
|
||||||
fn create_test_game() -> Game {
|
fn create_test_game() -> Game {
|
||||||
let x = Cryp::new()
|
let mut x = Cryp::new()
|
||||||
.named(&"pronounced \"creeep\"".to_string())
|
.named(&"pronounced \"creeep\"".to_string())
|
||||||
.level(8)
|
.level(8)
|
||||||
.learn(Skill::TestStun)
|
.learn(Skill::TestStun)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user