threads per ws maybe?
This commit is contained in:
parent
a42ef53c6d
commit
67f62c659a
@ -4,8 +4,8 @@ function CrypPanel({ battle }) {
|
|||||||
if (!battle) return <div>...</div>;
|
if (!battle) return <div>...</div>;
|
||||||
return (
|
return (
|
||||||
<div className="">
|
<div className="">
|
||||||
{JSON.stringify(battle.a)}
|
<div>{JSON.stringify(battle.a)}</div>
|
||||||
{JSON.stringify(battle.b)}
|
<div>{JSON.stringify(battle.b)}</div>
|
||||||
<ul>
|
<ul>
|
||||||
{battle.log.map((l, i) => (<li key={i} >{l}</li>))}
|
{battle.log.map((l, i) => (<li key={i} >{l}</li>))}
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
const preact = require('preact');
|
const preact = require('preact');
|
||||||
|
|
||||||
function CrypPanel({ cryps, sendCombatPve }) {
|
function CrypList({ cryps, sendCombatPve }) {
|
||||||
if (!cryps) return <div>not ready</div>;
|
if (!cryps) return <div>not ready</div>;
|
||||||
const crypPanels = cryps.map(cryp => (
|
const crypPanels = cryps.map(cryp => (
|
||||||
|
|
||||||
@ -39,4 +39,4 @@ function CrypPanel({ cryps, sendCombatPve }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = CrypPanel;
|
module.exports = CrypList;
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
* auto login
|
* auto login
|
||||||
* ws reconnect ✔️
|
* ws reconnect ✔️
|
||||||
* Levelling
|
* Levelling
|
||||||
|
* KO cooldowns
|
||||||
* Global rolls
|
* Global rolls
|
||||||
* Logins ✔️
|
* Logins ✔️
|
||||||
* Cryp Ownership ✔
|
* Cryp Ownership ✔
|
||||||
|
|||||||
@ -40,8 +40,8 @@ impl Battle {
|
|||||||
let mut a_turn = self.a.turn();
|
let mut a_turn = self.a.turn();
|
||||||
let mut b_turn = self.b.turn();
|
let mut b_turn = self.b.turn();
|
||||||
|
|
||||||
self.a.assign_dmg(&self.b, &a_turn, &b_turn);
|
self.a.assign_dmg(&self.b, &mut a_turn, &b_turn);
|
||||||
self.b.assign_dmg(&self.a, &b_turn, &a_turn);
|
self.b.assign_dmg(&self.a, &mut b_turn, &a_turn);
|
||||||
|
|
||||||
self.log.append(&mut a_turn.log);
|
self.log.append(&mut a_turn.log);
|
||||||
self.log.append(&mut b_turn.log);
|
self.log.append(&mut b_turn.log);
|
||||||
|
|||||||
@ -116,7 +116,8 @@ pub fn pve(params: CombatPveParams, db: &Db, account: &Account) -> Result<Battle
|
|||||||
|
|
||||||
// TEMP
|
// TEMP
|
||||||
if plr.hp.value == 0 {
|
if plr.hp.value == 0 {
|
||||||
plr.rez();
|
return Err(err_msg("cryp is ko"));
|
||||||
|
// plr.rez();
|
||||||
}
|
}
|
||||||
|
|
||||||
let mob = generate_mob(&plr);
|
let mob = generate_mob(&plr);
|
||||||
|
|||||||
@ -168,18 +168,18 @@ impl Cryp {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn assign_dmg(&mut self, opp: &Cryp, plr_t: &Turn, opp_t: &Turn) -> &mut Cryp {
|
pub fn assign_dmg(&mut self, opp: &Cryp, plr_t: &mut Turn, opp_t: &Turn) -> &mut Cryp {
|
||||||
let final_dmg = opp_t.dmg.result.saturating_sub(plr_t.def.result);
|
let final_dmg = opp_t.dmg.result.saturating_sub(plr_t.def.result);
|
||||||
let blocked = opp_t.dmg.result.saturating_sub(final_dmg);
|
let blocked = opp_t.dmg.result.saturating_sub(final_dmg);
|
||||||
|
|
||||||
self.hp.reduce(final_dmg);
|
self.hp.reduce(final_dmg);
|
||||||
|
|
||||||
println!("{:?} deals {:?} dmg to {:?} ({:?} blocked / {:?} hp remaining)"
|
plr_t.log.push(format!("{:?} deals {:?} dmg to {:?} ({:?} blocked / {:?} hp remaining)"
|
||||||
,opp.name
|
,opp.name
|
||||||
,final_dmg
|
,final_dmg
|
||||||
,self.name
|
,self.name
|
||||||
,blocked
|
,blocked
|
||||||
,self.hp.value);
|
,self.hp.value));
|
||||||
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@ use ws::{listen, Handler, Sender, Result, Message, Handshake, CloseCode, Error};
|
|||||||
use serde_cbor::{to_vec};
|
use serde_cbor::{to_vec};
|
||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
|
use std::thread::spawn;
|
||||||
|
|
||||||
use r2d2::{Pool};
|
use r2d2::{Pool};
|
||||||
use r2d2::{PooledConnection};
|
use r2d2::{PooledConnection};
|
||||||
@ -78,5 +79,12 @@ pub fn start() {
|
|||||||
|
|
||||||
let pool = db_connection(database_url);
|
let pool = db_connection(database_url);
|
||||||
|
|
||||||
listen("127.0.0.1:40000", |out| { Server { out, rpc: Rpc {}, db: pool.clone() } }).unwrap();
|
listen("127.0.0.1:40000", |out| {
|
||||||
|
let db = pool.clone();
|
||||||
|
let handler = spawn(move || {
|
||||||
|
Server { out, rpc: Rpc {}, db }
|
||||||
|
});
|
||||||
|
let result = handler.join().unwrap();
|
||||||
|
return result;
|
||||||
|
}).unwrap();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user