Merge branch 'change-color'
This commit is contained in:
commit
48292a0ca5
@ -64,7 +64,7 @@
|
||||
/>
|
||||
<div class="medium-divider" />
|
||||
<Battle
|
||||
{...battles[4] ?? { id: 'notYet' }}
|
||||
{...battles[5] ?? { id: 'notYet' }}
|
||||
{campaignId}
|
||||
chapter={3}
|
||||
chapterBattle={2}
|
||||
|
@ -8,7 +8,7 @@
|
||||
>
|
||||
<div>
|
||||
{#if status === 'ongoing' && wave == 2}
|
||||
<i style="color: yellow">mood_bad</i>
|
||||
<i class="orange-text">mood_bad</i>
|
||||
{:else if status === 'ongoing' && wave == 1}
|
||||
<i style="color: blue">sentiment_neutral</i>
|
||||
{:else if status === 'lost'}
|
||||
|
@ -25,20 +25,26 @@ function campaignStatus(campaign) {
|
||||
}
|
||||
|
||||
function calculateScore(campaign) {
|
||||
return [
|
||||
// -campaign.battles.slice(0, 6).filter(({ wave }) => wave === 2).length,
|
||||
// -campaign.battles.slice(6).filter(({ status }) => status === 'lost')
|
||||
// .length,
|
||||
...campaign.battles.map(({ difficulty }) => parseInt(difficulty)),
|
||||
].reduce((a, b) => a + b, 0);
|
||||
const values = [
|
||||
-campaign.battles.slice(0, 6).filter(({ wave }) => wave === 2).length,
|
||||
-campaign.battles.slice(6).filter(({ status }) => status === 'lost')
|
||||
.length,
|
||||
...campaign.battles
|
||||
.map(({ difficulty }) => parseInt(difficulty))
|
||||
.map((x) => (Number.isNaN(x) ? 0 : x)),
|
||||
];
|
||||
console.log(values);
|
||||
return values.reduce((a, b) => a + b, 0);
|
||||
}
|
||||
|
||||
export function updateBattle(campaign, battleId, status) {
|
||||
const battle = campaign.battles[battleId - 1];
|
||||
if (status === 'lost' && (battle.wave == 1 || battle.id < 7)) {
|
||||
return u.updateIn(campaign, `battles.${battleId - 1}`, {
|
||||
if (status === 'lost' && battle.wave == 1 && battle.id < 7) {
|
||||
campaign = u.updateIn(campaign, `battles.${battleId - 1}`, {
|
||||
wave: 2,
|
||||
});
|
||||
campaign = u.updateIn(campaign, 'score', calculateScore(campaign));
|
||||
return campaign;
|
||||
}
|
||||
campaign = u.updateIn(campaign, `battles.${battleId - 1}`, {
|
||||
status,
|
||||
|
Loading…
Reference in New Issue
Block a user