change combat format

This commit is contained in:
ntr
2018-10-17 16:57:57 +11:00
parent 7d70a864fd
commit 6b2eda8391
5 changed files with 67 additions and 33 deletions
+8 -3
View File
@@ -6,9 +6,14 @@ function CrypPanel({ battle }) {
<div className="">
<div>{JSON.stringify(battle.a)}</div>
<div>{JSON.stringify(battle.b)}</div>
<ul>
{battle.log.map((l, i) => (<li key={i} >{l}</li>))}
</ul>
<div>
{
battle.log.map((l, i) => {
if (l === '') return (<br/>);
return <p key={i} >{l}</p>
})
}
</div>
</div>
);
}
+16
View File
@@ -15,6 +15,22 @@ const stringSort = (k, desc) => {
};
};
const numSort = (k, desc) => {
if (desc) {
return (a, b) => {
if (!get(a, k)) return 1;
if (!get(b, k)) return -1;
return get(b, k) - get(a, k);
};
}
return (a, b) => {
if (!get(a, k)) return 1;
if (!get(b, k)) return -1;
return get(a, k) - get(b, k);
};
};
module.exports = {
stringSort,
numSort,
}