Merge branch 'info-rework' into tutorial-merged

This commit is contained in:
Mashy 2019-10-28 12:13:19 +10:00
commit 5dacda76dc
5 changed files with 92 additions and 87 deletions

View File

@ -20,36 +20,27 @@ class InfoComponent extends preact.Component {
render(args) {
const {
ws,
itemInfo,
player,
instance,
// Variables that will change
info,
tutorial,
clearTutorial,
// Static
player, // Only used for colour calcs which will be update if info changes
ws,
itemInfo,
instance, // Only used for instance id
// functions
setInfo,
setTutorialNull,
} = args;
function Info() {
if (tutorial) {
const tutorialStageInfo = tutorialStage(tutorial, ws, clearTutorial, instance);
const tutorialStageInfo = tutorialStage(tutorial, ws, setTutorialNull, instance);
if (tutorialStageInfo) return tutorialStageInfo;
}
if (!info) return false;
if (!info) {
return (
<div>
<h2>VBOX phase</h2>
<p>Strengthen and specialise your constructs by equipping items to them.</p>
<p>Double click to purchase items in the <b>VBOX</b> and move them to your <b>INVENTORY</b>.</p>
<p>
Combine a <b>SKILL</b> or <b>SPEC</b> with 2 <b>COLOURS</b> to create an item.<br />
Combine <b>3 of the same item</b> to upgrade it.<br />
Click an item and then click a construct to <b>equip</b> that item to it.<br />
</p>
<p>Click the <b>READY</b> button for the <b>GAME PHASE</b>.</p>
</div>
);
}
const fullInfo = itemInfo.items.find(i => i.item === info) || INFO[info];
if (!fullInfo) return false;
const isSkill = fullInfo.skill;
@ -68,7 +59,7 @@ class InfoComponent extends preact.Component {
const cooldown = fullInfo.cooldown ? `${fullInfo.cooldown} Turn delay` : null;
return (
<div class="info-skill">
<h2>{fullInfo.item} - {fullInfo.cost}b</h2>
<h2>{fullInfo.item} {fullInfo.cost}b</h2>
<h3> SKILL </h3>
{itemSourceDescription}
<div> {cooldown} </div>
@ -165,16 +156,20 @@ class InfoComponent extends preact.Component {
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
let itemSourceInfo = itemSource.length
? `${itemSource[0].components[0]} ${itemSource[0].components[1]} ${itemSource[0].components[2]}`
: false;
const itemRegEx = /(Red|Blue|Green)/;
if (itemSourceInfo) {
while (itemSourceInfo.includes('Plus')) itemSourceInfo = itemSourceInfo.replace('Plus', '+');
}
const itemSourceDescription = reactStringReplace(itemSourceInfo, itemRegEx, match => shapes[match]());
const infoText = info.replace('Plus', '+');
let infoText = info;
while (infoText.includes('Plus')) infoText = infoText.replace('Plus', '+');
return (
<div class="info-spec">
<h2>{infoText} - {fullInfo.cost}b</h2>
<h2>{infoText} {fullInfo.cost}b</h2>
<h3>SPEC</h3>
{itemSourceDescription}
<div>{infoDescription}</div>
@ -206,7 +201,7 @@ class InfoComponent extends preact.Component {
<tbody>
{vboxCombos.map((c, i) =>
<tr key={i} >
<td class="highlight" >{convertItem(c.item)}</td>
<td class="highlight" onClick={() => setInfo(c.item)} >{convertItem(c.item)}</td>
{c.components.map((u, j) => <td key={j} >{convertItem(u)}</td>)}
</tr>
)}

View File

@ -29,10 +29,14 @@ const addState = connect(
},
function receiveDispatch(dispatch) {
function clearTutorial() {
function setTutorialNull() {
dispatch(actions.setTutorial(null));
}
return { clearTutorial };
function setInfo(info) {
dispatch(actions.setInfo(info));
}
return { setTutorialNull, setInfo };
}

View File

@ -56,7 +56,6 @@ class Instance extends Component {
render(args) {
const {
instance,
setInfo,
clearItems,
} = args;
@ -76,7 +75,7 @@ class Instance extends Component {
}
return (
<main id="instance" class='instance' onClick={instanceClick} onMouseOver={() => setInfo(null)}>
<main id="instance" class='instance' onClick={instanceClick}>
<Vbox />
<InfoContainer />
<InstanceConstructsContainer />

View File

@ -57,10 +57,6 @@ const addState = connect(
dispatch(actions.setActiveConstruct(value));
}
function clearInfo() {
return dispatch(actions.setInfo(null));
}
function setItemEquip(v) {
return dispatch(actions.setItemEquip(v));
}
@ -69,7 +65,7 @@ const addState = connect(
return dispatch(actions.setItemUnequip(v));
}
return { quit, clearInfo, setInfo, setActiveConstruct, setItemUnequip, setItemEquip };
return { quit, setInfo, setActiveConstruct, setItemUnequip, setItemEquip };
}
);

View File

@ -160,8 +160,12 @@ class Vbox extends preact.Component {
//
function vboxHover(e, v) {
if (v) {
if (info !== v) setInfo(v);
e.stopPropagation();
if (combiner.length !== 0) {
const base = combiner.find(c => !['Red', 'Blue', 'Green'].includes(vbox.bound[c]));
if (base) return setInfo(vbox.bound[base]);
}
if (info !== v) setInfo(v);
}
return true;
}
@ -245,10 +249,12 @@ class Vbox extends preact.Component {
return (
<div class='vbox-vbox'
onMouseDown={() => setReclaiming(false)}
onClick={e => e.stopPropagation()}
onMouseOver={e => hoverInfo(e, 'vbox')}>
onClick={e => e.stopPropagation()}>
<div class="vbox-hdr">
<h3 onTouchStart={e => e.target.scrollIntoView(true)}>VBOX</h3>
<h3
onTouchStart={e => e.target.scrollIntoView(true)}
onMouseOver={e => hoverInfo(e, 'vbox')}> VBOX
</h3>
<div class="bits" onMouseOver={e => hoverInfo(e, 'bits')} >{vbox.bits}b</div>
</div>
<div class="vbox-colours">
@ -307,8 +313,10 @@ class Vbox extends preact.Component {
if (reclaiming) return sendVboxReclaim(i);
// 4 things selected
if (combiner.length > 2) return combinerChange([i]);
if (combiner.length > 2) {
setInfo(vbox.bound[i]);
return combinerChange([i]);
}
// removing
const combinerIndex = combiner.indexOf(i);
if (combinerIndex > -1) {
@ -318,6 +326,7 @@ class Vbox extends preact.Component {
combiner.push(i);
if (!comboHighlight) {
setInfo(vbox.bound[i]);
return combinerChange([i]);
}
@ -401,10 +410,12 @@ class Vbox extends preact.Component {
<div class={inventoryClass}
onMouseDown={inventoryClick}
onClick={e => e.stopPropagation()}
style={vboxSelecting || (itemUnequip.length) ? { cursor: 'pointer' } : null}
onMouseOver={e => hoverInfo(e, 'inventory')}>
style={vboxSelecting || (itemUnequip.length) ? { cursor: 'pointer' } : null}>
<div class="vbox-hdr">
<h3 onTouchStart={e => e.target.scrollIntoView(true)}>INVENTORY</h3>
<h3
onTouchStart={e => e.target.scrollIntoView(true)}
onMouseOver={e => hoverInfo(e, 'inventory')}> INVENTORY
</h3>
<button
disabled={tutorial && tutorial < 8}
class='vbox-btn reclaim'