Skip to content

Commit 8aadb67

Browse files
chore: clean up contexts
1 parent 0f93fb3 commit 8aadb67

7 files changed

Lines changed: 20 additions & 25 deletions

src/contexts/BaseTreeControllerContext.ts

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/contexts/PlayControllerContext.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import React from 'react'
22
import { Chess } from 'chess.ts'
3-
import { GameTree } from 'src/types'
3+
import { GameTree, BaseTreeControllerContext } from 'src/types'
44
import { usePlayController } from 'src/hooks/usePlayController'
5-
import { BaseTreeControllerContext } from './BaseTreeControllerContext'
65

76
export interface IPlayControllerContext extends BaseTreeControllerContext {
87
game: ReturnType<typeof usePlayController>['game']

src/contexts/TrainingControllerContext.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { Chess } from 'chess.ts'
22
import { createContext } from 'react'
3-
import { GameTree, GameNode } from 'src/types'
4-
import { BaseTreeControllerContext } from './BaseTreeControllerContext'
3+
import { GameTree, GameNode, BaseTreeControllerContext } from 'src/types'
54

65
export interface ITrainingControllerContext extends BaseTreeControllerContext {
76
currentNode: GameNode

src/contexts/TreeControllerContext.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import React, { SetStateAction } from 'react'
1+
import React from 'react'
22
import { Chess } from 'chess.ts'
33
import { useTreeController } from 'src/hooks/useTreeController'
4-
import { BaseTreeControllerContext } from './BaseTreeControllerContext'
5-
import { GameTree } from 'src/types'
4+
import { GameTree, BaseTreeControllerContext } from 'src/types'
65

76
export interface ITreeControllerContext extends BaseTreeControllerContext {
87
currentNode: ReturnType<typeof useTreeController>['currentNode']

src/contexts/TuringTreeControllerContext.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import { Chess } from 'chess.ts'
22
import { createContext } from 'react'
3-
import { GameTree, Color, GameNode } from 'src/types'
43
import { TuringGame } from 'src/types/turing'
54
import { AllStats } from 'src/hooks/useStats'
6-
import { BaseTreeControllerContext } from './BaseTreeControllerContext'
5+
import { GameTree, Color, BaseTreeControllerContext } from 'src/types'
76

87
export interface ITuringControllerContext extends BaseTreeControllerContext {
98
game?: TuringGame

src/hooks/useBaseTreeController.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useContext } from 'react'
2-
import { BaseTreeControllerContext } from 'src/contexts/BaseTreeControllerContext'
2+
import { BaseTreeControllerContext } from 'src/types'
33
import { TreeControllerContext } from 'src/contexts/TreeControllerContext'
44
import { PlayControllerContext } from 'src/contexts/PlayControllerContext'
55
import { TuringControllerContext } from 'src/contexts/TuringTreeControllerContext'

src/types/analysis/index.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
1-
import { Game } from '../base'
2-
import { AvailableMoves } from '../training'
31
import Maia from 'src/lib/engine/maia'
2+
import { AvailableMoves } from '../training'
3+
import { Game, GameNode, GameTree } from '../base'
4+
5+
export interface BaseTreeControllerContext {
6+
gameTree: GameTree
7+
currentNode: GameNode
8+
goToNode: (node: GameNode) => void
9+
goToNextNode: () => void
10+
goToPreviousNode: () => void
11+
goToRootNode: () => void
12+
plyCount: number
13+
orientation: 'white' | 'black'
14+
setOrientation: (orientation: 'white' | 'black') => void
15+
}
416

517
export interface MaiaEngine {
618
maia?: Maia

0 commit comments

Comments
 (0)