instance lists
This commit is contained in:
@@ -17,6 +17,7 @@ const COLOURS = [
|
||||
|
||||
function Menu(args) {
|
||||
const {
|
||||
account,
|
||||
cryps,
|
||||
selectedCryps,
|
||||
setSelectedCryps,
|
||||
@@ -31,14 +32,12 @@ function Menu(args) {
|
||||
if (!instances) return <div>...</div>;
|
||||
|
||||
const instancePanels = instances.map(instance => {
|
||||
const globalInstance = instance.instance === NULL_UUID;
|
||||
const name = globalInstance
|
||||
? 'Global Matchmaking'
|
||||
: `${instance.instance.substring(0, 5)} | ${instance.score.wins} : ${instance.score.losses}`;
|
||||
const player = instance.players.find(p => p.account === account.id);
|
||||
const name = `${instance.name} | ${player.score.wins} : ${player.score.losses}`;
|
||||
|
||||
return (
|
||||
<button
|
||||
className={`menu-instance-btn right ${globalInstance ? 'full' : ''}`}
|
||||
className={'menu-instance-btn right'}
|
||||
key={instance.id}
|
||||
onClick={() => sendInstanceState(instance)}>
|
||||
{name}
|
||||
|
||||
@@ -5,7 +5,7 @@ const actions = require('./../actions');
|
||||
|
||||
const addState = connect(
|
||||
function receiveState(state) {
|
||||
const { ws, cryps, selectedCryps, instances } = state;
|
||||
const { ws, cryps, selectedCryps, instances, account } = state;
|
||||
|
||||
function sendInstanceJoin() {
|
||||
if (selectedCryps.length) {
|
||||
@@ -26,10 +26,11 @@ const addState = connect(
|
||||
}
|
||||
|
||||
function sendInstanceState(instance) {
|
||||
return ws.sendInstanceState(instance.instance);
|
||||
return ws.sendInstanceState(instance.id);
|
||||
}
|
||||
|
||||
return {
|
||||
account,
|
||||
cryps,
|
||||
selectedCryps,
|
||||
sendInstanceJoin,
|
||||
|
||||
@@ -50,8 +50,8 @@ function createSocket(events) {
|
||||
send({ method: 'account_cryps', params: {} });
|
||||
}
|
||||
|
||||
function sendAccountPlayers() {
|
||||
send({ method: 'account_players', params: {} });
|
||||
function sendAccountInstances() {
|
||||
send({ method: 'account_instances', params: {} });
|
||||
}
|
||||
|
||||
function sendAccountZone() {
|
||||
@@ -171,10 +171,10 @@ function createSocket(events) {
|
||||
localStorage.setItem('account', JSON.stringify(login));
|
||||
events.setAccount(login);
|
||||
sendAccountCryps();
|
||||
sendAccountPlayers();
|
||||
sendAccountInstances();
|
||||
}
|
||||
|
||||
function accountPlayerList(res) {
|
||||
function accountInstanceList(res) {
|
||||
const [struct, playerList] = res;
|
||||
events.setInstanceList(playerList);
|
||||
}
|
||||
@@ -229,7 +229,7 @@ function createSocket(events) {
|
||||
account_login: accountLogin,
|
||||
account_create: accountLogin,
|
||||
account_cryps: accountCryps,
|
||||
account_players: accountPlayerList,
|
||||
account_instances: accountInstanceList,
|
||||
instance_scores: instanceScores,
|
||||
zone_create: res => console.log(res),
|
||||
zone_state: zoneState,
|
||||
@@ -285,7 +285,7 @@ function createSocket(events) {
|
||||
|
||||
if (account) {
|
||||
events.setAccount(account);
|
||||
sendAccountPlayers();
|
||||
sendAccountInstances();
|
||||
sendAccountCryps();
|
||||
}
|
||||
|
||||
@@ -319,7 +319,7 @@ function createSocket(events) {
|
||||
sendAccountCreate,
|
||||
sendAccountDemo,
|
||||
sendAccountCryps,
|
||||
sendAccountPlayers,
|
||||
sendAccountInstances,
|
||||
sendAccountZone,
|
||||
sendGameState,
|
||||
sendGameJoin,
|
||||
|
||||
Reference in New Issue
Block a user