Merge branch 'master' of ssh://cryps.gg:40022/~/cryps
This commit is contained in:
commit
caf827e42b
18
client/assets/c1.svg
Normal file
18
client/assets/c1.svg
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
|
||||||
|
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
|
||||||
|
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="13.8889in" height="13.8889in"
|
||||||
|
viewBox="0 0 1000 1000">
|
||||||
|
<path id="Unnamed"
|
||||||
|
fill="none" stroke="black" stroke-width="1"
|
||||||
|
d="M 250.00,-1.00
|
||||||
|
C 250.00,-1.00 0.00,300.00 0.00,300.00
|
||||||
|
0.00,300.00 1000.00,300.00 1000.00,300.00
|
||||||
|
1000.00,300.00 750.00,2.00 750.00,2.00M 500.00,300.00
|
||||||
|
C 500.00,300.00 500.00,700.00 500.00,700.00M 250.00,1000.00
|
||||||
|
C 250.00,1000.00 0.00,700.00 0.00,700.00
|
||||||
|
0.00,700.00 999.00,700.00 1000.00,700.00
|
||||||
|
1001.00,700.00 750.00,1000.00 750.00,1000.00" />
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 811 B |
20
client/assets/c2.svg
Normal file
20
client/assets/c2.svg
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
|
||||||
|
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
|
||||||
|
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="13.8889in" height="13.8889in"
|
||||||
|
viewBox="0 0 1000 1000">
|
||||||
|
<path id="c2"
|
||||||
|
fill="none" stroke="black" stroke-width="1"
|
||||||
|
d="M 250.00,-1.00
|
||||||
|
C 250.00,-1.00 250.00,300.00 250.00,300.00
|
||||||
|
250.00,300.00 750.00,299.00 750.00,299.00
|
||||||
|
750.00,299.00 750.00,2.00 750.00,2.00M 500.00,100.00
|
||||||
|
C 500.00,100.00 500.00,300.00 500.00,300.00
|
||||||
|
500.00,300.00 500.00,700.00 500.00,700.00M 250.00,1000.00
|
||||||
|
C 250.00,1000.00 500.00,700.00 500.00,700.00
|
||||||
|
500.00,700.00 750.00,1000.00 750.00,1000.00M 750.00,700.00
|
||||||
|
C 750.00,700.00 500.00,400.00 500.00,400.00
|
||||||
|
500.00,400.00 249.00,699.00 249.00,699.00" />
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 938 B |
20
client/assets/c3.svg
Normal file
20
client/assets/c3.svg
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
|
||||||
|
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
|
||||||
|
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="13.8889in" height="13.8889in"
|
||||||
|
viewBox="0 0 1000 1000">
|
||||||
|
<path id="c3"
|
||||||
|
fill="none" stroke="black" stroke-width="1"
|
||||||
|
d="M 250.00,-1.00
|
||||||
|
C 250.00,-1.00 250.00,300.00 250.00,300.00
|
||||||
|
250.00,300.00 750.00,299.00 750.00,299.00
|
||||||
|
750.00,299.00 750.00,2.00 750.00,2.00M 500.00,300.00
|
||||||
|
C 500.00,300.00 500.00,700.00 500.00,700.00M 250.00,1000.00
|
||||||
|
C 250.00,1000.00 250.00,700.00 250.00,700.00
|
||||||
|
250.00,700.00 500.00,700.00 500.00,700.00
|
||||||
|
500.00,700.00 750.00,700.00 750.00,700.00
|
||||||
|
750.00,700.00 750.00,1000.00 750.00,1000.00M 250.00,500.00
|
||||||
|
C 250.00,500.00 750.00,500.00 750.00,500.00" />
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 938 B |
@ -67,7 +67,6 @@ class MenuNavigation extends Phaser.Scene {
|
|||||||
pveText.destroy();
|
pveText.destroy();
|
||||||
pvp.destroy();
|
pvp.destroy();
|
||||||
pvpText.destroy();
|
pvpText.destroy();
|
||||||
ws.sendGameJoinableList();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const cancel = this.add
|
const cancel = this.add
|
||||||
|
|||||||
@ -77,10 +77,6 @@ function createSocket(events) {
|
|||||||
send({ method: 'game_join', params: { game_id: gameId, cryp_ids: crypIds } });
|
send({ method: 'game_join', params: { game_id: gameId, cryp_ids: crypIds } });
|
||||||
}
|
}
|
||||||
|
|
||||||
function sendGameJoinableList() {
|
|
||||||
send({ method: 'game_joinable_list', params: { } });
|
|
||||||
}
|
|
||||||
|
|
||||||
function sendSpecForget(id, spec) {
|
function sendSpecForget(id, spec) {
|
||||||
send({ method: 'cryp_unspec', params: { id, spec } });
|
send({ method: 'cryp_unspec', params: { id, spec } });
|
||||||
}
|
}
|
||||||
@ -105,18 +101,10 @@ function createSocket(events) {
|
|||||||
send({ method: 'player_vbox_combine', params: { instance_id: instanceId, indices } });
|
send({ method: 'player_vbox_combine', params: { instance_id: instanceId, indices } });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function sendVboxDrop(instanceId, index) {
|
function sendVboxDrop(instanceId, index) {
|
||||||
send({ method: 'player_vbox_drop', params: { instance_id: instanceId, index } });
|
send({ method: 'player_vbox_drop', params: { instance_id: instanceId, index } });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function sendPressR() {
|
|
||||||
send({ method: 'press_r', params: { } });
|
|
||||||
}
|
|
||||||
|
|
||||||
window.pressR = sendPressR;
|
|
||||||
|
|
||||||
function sendGameSkill(gameId, crypId, targetCrypId, skill) {
|
function sendGameSkill(gameId, crypId, targetCrypId, skill) {
|
||||||
send({
|
send({
|
||||||
method: 'game_skill',
|
method: 'game_skill',
|
||||||
@ -154,7 +142,6 @@ function createSocket(events) {
|
|||||||
account = login;
|
account = login;
|
||||||
events.setAccount(login);
|
events.setAccount(login);
|
||||||
sendAccountCryps();
|
sendAccountCryps();
|
||||||
// sendGameJoinableList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function accountCryps(response) {
|
function accountCryps(response) {
|
||||||
@ -167,11 +154,6 @@ function createSocket(events) {
|
|||||||
events.setGame(game);
|
events.setGame(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
function gameJoinableList(response) {
|
|
||||||
const [structName, gameList] = response;
|
|
||||||
events.setGameList(gameList);
|
|
||||||
}
|
|
||||||
|
|
||||||
function crypSpawn(response) {
|
function crypSpawn(response) {
|
||||||
const [structName, cryp] = response;
|
const [structName, cryp] = response;
|
||||||
}
|
}
|
||||||
@ -202,7 +184,6 @@ function createSocket(events) {
|
|||||||
cryp_learn: () => true,
|
cryp_learn: () => true,
|
||||||
game_pve: gamePve,
|
game_pve: gamePve,
|
||||||
game_state: gameState,
|
game_state: gameState,
|
||||||
game_joinable_list: gameJoinableList,
|
|
||||||
account_login: accountLogin,
|
account_login: accountLogin,
|
||||||
account_create: accountLogin,
|
account_create: accountLogin,
|
||||||
account_cryps: accountCryps,
|
account_cryps: accountCryps,
|
||||||
@ -290,7 +271,6 @@ function createSocket(events) {
|
|||||||
sendGamePve,
|
sendGamePve,
|
||||||
sendGamePvp,
|
sendGamePvp,
|
||||||
sendGameJoin,
|
sendGameJoin,
|
||||||
sendGameJoinableList,
|
|
||||||
sendGameSkill,
|
sendGameSkill,
|
||||||
sendGameTarget,
|
sendGameTarget,
|
||||||
sendCrypSpawn,
|
sendCrypSpawn,
|
||||||
|
|||||||
@ -185,10 +185,6 @@ impl Game {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn joinable(&self) -> bool {
|
|
||||||
self.phase == Phase::Start
|
|
||||||
}
|
|
||||||
|
|
||||||
fn can_start(&self) -> bool {
|
fn can_start(&self) -> bool {
|
||||||
return self.teams.len() == self.team_num
|
return self.teams.len() == self.team_num
|
||||||
&& self.teams.iter().all(|t| t.cryps.len() == self.team_size)
|
&& self.teams.iter().all(|t| t.cryps.len() == self.team_size)
|
||||||
@ -607,13 +603,13 @@ pub fn game_write(game: &Game, tx: &mut Transaction) -> Result<(), Error> {
|
|||||||
let game_bytes = to_vec(&game)?;
|
let game_bytes = to_vec(&game)?;
|
||||||
|
|
||||||
let query = "
|
let query = "
|
||||||
INSERT INTO games (id, joinable, data)
|
INSERT INTO games (id, data)
|
||||||
VALUES ($1, $2, $3)
|
VALUES ($1, $2)
|
||||||
RETURNING id;
|
RETURNING id;
|
||||||
";
|
";
|
||||||
|
|
||||||
let result = tx
|
let result = tx
|
||||||
.query(query, &[&game.id, &game.joinable(), &game_bytes])?;
|
.query(query, &[&game.id, &game_bytes])?;
|
||||||
|
|
||||||
result.iter().next().ok_or(format_err!("no game written"))?;
|
result.iter().next().ok_or(format_err!("no game written"))?;
|
||||||
|
|
||||||
@ -653,13 +649,13 @@ pub fn game_update(game: &Game, tx: &mut Transaction) -> Result<(), Error> {
|
|||||||
|
|
||||||
let query = "
|
let query = "
|
||||||
UPDATE games
|
UPDATE games
|
||||||
SET data = $1, joinable = $2
|
SET data = $1
|
||||||
WHERE id = $3
|
WHERE id = $2
|
||||||
RETURNING id, data;
|
RETURNING id, data;
|
||||||
";
|
";
|
||||||
|
|
||||||
let result = tx
|
let result = tx
|
||||||
.query(query, &[&game_bytes, &game.joinable(), &game.id])?;
|
.query(query, &[&game_bytes, &game.id])?;
|
||||||
|
|
||||||
result.iter().next().ok_or(format_err!("game {:?} could not be written", game))?;
|
result.iter().next().ok_or(format_err!("game {:?} could not be written", game))?;
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -106,7 +106,7 @@ pub fn instance_get_open(tx: &mut Transaction) -> Result<Instance, Error> {
|
|||||||
let query = "
|
let query = "
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM instance
|
FROM instance
|
||||||
AND open = true;
|
WHERE open = true;
|
||||||
";
|
";
|
||||||
|
|
||||||
let result = tx
|
let result = tx
|
||||||
|
|||||||
@ -8,10 +8,9 @@ use failure::Error;
|
|||||||
use failure::err_msg;
|
use failure::err_msg;
|
||||||
|
|
||||||
use account::Account;
|
use account::Account;
|
||||||
use instance::Instance;
|
use cryp::{Cryp, cryp_get};
|
||||||
use cryp::{Cryp};
|
|
||||||
use vbox::{Vbox};
|
use vbox::{Vbox};
|
||||||
use rpc::{PlayerStateParams};
|
use rpc::{PlayerStateParams, PlayerCrypsSetParams};
|
||||||
|
|
||||||
#[derive(Debug,Clone,Serialize,Deserialize)]
|
#[derive(Debug,Clone,Serialize,Deserialize)]
|
||||||
pub struct Score {
|
pub struct Score {
|
||||||
@ -106,3 +105,24 @@ pub fn player_update(tx: &mut Transaction, player: Player) -> Result<Player, Err
|
|||||||
pub fn player_state(params: PlayerStateParams, tx: &mut Transaction, account: &Account) -> Result<Player, Error> {
|
pub fn player_state(params: PlayerStateParams, tx: &mut Transaction, account: &Account) -> Result<Player, Error> {
|
||||||
player_get(tx, account.id, params.instance_id)
|
player_get(tx, account.id, params.instance_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn player_cryps_set(params: PlayerCrypsSetParams, tx: &mut Transaction, account: &Account) -> Result<Player, Error> {
|
||||||
|
if params.instance_id != Uuid::nil() {
|
||||||
|
return Err(err_msg("only the global team can be replaced"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if params.cryp_ids.len() != 3 {
|
||||||
|
return Err(err_msg("team size is 3"));
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut player = player_get(tx, account.id, params.instance_id)?;
|
||||||
|
|
||||||
|
let cryps = params.cryp_ids
|
||||||
|
.iter()
|
||||||
|
.map(|id| cryp_get(tx, *id, account.id))
|
||||||
|
.collect::<Result<Vec<Cryp>, Error>>()?;
|
||||||
|
|
||||||
|
player.cryps = cryps;
|
||||||
|
|
||||||
|
player_update(tx, player)
|
||||||
|
}
|
||||||
|
|||||||
@ -21,7 +21,7 @@ use account::{Account, account_create, account_login, account_from_token, accoun
|
|||||||
use skill::{Skill};
|
use skill::{Skill};
|
||||||
use zone::{Zone, zone_create, zone_join, zone_close};
|
use zone::{Zone, zone_create, zone_join, zone_close};
|
||||||
use spec::{Spec};
|
use spec::{Spec};
|
||||||
use player::{player_state, player_create, Player};
|
use player::{player_state, player_create, player_cryps_set, Player};
|
||||||
use instance::{instance_join};
|
use instance::{instance_join};
|
||||||
use vbox::{vbox_accept, vbox_apply, vbox_discard, vbox_combine, vbox_drop};
|
use vbox::{vbox_accept, vbox_apply, vbox_discard, vbox_combine, vbox_drop};
|
||||||
|
|
||||||
@ -91,7 +91,10 @@ impl Rpc {
|
|||||||
|
|
||||||
return response;
|
return response;
|
||||||
},
|
},
|
||||||
Err(_e) => Err(err_msg("invalid message")),
|
Err(e) => {
|
||||||
|
println!("{:?}", e);
|
||||||
|
Err(err_msg("invalid message"))
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,7 +117,7 @@ impl Rpc {
|
|||||||
return Ok(game_response);
|
return Ok(game_response);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn game_pve(data: Vec<u8>, tx: &mut Transaction, account: Account, client: &mut WebSocket<TcpStream>) -> Result<RpcResponse, Error> {
|
fn game_pve(data: Vec<u8>, tx: &mut Transaction, account: Account, _client: &mut WebSocket<TcpStream>) -> Result<RpcResponse, Error> {
|
||||||
let msg = from_slice::<GamePveMsg>(&data).or(Err(err_msg("invalid params")))?;
|
let msg = from_slice::<GamePveMsg>(&data).or(Err(err_msg("invalid params")))?;
|
||||||
|
|
||||||
let game_response = RpcResponse {
|
let game_response = RpcResponse {
|
||||||
@ -122,11 +125,6 @@ impl Rpc {
|
|||||||
params: RpcResult::GameState(game_pve(msg.params, tx, &account)?)
|
params: RpcResult::GameState(game_pve(msg.params, tx, &account)?)
|
||||||
};
|
};
|
||||||
|
|
||||||
Rpc::send_msg(client, RpcResponse {
|
|
||||||
method: "account_cryps".to_string(),
|
|
||||||
params: RpcResult::CrypList(account_cryps(tx, &account)?)
|
|
||||||
})?;
|
|
||||||
|
|
||||||
return Ok(game_response);
|
return Ok(game_response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,7 +270,6 @@ impl Rpc {
|
|||||||
return Ok(response);
|
return Ok(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn player_state(data: Vec<u8>, tx: &mut Transaction, account: Account, _client: &mut WebSocket<TcpStream>) -> Result<RpcResponse, Error> {
|
fn player_state(data: Vec<u8>, tx: &mut Transaction, account: Account, _client: &mut WebSocket<TcpStream>) -> Result<RpcResponse, Error> {
|
||||||
let msg = from_slice::<PlayerStateMsg>(&data).or(Err(err_msg("invalid params")))?;
|
let msg = from_slice::<PlayerStateMsg>(&data).or(Err(err_msg("invalid params")))?;
|
||||||
|
|
||||||
@ -284,6 +281,17 @@ impl Rpc {
|
|||||||
return Ok(response);
|
return Ok(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn player_cryps_set(data: Vec<u8>, tx: &mut Transaction, account: Account, _client: &mut WebSocket<TcpStream>) -> Result<RpcResponse, Error> {
|
||||||
|
let msg = from_slice::<PlayerStateMsg>(&data).or(Err(err_msg("invalid params")))?;
|
||||||
|
|
||||||
|
let response = RpcResponse {
|
||||||
|
method: "player_state".to_string(),
|
||||||
|
params: RpcResult::PlayerState(player_cryps_set(msg.params, tx, &account)?)
|
||||||
|
};
|
||||||
|
|
||||||
|
return Ok(response);
|
||||||
|
}
|
||||||
|
|
||||||
fn player_vbox_accept(data: Vec<u8>, tx: &mut Transaction, account: Account, _client: &mut WebSocket<TcpStream>) -> Result<RpcResponse, Error> {
|
fn player_vbox_accept(data: Vec<u8>, tx: &mut Transaction, account: Account, _client: &mut WebSocket<TcpStream>) -> Result<RpcResponse, Error> {
|
||||||
let msg = from_slice::<VboxAcceptMsg>(&data).or(Err(err_msg("invalid params")))?;
|
let msg = from_slice::<VboxAcceptMsg>(&data).or(Err(err_msg("invalid params")))?;
|
||||||
|
|
||||||
@ -362,7 +370,6 @@ pub enum RpcResult {
|
|||||||
Account(Account),
|
Account(Account),
|
||||||
CrypList(Vec<Cryp>),
|
CrypList(Vec<Cryp>),
|
||||||
GameState(Game),
|
GameState(Game),
|
||||||
GameJoinableList(Vec<Game>),
|
|
||||||
ZoneState(Zone),
|
ZoneState(Zone),
|
||||||
ZoneClose(()),
|
ZoneClose(()),
|
||||||
|
|
||||||
@ -540,6 +547,18 @@ pub struct PlayerStateParams {
|
|||||||
pub instance_id: Uuid,
|
pub instance_id: Uuid,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug,Clone,Serialize,Deserialize)]
|
||||||
|
struct PlayerCrypsSetMsg {
|
||||||
|
method: String,
|
||||||
|
params: PlayerCrypsSetParams,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug,Clone,Serialize,Deserialize)]
|
||||||
|
pub struct PlayerCrypsSetParams {
|
||||||
|
pub instance_id: Uuid,
|
||||||
|
pub cryp_ids: Vec<Uuid>,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug,Clone,Serialize,Deserialize)]
|
#[derive(Debug,Clone,Serialize,Deserialize)]
|
||||||
struct VboxAcceptMsg {
|
struct VboxAcceptMsg {
|
||||||
method: String,
|
method: String,
|
||||||
|
|||||||
@ -50,7 +50,7 @@ pub enum Var {
|
|||||||
Strangle,
|
Strangle,
|
||||||
Strike,
|
Strike,
|
||||||
Siphon,
|
Siphon,
|
||||||
Survival,
|
Clutch,
|
||||||
Taunt,
|
Taunt,
|
||||||
Throw,
|
Throw,
|
||||||
Toxic,
|
Toxic,
|
||||||
@ -91,7 +91,7 @@ impl Var {
|
|||||||
Var::Snare => Ok(Skill::Snare),
|
Var::Snare => Ok(Skill::Snare),
|
||||||
Var::Strangle => Ok(Skill::Strangle),
|
Var::Strangle => Ok(Skill::Strangle),
|
||||||
// Var::Strike => Ok(Skill::Strike),
|
// Var::Strike => Ok(Skill::Strike),
|
||||||
// Var::Survival => Ok(Skill::Survival),
|
// Var::Clutch => Ok(Skill::Clutch),
|
||||||
// Var::Taunt => Ok(Skill::Taunt),
|
// Var::Taunt => Ok(Skill::Taunt),
|
||||||
Var::Throw => Ok(Skill::Throw),
|
Var::Throw => Ok(Skill::Throw),
|
||||||
// Var::Toxic => Ok(Skill::Toxic),
|
// Var::Toxic => Ok(Skill::Toxic),
|
||||||
@ -247,7 +247,7 @@ impl Vbox {
|
|||||||
ColourCode::RR => Var::Empower,
|
ColourCode::RR => Var::Empower,
|
||||||
ColourCode::GG => Var::Triage,
|
ColourCode::GG => Var::Triage,
|
||||||
ColourCode::BB => Var::Amplify,
|
ColourCode::BB => Var::Amplify,
|
||||||
ColourCode::RG => Var::Survival,
|
ColourCode::RG => Var::Clutch,
|
||||||
ColourCode::GB => return Err(err_msg("unhandled skill combo")),
|
ColourCode::GB => return Err(err_msg("unhandled skill combo")),
|
||||||
ColourCode::BR => Var::Haste,
|
ColourCode::BR => Var::Haste,
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user