Merge branch 'sky14-battle-0'
This commit is contained in:
commit
929b833a49
@ -33,6 +33,7 @@
|
||||
"dependencies": {
|
||||
"@ernane/svelte-star-rating": "^1.1.2",
|
||||
"@sveltejs/vite-plugin-svelte": "^2.0.2",
|
||||
"@testing-library/svelte": "^3.2.2",
|
||||
"@yanick/updeep-remeda": "^2.1.0",
|
||||
"beercss": "^3.0.4",
|
||||
"dexie": "^3.2.2",
|
||||
|
@ -15,7 +15,11 @@
|
||||
</h5>
|
||||
</nav>
|
||||
</header>
|
||||
<h6>Chapter {chapter}, battle {chapterBattle} -- {status}</h6>
|
||||
<h6>
|
||||
Chapter {chapter},
|
||||
<span class="battleNbr">battle {chapterBattle}?</span>
|
||||
-- {status}
|
||||
</h6>
|
||||
<dl>
|
||||
{#if status === 'ongoing'}
|
||||
<dt>wave</dt>
|
||||
@ -103,13 +107,14 @@
|
||||
|
||||
export let params;
|
||||
|
||||
const { activeCampaign, event } = getContext('api');
|
||||
const api = getContext('api');
|
||||
export let activeCampaign = api?.activeCampaign;
|
||||
export let event = api?.event;
|
||||
|
||||
event.setActiveCampaign(params.campaignId);
|
||||
event?.setActiveCampaign(params.campaignId);
|
||||
|
||||
$: battles = $activeCampaign?.battles;
|
||||
$: battle = battles && battles[params.battleId - 1];
|
||||
$: console.log($activeCampaign);
|
||||
$: scenario = battle?.scenario;
|
||||
$: status = battle?.status;
|
||||
$: wave = battle?.wave;
|
||||
@ -117,13 +122,14 @@
|
||||
$: character = battle?.character;
|
||||
$: city = battle?.city;
|
||||
|
||||
$: console.log(battle);
|
||||
|
||||
let chapter = 1 + parseInt(params.battleId / 2);
|
||||
let chapterBattle = params.battleId % 2;
|
||||
let chapterBattle =
|
||||
params.battleId >= 7
|
||||
? params.battleId - 6
|
||||
: 1 + ((params.battleId - 1) % 2);
|
||||
|
||||
const battleVerdict = (verdict) => () =>
|
||||
event.setBattleVerdict(params.battleId, verdict);
|
||||
event?.setBattleVerdict(params.battleId, verdict);
|
||||
|
||||
// $: event.setBattleDifficulty(params.battleId, difficulty);
|
||||
</script>
|
||||
|
31
src/lib/components/Battle/battle.test.js
Normal file
31
src/lib/components/Battle/battle.test.js
Normal file
@ -0,0 +1,31 @@
|
||||
import { test, expect, afterEach } from 'vitest';
|
||||
import { render, cleanup } from '@testing-library/svelte';
|
||||
import Battle from '../Battle.svelte';
|
||||
import { readable } from 'svelte/store';
|
||||
|
||||
const activeCampaign = readable({
|
||||
battles: Array(12)
|
||||
.fill(null)
|
||||
.map((_, i) => ({
|
||||
id: i + 1,
|
||||
})),
|
||||
});
|
||||
|
||||
afterEach(cleanup);
|
||||
|
||||
test.each([
|
||||
[2, 2],
|
||||
[3, 1],
|
||||
[7, 1],
|
||||
[8, 2],
|
||||
[9, 3],
|
||||
])('chapter battle (%i,%i))', (battleId, expected) => {
|
||||
const { container } = render(Battle, {
|
||||
params: { battleId },
|
||||
activeCampaign,
|
||||
});
|
||||
|
||||
expect(container.querySelector('.battleNbr').innerHTML).toMatch(
|
||||
'battle ' + expected,
|
||||
);
|
||||
});
|
@ -1,20 +1,20 @@
|
||||
import { sveltekit } from '@sveltejs/kit/vite';
|
||||
import { svelte } from '@sveltejs/vite-plugin-svelte';
|
||||
|
||||
console.log(import.meta);
|
||||
/** @type {import('vite').UserConfig} */
|
||||
const config = {
|
||||
plugins: [svelte()],
|
||||
test: {
|
||||
include: ['src/**/*.{test,spec}.{js,ts}'],
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
$lib:
|
||||
import.meta.url.replace('file://', '').replace(/[^/]+$/, '') +
|
||||
'src/lib',
|
||||
},
|
||||
},
|
||||
plugins: [svelte()],
|
||||
test: {
|
||||
include: ['src/**/*.{test,spec}.{js,ts}'],
|
||||
environment: 'jsdom',
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
$lib:
|
||||
import.meta.url.replace('file://', '').replace(/[^/]+$/, '') +
|
||||
'src/lib',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default config;
|
||||
|
Loading…
Reference in New Issue
Block a user