This commit is contained in:
ntr
2019-01-16 23:51:06 +11:00
parent 61cbef6999
commit a525522de7
5 changed files with 41 additions and 7 deletions
+2
View File
@@ -12,6 +12,7 @@ use rpc::{AccountCreateParams, AccountLoginParams};
use cryp::{Cryp, CrypRecover, cryp_write};
use game::Game;
use zone::{Zone, zone_delete};
use skill::{Skill};
use failure::Error;
use failure::err_msg;
@@ -154,6 +155,7 @@ fn recover_cryp(cryp_bytes: Vec<u8>, tx: &mut Transaction) -> Result<Cryp, Error
let mut cryp = Cryp::new()
.named(&c.name)
.level(c.lvl)
.learn(Skill::Attack)
.set_account(c.account)
.create();
+28 -1
View File
@@ -18,7 +18,7 @@ use net::Db;
use cryp::{Cryp, cryp_spawn, cryp_learn, cryp_forget};
use game::{Game, game_state, game_pve, game_pvp, game_join, game_joinable_list, game_skill};
use account::{Account, account_create, account_login, account_from_token, account_cryps, account_zone};
use item::{Item, items_list, item_use};
use item::{Item, ItemAction, items_list, item_use, item_create};
use skill::{Skill};
use zone::{Zone, zone_create, zone_join, zone_close};
@@ -78,6 +78,8 @@ impl Rpc {
"account_zone" => Rpc::account_zone(data, &mut tx, account.unwrap(), client),
"item_use" => Rpc::item_use(data, &mut tx, account.unwrap(), client),
"press_r" => Rpc::press_r(data, &mut tx, account.unwrap(), client),
_ => Err(format_err!("unknown method - {:?}", v.method)),
};
@@ -307,6 +309,31 @@ impl Rpc {
})
}
fn press_r(_data: Vec<u8>, tx: &mut Transaction, account: Account, _client: &mut WebSocket<TcpStream>) -> Result<RpcResponse, Error> {
for action in [
ItemAction::RerollPhysDamage,
ItemAction::RerollSpellDamage,
ItemAction::RerollSpeed,
ItemAction::RerollStamina,
ItemAction::RerollArmour,
ItemAction::RerollSpellShield,
ItemAction::RerollEvasion,
ItemAction::SpecPhysDmg5,
ItemAction::SpecSpellDmg5,
].into_iter() {
let item = Item::new(*action, account.id);
item_create(item, tx, account.id)?;
}
let res = RpcResponse {
method: "account_items".to_string(),
params: RpcResult::ItemList(items_list(tx, &account)?)
};
return Ok(res);
}
fn item_use(data: Vec<u8>, tx: &mut Transaction, account: Account, client: &mut WebSocket<TcpStream>) -> Result<RpcResponse, Error> {
let msg = from_slice::<ItemUseMsg>(&data).or(Err(err_msg("invalid params")))?;
+2 -2
View File
@@ -25,8 +25,8 @@ impl Spec {
pub fn apply(&self, modified: u64, base: u64) -> u64 {
match self.spec {
SpecType::PhysDamage5 => modified + ( base * 105 / 100),
SpecType::SpellDamage5 => modified + ( base * 105 / 100),
SpecType::PhysDamage5 => modified + (base * 5 / 100),
SpecType::SpellDamage5 => modified + (base * 5 / 100),
}
}
}