press r
This commit is contained in:
parent
61cbef6999
commit
a525522de7
@ -12,7 +12,7 @@ const Y = ITEM_LIST.y();
|
||||
const WIDTH = ITEM_LIST.width();
|
||||
const HEIGHT = ITEM_LIST.height();
|
||||
const ITEM_WIDTH = WIDTH * 0.4;
|
||||
const ITEM_HEIGHT = HEIGHT * 0.08;
|
||||
const ITEM_HEIGHT = HEIGHT * 0.06;
|
||||
|
||||
const itemCheckHitbox = (scenePlugin, pointer) => {
|
||||
const { list } = scenePlugin.get('MenuCrypList').children;
|
||||
@ -47,7 +47,7 @@ class Item extends Phaser.GameObjects.Container {
|
||||
.rectangle(0, 0, ITEM_WIDTH, ITEM_HEIGHT, 0x222222);
|
||||
|
||||
this.text = scene.add
|
||||
.text(0, 0, `${action} x${count}`, TEXT.HEADER)
|
||||
.text(0, 0, `${action} x${count}`, TEXT.NORMAL)
|
||||
.setOrigin(0.5, 0.5);
|
||||
|
||||
this.add(this.box);
|
||||
@ -91,6 +91,8 @@ class ItemList extends Phaser.Scene {
|
||||
|
||||
updateData(parent, key) {
|
||||
if (key === 'itemList') {
|
||||
this.registry.events.off('changedata', this.updateData, this);
|
||||
this.registry.events.off('setdata', this.updateData, this);
|
||||
this.scene.restart();
|
||||
}
|
||||
}
|
||||
@ -110,8 +112,6 @@ class ItemList extends Phaser.Scene {
|
||||
|
||||
const actions = countBy(itemList, i => i.action);
|
||||
|
||||
console.log(actions);
|
||||
|
||||
Object.keys(actions).forEach((action, i) => {
|
||||
const ITEM_X = ITEM_WIDTH;
|
||||
const ITEM_Y = ITEM_HEIGHT * 1.2 * i + HEIGHT / 2.5;
|
||||
|
||||
@ -84,6 +84,11 @@ function createSocket(events) {
|
||||
send({ method: 'game_joinable_list', params: { } });
|
||||
}
|
||||
|
||||
function sendPressR() {
|
||||
send({ method: 'press_r', params: { } });
|
||||
}
|
||||
|
||||
window.pressR = sendPressR;
|
||||
|
||||
function sendGameSkill(gameId, crypId, targetCrypId, skill) {
|
||||
send({
|
||||
|
||||
@ -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();
|
||||
|
||||
|
||||
@ -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")))?;
|
||||
|
||||
|
||||
@ -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),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user