import { CreatureStats , AttackType , attackTypes , DefinitionClass } from "@creature-chess/models" ; export const classBuilds = { [ DefinitionClass . VALIANT ] : { hp : 0.4 , attack : 0.2 , defense : 0.3 , speed : 0.2 } , [ DefinitionClass . ARCANE ] : { hp : 0.2 , attack : 0.4 , defense : 0.2 , speed : 0.3 } , [ DefinitionClass . CUNNING ] : { hp : 0.1 , attack : 0.4 , defense : 0.1 , speed : 0.45 } } ; const getBaseStats = ( ) : Omit < CreatureStats , "attackType" > => ( { hp : 10 , attack : 10 , defense : 10 , speed : 10 } ) ; const getPoints = ( cost , stage ) : number => { const COST_MODIFIER = 1.5 ; if ( stage === 0 ) { return ( cost * COST_MODIFIER ) * 20 ; } if ( stage === 1 ) { return ( cost * COST_MODIFIER ) * 80 ; } if ( stage === 2 ) { return ( cost * COST_MODIFIER ) * 210 ; } return 0 ; } ; const getStat = ( baseStat , buildStat , availablePoints ) => baseStat + Math . ceil ( buildStat * availablePoints ) ; const getStats = ( definitionClass , cost , stage ) : CreatureStats => { const baseStats = getBaseStats ( ) ; const availablePoints = getPoints ( cost , stage ) ; const build = classBuilds [ definitionClass ] ; const attackType = ( definitionClass === DefinitionClass . ARCANE ? attackTypes . shoot : attackTypes . basic ) ; return { hp : getStat ( baseStats . hp , build . hp , availablePoints ) , attack : getStat ( baseStats . attack , build . attack , availablePoints ) , defense : getStat ( baseStats . defense , build . defense , availablePoints ) , speed : getStat ( baseStats . speed , build . speed , availablePoints ) , attackType } ; } ; export const getStages = ( definitionClass , cost ) : CreatureStats [ ] => [ getStats ( definitionClass , cost , 0 ) , getStats ( definitionClass , cost , 1 ) , getStats ( definitionClass , cost , 2 ) ] ;