import { select , put , call } from "redux-saga/effects" ; import { getVariable } from "@shoki/engine" ; import { PlayerActions , PlayerState , PlayerVariables } from "@creature-chess/gamemode" ; import { BotPersonality } from "@creature-chess/data" ; import delay from "delay" ; import { BOT_ACTION_TIME_MS } from "../constants" ; import { getActions } from "../actions" ; import { putBenchOnBoard } from "../putBenchOnBoard" ; export const preparingPhase = function * ( personality ) { const name = yield * getVariable < PlayerVariables , string > ( v => v . name ) ; yield delay ( BOT_ACTION_TIME_MS ) ; while ( true ) { const state = yield select ( ) ; const actions = getActions ( state , personality ) ; if ( actions . length === 0 ) { break ; } const [ mostValuable ] = actions ; yield put ( mostValuable . action ( ) ) ; yield delay ( BOT_ACTION_TIME_MS ) ; yield call ( putBenchOnBoard ) ; } yield put ( PlayerActions . readyUpPlayerAction ( ) ) ; } ;