import { createUtilityValue , ScoringDirection } from "@shoki/engine" ; import { PlayerActions , PlayerState , PlayerStateSelectors } from "@creature-chess/gamemode" ; import { Constants } from "@creature-chess/models" ; import { BotPersonality } from "@creature-chess/data" ; import { BrainAction } from "../../brain" ; export const createRerollCardsAction = ( state , personality ) : BrainAction | null => { const cards = PlayerStateSelectors . getPlayerCards ( state ) . filter ( c => c !== null ) ; const health = PlayerStateSelectors . getPlayerHealth ( state ) ; const money = PlayerStateSelectors . getPlayerMoney ( state ) ; const canAfford = money > 13 + Constants . REROLL_COST ; if ( cards . length !== 0 || ! canAfford ) { return null ; } return { name : "reroll cards" , action : PlayerActions . rerollCardsPlayerAction , value : createUtilityValue ( [ { value : health , range : [ 1 , 100 ] , direction : ScoringDirection . Low , weighting : { value : personality . composure , direction : ScoringDirection . Low } } , { value : money , range : [ 1 , 55 ] , direction : ScoringDirection . High , weighting : { value : personality . ambition , direction : ScoringDirection . High } } ] ) } ; } ;