implemented usePreviousPlayer, preparing to implement gold chip funcitonality

This commit is contained in:
2022-08-09 14:27:59 -05:00
parent fd6d96737a
commit 35931eb8e5
22 changed files with 78 additions and 51 deletions

View File

@@ -0,0 +1,19 @@
import { AppState, PlayerData } from "../util/types";
export const useCurrentPlayer = (state: AppState): PlayerData | null => {
/**
* takes in current app state and the current active player
* @param state = current app state
* @returns: @PlayerData if a matching player is found,
* or @null if one is not found
*/
const currentPlayers = state.players;
if (!currentPlayers) return null;
for (let each of currentPlayers) {
if (each.turnActive) return each;
}
return null;
}