mirror of
https://gitlab.com/lecarore/breakout71.git
synced 2025-04-29 16:29:13 -04:00
wip
This commit is contained in:
parent
bcf40fe667
commit
096f7d4abd
13 changed files with 1917 additions and 225 deletions
38
src/data/unlockConditions.test.ts
Normal file
38
src/data/unlockConditions.test.ts
Normal file
|
@ -0,0 +1,38 @@
|
|||
import conditions from "./unlockConditions.json"
|
||||
import levels from "./levels.json"
|
||||
import {rawUpgrades} from "../upgrades";
|
||||
import {getLevelUnlockCondition} from "../get_level_unlock_condition";
|
||||
import {UnlockCondition} from "../types";
|
||||
|
||||
describe("conditions", () => {
|
||||
it("defines conditions for existing levels only", () => {
|
||||
const conditionForMissingLevel=Object.keys(conditions).filter(levelName=>!levels.find(l=>l.name===levelName))
|
||||
expect(conditionForMissingLevel).toEqual([]);
|
||||
});
|
||||
it("defines conditions with existing upgrades only", () => {
|
||||
|
||||
const existingIds :Set<string>= new Set(rawUpgrades.map(u=>u.id));
|
||||
const missing:Set<string>=new Set();
|
||||
Object.values(conditions).forEach(({required,forbidden})=>{
|
||||
[...required,...forbidden].forEach(id=> {
|
||||
if(!existingIds.has(id))
|
||||
missing.add(id)
|
||||
})
|
||||
})
|
||||
|
||||
expect([...missing]).toEqual([]);
|
||||
});
|
||||
|
||||
it("defines conditions for all levels", () => {
|
||||
const toAdd : Record<string,UnlockCondition>= {}
|
||||
levels.filter(l=>!l.name.startsWith('icon:')).forEach((l,li)=> {
|
||||
if(l.name in conditions) return
|
||||
toAdd[l.name]= getLevelUnlockCondition(li, l.name)
|
||||
})
|
||||
if(Object.keys(toAdd).length){
|
||||
console.debug('Missing hardcoded conditons\n\n'+ JSON.stringify(toAdd).slice(1,-1)+'\n\n')
|
||||
}
|
||||
expect(Object.keys(toAdd)).toEqual([]);
|
||||
});
|
||||
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue