rename constructs
This commit is contained in:
@@ -9,7 +9,6 @@ use failure::err_msg;
|
||||
|
||||
use skill::{Skill, Cast, Immunity, Disable, Event};
|
||||
use effect::{Cooldown, Effect, Colour};
|
||||
use names::{name};
|
||||
use spec::{Spec};
|
||||
use item::{Item};
|
||||
use img;
|
||||
@@ -252,8 +251,8 @@ impl Construct {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn new_name(self) -> Construct {
|
||||
self.named(&name())
|
||||
pub fn new_name(self, name: String) -> Construct {
|
||||
self.named(&name)
|
||||
}
|
||||
|
||||
pub fn learn(mut self, s: Skill) -> Construct {
|
||||
|
||||
+2
-2
@@ -68,14 +68,14 @@ pub struct Mtx {
|
||||
variant: MtxVariant,
|
||||
}
|
||||
|
||||
pub fn apply(tx: &mut Transaction, account: &Account, variant: MtxVariant, construct_id: Uuid) -> Result<Vec<Construct>, Error> {
|
||||
pub fn apply(tx: &mut Transaction, account: &Account, variant: MtxVariant, construct_id: Uuid, name: String) -> Result<Vec<Construct>, Error> {
|
||||
let mtx = select(tx, variant, account.id)?;
|
||||
let mut construct = construct_select(tx, construct_id, account.id)?;
|
||||
|
||||
account::debit(tx, account.id, 1)?;
|
||||
|
||||
construct = match mtx.variant {
|
||||
MtxVariant::Rename => construct.new_name(),
|
||||
MtxVariant::Rename => construct.new_name(name),
|
||||
_ => construct.new_img(),
|
||||
};
|
||||
match mtx.variant {
|
||||
|
||||
+3
-3
@@ -42,7 +42,7 @@ enum RpcRequest {
|
||||
ItemInfo {},
|
||||
DevResolve { a: Uuid, b: Uuid, skill: Skill },
|
||||
|
||||
MtxConstructApply { mtx: mtx::MtxVariant, construct_id: Uuid },
|
||||
MtxConstructApply { mtx: mtx::MtxVariant, construct_id: Uuid, name: String },
|
||||
MtxAccountApply { mtx: mtx::MtxVariant },
|
||||
MtxBuy { mtx: mtx::MtxVariant },
|
||||
|
||||
@@ -149,8 +149,8 @@ pub fn receive(data: Vec<u8>, db: &Db, _client: &mut WebSocket<TcpStream>, begin
|
||||
Ok(RpcResult::InstanceState(vbox_unequip(&mut tx, account, instance_id, construct_id, target)?)),
|
||||
|
||||
|
||||
RpcRequest::MtxConstructApply { mtx, construct_id } =>
|
||||
Ok(RpcResult::AccountConstructs(mtx::apply(&mut tx, account, mtx, construct_id)?)),
|
||||
RpcRequest::MtxConstructApply { mtx, construct_id, name } =>
|
||||
Ok(RpcResult::AccountConstructs(mtx::apply(&mut tx, account, mtx, construct_id, name)?)),
|
||||
|
||||
RpcRequest::MtxBuy { mtx } =>
|
||||
Ok(RpcResult::AccountShop(mtx::buy(&mut tx, account, mtx)?)),
|
||||
|
||||
Reference in New Issue
Block a user