generated from maximegris/angular-electron
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
310 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './lorescrolls'; | ||
export * from './traitscrolls'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
import { | ||
IItemDefinition, | ||
IModKit, | ||
ItemClass, | ||
Skill, | ||
} from '../../../interfaces'; | ||
import { id } from '../id'; | ||
|
||
const LORE_DROP_RATE = 10000; | ||
const LORE_PREFIX = `Lore Scroll - Gem -`; | ||
|
||
export function generateLoreScrolls(mod: IModKit): IItemDefinition[] { | ||
const allGems = mod.items.filter( | ||
(x) => | ||
x.itemClass === 'Gem' && | ||
!['Solokar', 'Orikurnis'].some((region) => x.name.includes(region)) | ||
); | ||
|
||
const allGemScrollDescs = allGems.map((x) => { | ||
const allKeys = Object.keys(x.encrustGive?.stats ?? {}).map((z) => | ||
z.toUpperCase() | ||
); | ||
|
||
const allGemEffects = []; | ||
|
||
if (allKeys.length > 0) { | ||
allGemEffects.push(`boost your ${allKeys.join(', ')}`); | ||
} | ||
|
||
if (x.useEffect) { | ||
allGemEffects.push( | ||
`grant the spell ${x.useEffect.name.toUpperCase()} when used` | ||
); | ||
} | ||
|
||
if (x.encrustGive?.strikeEffect) { | ||
allGemEffects.push( | ||
`grant the on-hit spell ${x.encrustGive.strikeEffect.name.toUpperCase()} when encrusted` | ||
); | ||
} | ||
|
||
if (allGemEffects.length === 0) { | ||
allGemEffects.push(`sell for a lot of gold`); | ||
} | ||
|
||
const effectText = allGemEffects.join(' and '); | ||
|
||
const bonusText = x.encrustGive?.slots | ||
? `- be careful though, it can only be used in ${x.encrustGive?.slots.join( | ||
', ' | ||
)} equipment` | ||
: ''; | ||
|
||
return { | ||
_itemName: x.name, | ||
scrollDesc: `If you find ${x.desc}, it will ${effectText} ${bonusText}`, | ||
}; | ||
}); | ||
|
||
const allGemLoreItems: IItemDefinition[] = allGemScrollDescs.map( | ||
({ _itemName, scrollDesc }) => { | ||
const itemName = `${LORE_PREFIX} ${_itemName}`; | ||
|
||
return { | ||
_id: `${id()}-AUTOGENERATED`, | ||
name: itemName, | ||
sprite: 224, | ||
value: 1, | ||
desc: `Twean's Gem Codex: ${scrollDesc}`.trim(), | ||
itemClass: ItemClass.Scroll, | ||
isSackable: true, | ||
type: Skill.Martial, | ||
} as unknown as IItemDefinition; | ||
} | ||
); | ||
|
||
return allGemLoreItems; | ||
} | ||
|
||
export function cleanOldLoreScrolls(mod: IModKit): void { | ||
mod.items = mod.items.filter((item) => !item.name.includes(LORE_PREFIX)); | ||
|
||
mod.drops.forEach((droptable) => { | ||
droptable.drops = droptable.drops.filter((item) => | ||
item.result.includes(LORE_PREFIX) | ||
); | ||
}); | ||
} | ||
|
||
export function countExistingLoreScrolls(mod: IModKit): number { | ||
return mod.items.filter((i) => i.name.includes(LORE_PREFIX)).length; | ||
} | ||
|
||
export function applyLoreScrolls(mod: IModKit, lore: IItemDefinition[]): void { | ||
mod.items.push(...lore); | ||
|
||
lore.forEach((loreItem) => { | ||
const loreItemName = loreItem.name.split(LORE_PREFIX).join('').trim(); | ||
|
||
mod.drops.forEach((droptable) => { | ||
if (!droptable.drops.some((i) => i.result === loreItemName)) return; | ||
|
||
droptable.drops.push({ | ||
result: loreItem.name, | ||
chance: 1, | ||
maxChance: LORE_DROP_RATE, | ||
}); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import { startCase } from 'lodash'; | ||
import { | ||
IItemDefinition, | ||
IModKit, | ||
ItemClass, | ||
Skill, | ||
} from '../../../interfaces'; | ||
import { id } from '../id'; | ||
|
||
const romans: Record<number, string> = { | ||
1: 'I', | ||
2: 'II', | ||
3: 'III', | ||
4: 'IV', | ||
5: 'V', | ||
}; | ||
|
||
const TRAIT_PREFIX = `Rune Scroll - `; | ||
|
||
export function generateTraitScrolls( | ||
mod: IModKit, | ||
allTraitTrees: any = {} | ||
): IItemDefinition[] { | ||
const scrollToClass: Record<string, string[]> = {}; | ||
const allRuneScrolls = new Set<string>(); | ||
|
||
const returnedRuneScrolls: IItemDefinition[] = []; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument | ||
Object.keys(allTraitTrees).forEach((classTree) => { | ||
if (classTree === 'Ancient') return; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument | ||
Object.keys(allTraitTrees[classTree].trees).forEach((treeName) => { | ||
if (treeName === 'Ancient') return; | ||
|
||
const tree = allTraitTrees[classTree].trees[treeName].tree; | ||
|
||
tree.forEach(({ traits }: any) => { | ||
traits.forEach(({ name, maxLevel }: any) => { | ||
if (!name || maxLevel <= 1) return; | ||
|
||
scrollToClass[name] ??= []; | ||
|
||
allRuneScrolls.add(name as string); | ||
|
||
if (classTree !== 'Core' && treeName !== 'Core') { | ||
scrollToClass[name].push(classTree); | ||
} | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
Array.from(allRuneScrolls).forEach((scrollName) => { | ||
for (let i = 1; i <= 5; i++) { | ||
const scrollSpaced = startCase(scrollName); | ||
const itemName = `${TRAIT_PREFIX} ${scrollSpaced} ${romans[i]}`; | ||
|
||
returnedRuneScrolls.push({ | ||
_id: `${id()}-AUTOGENERATED`, | ||
name: itemName, | ||
sprite: 681, | ||
animation: 10, | ||
desc: `a runic scroll imbued with the empowerment "${scrollSpaced} ${romans[i]}"`, | ||
trait: { | ||
name: scrollName, | ||
level: i, | ||
restrict: scrollToClass[scrollName], | ||
}, | ||
requirements: { | ||
level: 5 + (i - 1) * 10, | ||
}, | ||
value: 1, | ||
itemClass: ItemClass.Scroll, | ||
type: Skill.Martial, | ||
stats: {}, | ||
isSackable: true, | ||
} as IItemDefinition); | ||
} | ||
}); | ||
|
||
return returnedRuneScrolls; | ||
} | ||
|
||
export function countExistingTraitScrolls(mod: IModKit): number { | ||
return mod.items.filter((i) => i.name.includes(TRAIT_PREFIX)).length; | ||
} | ||
|
||
export function applyTraitScrolls( | ||
mod: IModKit, | ||
scrolls: IItemDefinition[] | ||
): void { | ||
mod.items.push(...scrolls); | ||
} | ||
|
||
export function cleanOldTraitScrolls(mod: IModKit): void { | ||
mod.items = mod.items.filter((item) => !item.name.includes(TRAIT_PREFIX)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { IModKit, ValidationMessageGroup } from '../../../interfaces'; | ||
import { countExistingLoreScrolls, generateLoreScrolls } from '../autocontent'; | ||
|
||
export function checkAutogenerated(mod: IModKit): ValidationMessageGroup { | ||
// check npc dialog refs, make sure they exist | ||
const autoValidations: ValidationMessageGroup = { | ||
header: `Autogenerated Content`, | ||
messages: [], | ||
}; | ||
|
||
const existingLore = countExistingLoreScrolls(mod); | ||
const allAvailableLore = generateLoreScrolls(mod); | ||
|
||
if (allAvailableLore.length !== existingLore) { | ||
autoValidations.messages.push({ | ||
type: 'error', | ||
message: `Outdated number of lore scrolls found: the mod has ${existingLore} but there are ${allAvailableLore.length} available.`, | ||
}); | ||
} | ||
|
||
return autoValidations; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './autogenerated'; | ||
export * from './dialog'; | ||
export * from './droptable'; | ||
export * from './item'; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
src/app/shared/components/cell-buttons/cell-buttons.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.