fix weird map bug thing in info

This commit is contained in:
ntr 2019-04-03 23:10:46 +11:00
parent a08a05a575
commit 3329dc59c2
3 changed files with 26 additions and 21 deletions

View File

@ -29,7 +29,7 @@ export const SET_ACTIVE_SKILL = 'SET_ACTIVE_SKILL';
export const setActiveSkill = (crypId, skill) => ({ type: SET_ACTIVE_SKILL, value: crypId ? { crypId, skill } : null });
export const SET_INFO = 'SET_INFO';
export const setInfo = (type, value) => ({ type: SET_INFO, value: type ? { type, value } : null });
export const setInfo = value => ({ type: SET_INFO, value: Array.from(value) });
export const SET_RECLAIMING = 'SET_RECLAIMING';
export const setReclaiming = value => ({ type: SET_RECLAIMING, value });

View File

@ -8,22 +8,27 @@ function Info(args) {
} = args;
if (!info) return (<div className="instance-info">&nbsp;</div>);
if (info.type === 'skill') {
console.log(info);
const [type, value] = info;
if (type === 'skill') {
return (
<div className="instance-info">
<div>
<div> {info.value.skill} </div>
<div> {SKILLS[info.value.skill].description} </div>
<div> {SKILLS[info.value.skill].upgrades} </div>
<div>{value.skill}</div>
<div>{SKILLS[value.skill].description}</div>
<div>{SKILLS[value.skill].upgrades}</div>
</div>
<button onClick={() => sendUnequip(info.value.cryp.id, info.value.skill)}>
<button onClick={() => sendUnequip(value.cryp.id, value.skill)}>
unequip
</button>
</div>
);
}
if (info.type === 'cryp') {
if (type === 'cryp') {
const cryp = value;
const stats = [
{ stat: 'hp', disp: 'Hp', colour: '#1FF01F' },
{ stat: 'red_shield', disp: 'Red Shield', colour: '#a52a2a' },
@ -33,32 +38,32 @@ function Info(args) {
{ stat: 'green_damage', disp: 'Green Damage', colour: '#1FF01F' },
{ stat: 'speed', disp: 'Speed', colour: '#FFD123' },
].map((s, i) => (
<div key={i}>{s.disp}: {info.value[s.stat].max}</div>
<div key={i}>{s.disp}: {cryp[s.stat].max}</div>
));
const skills = info.value.skills.map((s, i) => <button key={i} onClick={() => sendUnequip(info.value.id, s.skill)}> {s.skill} </button>);
const skills = cryp.skills.map((s, i) => <button key={s.skill} onClick={() => sendUnequip(cryp.id, s.skill)}> {s.skill} </button>);
return (
<div className="instance-info">
<h5> {info.value.name} </h5>
<h5> {cryp.name} </h5>
{stats}
{skills}
</div>
);
}
/*if (info.item) {
if (SKILLS[info.item]) {
itemDetails = SKILLS[info.item];
} else if (SPECS[info.item]) {
itemDetails = SPECS[info.item];
} else if (COLOURS[info.item]) {
itemDetails = COLOURS[info.item];
/*if (item) {
if (SKILLS[item]) {
itemDetails = SKILLS[item];
} else if (SPECS[item]) {
itemDetails = SPECS[item];
} else if (COLOURS[item]) {
itemDetails = COLOURS[item];
}
}*/
/* const unequip = (itemDetails && info.cryp)
? <button onClick={() => sendUnequip(info.cryp.id, info.item)}> unequip </button>
/* const unequip = (itemDetails && cryp)
? <button onClick={() => sendUnequip(cryp.id, item)}> unequip </button>
: null;
*/

View File

@ -24,8 +24,8 @@ const addState = connect(
dispatch(actions.setInstance(null));
}
function setInfo(item, cryp) {
dispatch(actions.setInfo(item, cryp));
function setInfo(item, value) {
dispatch(actions.setInfo([item, value]));
}
return { quit, setInfo };