Merge branch 'develop' of ssh://git.mnml.gg:40022/~/mnml into develop

This commit is contained in:
ntr 2019-09-12 16:19:28 +10:00
commit d873c80e92
10 changed files with 121 additions and 42 deletions

View File

@ -20,8 +20,6 @@
* msg pane
* game invites
* add speed to descriptions
## SOON
*SERVER*
* modules

View File

@ -1,3 +1,5 @@
@import 'colours.less';
aside {
grid-area: ctrl;
display: grid;
@ -93,3 +95,16 @@ aside {
.team-page-ctrl h2 {
padding: 0 0.75em 0 0.75em;
}
.abandon {
&:hover {
color: @red;
border-color: @red;
};
&:active, &.confirming {
background: @red;
color: black;
border: 1px solid black;
}
}

View File

@ -91,7 +91,7 @@ class Slay extends Component {
});
anime.set('#slay', {
translateY: (window.screen.height) * 0.35 * this.props.direction.y,
translateY: -1 * (window.screen.height) * 0.35,
translateX: 0,
});
anime.set('#explosion feDisplacementMap', {

View File

@ -56,7 +56,7 @@ function Collection(args) {
teamSelect[insert] = id;
return setTeam(teamSelect);
}
console.log(constructs.length);
const dispConstructs = constructs.length >= ((teamPage + 1) * 6)
? constructs.slice(teamPage * 6, (teamPage + 1) * 6)
: constructs.slice(teamPage * 6, constructs.length);

View File

@ -3,7 +3,7 @@ const range = require('lodash/range');
const reactStringReplace = require('react-string-replace');
const { INFO } = require('./../constants');
const { convertItem } = require('../utils');
const { convertItem, removeTier, itemSpeed } = require('../utils');
const shapes = require('./shapes');
function InfoComponent(args) {
@ -40,12 +40,23 @@ function InfoComponent(args) {
if (isSkill) {
const regEx = /(RedPower|BluePower|GreenPower|RedLife|BlueLife|GreenLife|SpeedStat)/;
const infoDescription = reactStringReplace(fullInfo.description, regEx, match => shapes[match]());
const itemSource = itemInfo.combos.filter(c => c.item === removeTier(info));
const itemSourceInfo = itemSource.length
? `${itemSource[0].components[0]} ${itemSource[0].components[1]} ${itemSource[0].components[2]}`
: false;
const itemRegEx = /(Red|Blue|Green)/;
const itemSourceDescription = reactStringReplace(itemSourceInfo, itemRegEx, match => shapes[match]());
const calcSpeed = itemSource.length
? (24 + (itemSpeed(itemSource[0].components[0]) + itemSpeed(itemSource[0].components[1])) * itemSpeed(itemSource[0].components[2])) * 4
: (24 + itemSpeed(info)) * 4;
const speed = <div> Speed {shapes.SpeedStat()} multiplier {calcSpeed}% </div>;
return (
<div class="info-skill">
<h2>{fullInfo.item}</h2>
<h3>SKILL</h3>
{itemSourceDescription}
<div>{infoDescription}</div>
{speed}
</div>
);
}
@ -135,11 +146,18 @@ function InfoComponent(args) {
});
const regEx = /(RedPower|BluePower|GreenPower|RedLife|BlueLife|GreenLife|SpeedStat)/;
const infoDescription = reactStringReplace(fullInfo.description, regEx, match => shapes[match]());
const itemSource = itemInfo.combos.filter(c => c.item === info);
const itemSourceInfo = itemSource.length
? `${itemSource[0].components[0]} ${itemSource[0].components[1]} ${itemSource[0].components[2]}`
: false;
const itemRegEx = /(Red|Blue|Green)/;
const itemSourceDescription = reactStringReplace(itemSourceInfo, itemRegEx, match => shapes[match]());
return (
<div class="info-spec">
<h2>{info}</h2>
<h3>SPEC</h3>
{itemSourceDescription}
<div>{infoDescription}</div>
<div class="thresholds">
{thresholds}

View File

@ -1,4 +1,5 @@
const preact = require('preact');
const { Component } = require('preact')
const { connect } = require('preact-redux');
const addState = connect(
@ -8,7 +9,16 @@ const addState = connect(
}
);
function Scoreboard(args) {
class Scoreboard extends Component {
constructor(props) {
super(props);
this.state = {
abandonState: false,
};
}
render(args, state) {
const {
abandon,
animating,
@ -18,6 +28,8 @@ function Scoreboard(args) {
clear,
} = args;
const { abandonState } = state;
const scoreText = () => {
if (player.score === 'Zero') return '▫▫▫▫';
if (player.score === 'One') return '■▫▫▫';
@ -28,6 +40,15 @@ function Scoreboard(args) {
return '';
};
const divClick = e => {
e.stopPropagation();
return this.setState({ abandonState: false });
};
const abandonStateTrue = e => {
e.stopPropagation();
this.setState({ abandonState: true });
};
if (!isPlayer) {
return (
<div class={`player-box top ${player.ready ? 'ready' : ''}`}>
@ -39,17 +60,23 @@ function Scoreboard(args) {
</div>
);
}
const abandonClasses = `abandon ${abandonState ? 'confirming' : ''}`;
const abandonAction = abandonState ? abandon : abandonStateTrue;
return (
<div class={`player-box bottom ${player.ready ? 'ready' : ''}`}>
<div onClick={divClick} class={`player-box bottom ${player.ready ? 'ready' : ''}`}>
<div class="score">{scoreText()}</div>
<div class="img">
<div>{player.name}</div>
</div>
<div>
{(isPlayer && isGame) ? <button disabled={animating} onClick={clear}>Clear</button> : null}
{(abandon) ? <button disabled={animating} onClick={abandon}>Abandon</button> : null}
</div>
<div>
{(abandon) ? <button class={abandonClasses} disabled={animating} onClick={abandonAction}>Abandon</button> : null}
</div>
</div>
);
}
}
module.exports = addState(Scoreboard);

View File

@ -169,7 +169,7 @@ function registerEvents(store) {
}
function setInstance(v) {
const { account, instance } = store.getState();
const { account, instance, ws } = store.getState();
if (v) {
const player = v.players.find(p => p.id === account.id);
store.dispatch(actions.setPlayer(player));
@ -180,7 +180,11 @@ function registerEvents(store) {
store.dispatch(actions.setActiveConstruct(first));
}
}
if (v.phase === 'Finished') setGame(null);
if (v.phase === 'Finished') {
setGame(null);
ws.sendAccountInstances();
}
return store.dispatch(actions.setInstance(v));
}

View File

@ -187,6 +187,20 @@ const removeTier = skill => {
return skill;
};
function itemSpeed(item) {
switch (item) {
case 'Attack': return 1;
case 'Stun': return 2;
case 'Block': return 3;
case 'Buff': return 4;
case 'Debuff': return 4;
case 'Red': return 3;
case 'Green': return 2;
case 'Blue': return 1;
default: return 0;
}
}
function postData(url = '/', data = {}) {
// Default options are marked with *
return fetch(`/api${url}`, {
@ -250,5 +264,6 @@ module.exports = {
TARGET_COLOURS,
randomPoints,
removeTier,
itemSpeed,
match,
};

View File

@ -83,6 +83,7 @@ pub enum RpcRequest {
AccountState {},
AccountShop {},
AccountInstances {},
AccountConstructs {},
AccountSetTeam { ids: Vec<Uuid> },
@ -154,7 +155,8 @@ impl Connection {
Ok(RpcMessage::AccountState(account.clone())),
RpcRequest::AccountConstructs {} =>
Ok(RpcMessage::AccountConstructs(account::constructs(&mut tx, &account)?)),
RpcRequest::AccountInstances {} =>
Ok(RpcMessage::AccountInstances(account::account_instances(&mut tx, account)?)),
RpcRequest::AccountSetTeam { ids } =>
Ok(RpcMessage::AccountTeam(account::set_team(&mut tx, &account, ids)?)),