Merge branch 'develop' of ssh://git.mnml.gg:40022/~/mnml into develop
This commit is contained in:
commit
9bcea878ec
@ -41,6 +41,7 @@ export const setReclaiming = value => ({ type: 'SET_RECLAIMING', value });
|
|||||||
export const setShowLog = value => ({ type: 'SET_SHOW_LOG', value });
|
export const setShowLog = value => ({ type: 'SET_SHOW_LOG', value });
|
||||||
export const setShop = value => ({ type: 'SET_SHOP', value });
|
export const setShop = value => ({ type: 'SET_SHOP', value });
|
||||||
export const setSubscription = value => ({ type: 'SET_SUBSCRIPTION', value });
|
export const setSubscription = value => ({ type: 'SET_SUBSCRIPTION', value });
|
||||||
|
export const setPvp = value => ({ type: 'SET_PVP', value });
|
||||||
|
|
||||||
export const setTeam = value => ({ type: 'SET_TEAM', value: Array.from(value) });
|
export const setTeam = value => ({ type: 'SET_TEAM', value: Array.from(value) });
|
||||||
export const setTeamPage = value => ({ type: 'SET_TEAM_PAGE', value });
|
export const setTeamPage = value => ({ type: 'SET_TEAM_PAGE', value });
|
||||||
|
|||||||
@ -14,6 +14,7 @@ const addState = connect(
|
|||||||
account,
|
account,
|
||||||
instances,
|
instances,
|
||||||
invite,
|
invite,
|
||||||
|
pvp,
|
||||||
} = state;
|
} = state;
|
||||||
|
|
||||||
function sendInstanceState(id) {
|
function sendInstanceState(id) {
|
||||||
@ -32,15 +33,21 @@ const addState = connect(
|
|||||||
ws.sendInstanceInvite();
|
ws.sendInstanceInvite();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function sendInstanceLeave() {
|
||||||
|
ws.sendInstanceLeave();
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
account,
|
account,
|
||||||
instances,
|
instances,
|
||||||
invite,
|
invite,
|
||||||
|
pvp,
|
||||||
|
|
||||||
sendInstanceState,
|
sendInstanceState,
|
||||||
sendInstanceQueue,
|
sendInstanceQueue,
|
||||||
sendInstancePractice,
|
sendInstancePractice,
|
||||||
sendInstanceInvite,
|
sendInstanceInvite,
|
||||||
|
sendInstanceLeave,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -67,11 +74,13 @@ function Play(args) {
|
|||||||
account,
|
account,
|
||||||
instances,
|
instances,
|
||||||
invite,
|
invite,
|
||||||
|
pvp,
|
||||||
|
|
||||||
sendInstanceState,
|
sendInstanceState,
|
||||||
sendInstanceQueue,
|
sendInstanceQueue,
|
||||||
sendInstancePractice,
|
sendInstancePractice,
|
||||||
sendInstanceInvite,
|
sendInstanceInvite,
|
||||||
|
sendInstanceLeave,
|
||||||
|
|
||||||
setNav,
|
setNav,
|
||||||
} = args;
|
} = args;
|
||||||
@ -125,6 +134,31 @@ function Play(args) {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const pvpBtn = () => {
|
||||||
|
if (pvp) return (
|
||||||
|
<figure>
|
||||||
|
<button
|
||||||
|
class="ready"
|
||||||
|
onClick={() => sendInstanceLeave()}
|
||||||
|
>
|
||||||
|
Cancel
|
||||||
|
</button>
|
||||||
|
<figcaption>Finding Opponent</figcaption>
|
||||||
|
</figure>
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<figure>
|
||||||
|
<button
|
||||||
|
class="ready"
|
||||||
|
onClick={() => sendInstanceQueue()}>
|
||||||
|
PVP
|
||||||
|
</button>
|
||||||
|
<figcaption>Matchmaking</figcaption>
|
||||||
|
</figure>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const subscription = account.subscribed
|
const subscription = account.subscribed
|
||||||
? <button
|
? <button
|
||||||
class="yellow-btn"
|
class="yellow-btn"
|
||||||
@ -142,14 +176,7 @@ function Play(args) {
|
|||||||
if (!instances.length) {
|
if (!instances.length) {
|
||||||
return (
|
return (
|
||||||
<div class='list play'>
|
<div class='list play'>
|
||||||
<figure>
|
{pvpBtn()}
|
||||||
<button
|
|
||||||
class="ready"
|
|
||||||
onClick={() => sendInstanceQueue()}>
|
|
||||||
PVP
|
|
||||||
</button>
|
|
||||||
<figcaption>Matchmaking</figcaption>
|
|
||||||
</figure>
|
|
||||||
{inviteBtn()}
|
{inviteBtn()}
|
||||||
<figure>
|
<figure>
|
||||||
<button
|
<button
|
||||||
|
|||||||
@ -30,6 +30,10 @@ function registerEvents(store) {
|
|||||||
store.dispatch(actions.setPing(ping));
|
store.dispatch(actions.setPing(ping));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setPvp(v) {
|
||||||
|
store.dispatch(actions.setPvp(v));
|
||||||
|
}
|
||||||
|
|
||||||
function setNav(v) {
|
function setNav(v) {
|
||||||
store.dispatch(actions.setNav(v));
|
store.dispatch(actions.setNav(v));
|
||||||
}
|
}
|
||||||
@ -210,6 +214,7 @@ function registerEvents(store) {
|
|||||||
const { account, instance, ws, tutorial } = store.getState();
|
const { account, instance, ws, tutorial } = store.getState();
|
||||||
if (v) {
|
if (v) {
|
||||||
setInvite(null);
|
setInvite(null);
|
||||||
|
setPvp(false);
|
||||||
const player = v.players.find(p => p.id === account.id);
|
const player = v.players.find(p => p.id === account.id);
|
||||||
store.dispatch(actions.setPlayer(player));
|
store.dispatch(actions.setPlayer(player));
|
||||||
|
|
||||||
@ -371,6 +376,7 @@ function registerEvents(store) {
|
|||||||
setItemInfo,
|
setItemInfo,
|
||||||
setInvite,
|
setInvite,
|
||||||
setPing,
|
setPing,
|
||||||
|
setPvp,
|
||||||
setShop,
|
setShop,
|
||||||
setTeam,
|
setTeam,
|
||||||
setSubscription,
|
setSubscription,
|
||||||
|
|||||||
@ -48,6 +48,7 @@ module.exports = {
|
|||||||
player: createReducer(null, 'SET_PLAYER'),
|
player: createReducer(null, 'SET_PLAYER'),
|
||||||
reclaiming: createReducer(false, 'SET_RECLAIMING'),
|
reclaiming: createReducer(false, 'SET_RECLAIMING'),
|
||||||
shop: createReducer(false, 'SET_SHOP'),
|
shop: createReducer(false, 'SET_SHOP'),
|
||||||
|
pvp: createReducer(null, 'SET_PVP'),
|
||||||
|
|
||||||
subscription: createReducer(null, 'SET_SUBSCRIPTION'),
|
subscription: createReducer(null, 'SET_SUBSCRIPTION'),
|
||||||
|
|
||||||
|
|||||||
@ -151,6 +151,10 @@ function createSocket(events) {
|
|||||||
send(['InstanceQueue', {}]);
|
send(['InstanceQueue', {}]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function sendInstanceLeave() {
|
||||||
|
send(['InstanceLeave', {}]);
|
||||||
|
}
|
||||||
|
|
||||||
function sendInstanceInvite() {
|
function sendInstanceInvite() {
|
||||||
send(['InstanceInvite', {}]);
|
send(['InstanceInvite', {}]);
|
||||||
}
|
}
|
||||||
@ -274,8 +278,16 @@ function createSocket(events) {
|
|||||||
Pong: onPong,
|
Pong: onPong,
|
||||||
Demo: onDemo,
|
Demo: onDemo,
|
||||||
|
|
||||||
QueueRequested: () => events.notify('PVP queue request received.'),
|
// QueueRequested: () => events.notify('PVP queue request received.'),
|
||||||
QueueJoined: () => events.notify('You have joined the PVP queue.'),
|
QueueRequested: () => true,
|
||||||
|
QueueJoined: () => {
|
||||||
|
events.notify('You have joined the PVP queue.');
|
||||||
|
events.setPvp(true);
|
||||||
|
},
|
||||||
|
QueueLeft: () => {
|
||||||
|
events.notify('You have left the PVP queue.');
|
||||||
|
events.setPvp(false);
|
||||||
|
},
|
||||||
QueueFound: () => events.notify('Your PVP game has started.'),
|
QueueFound: () => events.notify('Your PVP game has started.'),
|
||||||
InviteRequested: () => events.notify('PVP invite request received.'),
|
InviteRequested: () => events.notify('PVP invite request received.'),
|
||||||
Invite: code => events.setInvite(code),
|
Invite: code => events.setInvite(code),
|
||||||
@ -343,7 +355,7 @@ function createSocket(events) {
|
|||||||
message: 'disconnected',
|
message: 'disconnected',
|
||||||
position: 'topRight',
|
position: 'topRight',
|
||||||
});
|
});
|
||||||
return setTimeout(connect, 2000);
|
return setTimeout(connect, 5000);
|
||||||
}
|
}
|
||||||
|
|
||||||
function connect() {
|
function connect() {
|
||||||
@ -390,6 +402,7 @@ function createSocket(events) {
|
|||||||
sendInstanceInvite,
|
sendInstanceInvite,
|
||||||
sendInstanceJoin,
|
sendInstanceJoin,
|
||||||
sendInstanceChat,
|
sendInstanceChat,
|
||||||
|
sendInstanceLeave,
|
||||||
|
|
||||||
sendVboxAccept,
|
sendVboxAccept,
|
||||||
sendVboxAcceptEquip,
|
sendVboxAcceptEquip,
|
||||||
|
|||||||
@ -60,6 +60,7 @@ pub enum Event {
|
|||||||
Invite(Id),
|
Invite(Id),
|
||||||
Join(Id, String),
|
Join(Id, String),
|
||||||
Joined(Id),
|
Joined(Id),
|
||||||
|
Leave(Id),
|
||||||
|
|
||||||
Chat(Id, Uuid, String),
|
Chat(Id, Uuid, String),
|
||||||
ChatClear(Id, Uuid),
|
ChatClear(Id, Uuid),
|
||||||
@ -249,6 +250,7 @@ impl Events {
|
|||||||
// or flag the requester as pvp ready
|
// or flag the requester as pvp ready
|
||||||
let requester = self.clients.get_mut(&id).unwrap();
|
let requester = self.clients.get_mut(&id).unwrap();
|
||||||
requester.pvp = true;
|
requester.pvp = true;
|
||||||
|
requester.tx.send(RpcMessage::QueueJoined(()))?;
|
||||||
info!("joined game queue id={:?} account={:?}", requester.id, requester.account);
|
info!("joined game queue id={:?} account={:?}", requester.id, requester.account);
|
||||||
return Ok(());
|
return Ok(());
|
||||||
},
|
},
|
||||||
@ -305,6 +307,18 @@ impl Events {
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Event::Leave(id) => {
|
||||||
|
// check whether request is valid
|
||||||
|
let c = self.clients.get_mut(&id)
|
||||||
|
.ok_or(format_err!("connection not found id={:?}", id))?;
|
||||||
|
|
||||||
|
c.pvp = false;
|
||||||
|
c.tx.send(RpcMessage::QueueLeft(()))?;
|
||||||
|
info!("left game queue id={:?} account={:?}", c.id, c.account);
|
||||||
|
return Ok(());
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
Event::Chat(id, instance, msg) => {
|
Event::Chat(id, instance, msg) => {
|
||||||
// set the chat state of this connection
|
// set the chat state of this connection
|
||||||
{
|
{
|
||||||
|
|||||||
@ -63,7 +63,7 @@ pub enum RpcMessage {
|
|||||||
|
|
||||||
QueueRequested(()),
|
QueueRequested(()),
|
||||||
QueueJoined(()),
|
QueueJoined(()),
|
||||||
QueueCancelled(()),
|
QueueLeft(()),
|
||||||
QueueFound(()),
|
QueueFound(()),
|
||||||
|
|
||||||
InviteRequested(()),
|
InviteRequested(()),
|
||||||
@ -105,6 +105,7 @@ pub enum RpcRequest {
|
|||||||
InstanceInvite {},
|
InstanceInvite {},
|
||||||
InstanceJoin { code: String },
|
InstanceJoin { code: String },
|
||||||
InstanceQueue {},
|
InstanceQueue {},
|
||||||
|
InstanceLeave {},
|
||||||
InstancePractice {},
|
InstancePractice {},
|
||||||
InstanceAbandon { instance_id: Uuid },
|
InstanceAbandon { instance_id: Uuid },
|
||||||
InstanceReady { instance_id: Uuid },
|
InstanceReady { instance_id: Uuid },
|
||||||
@ -168,6 +169,10 @@ impl Connection {
|
|||||||
self.events.send(Event::Join(self.id, code))?;
|
self.events.send(Event::Join(self.id, code))?;
|
||||||
Ok(RpcMessage::Joining(()))
|
Ok(RpcMessage::Joining(()))
|
||||||
},
|
},
|
||||||
|
RpcRequest::InstanceLeave {} => {
|
||||||
|
self.events.send(Event::Leave(self.id))?;
|
||||||
|
Ok(RpcMessage::Processing(()))
|
||||||
|
},
|
||||||
|
|
||||||
RpcRequest::InstanceChat { instance_id, index } => {
|
RpcRequest::InstanceChat { instance_id, index } => {
|
||||||
if !account.subscribed {
|
if !account.subscribed {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user