Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allows users to edit influence boxes when in Estimate/Scoring mode. #941

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,13 @@ class App extends Component {
state.mode === 'estimator'
? influence.map(scoreBoard.signMap, {discrete: true})
: influence.areaMap(scoreBoard.signMap)

for (let vertex in state.estimateOverrides) {
let clickCount = state.estimateOverrides[vertex]
let coord = vertex.split('x')
let val = areaMap[coord[0]][coord[1]] + 1 + clickCount
areaMap[coord[0]][coord[1]] = (val % 3) - 1
}
}

state = {...state, ...inferredState, scoreBoard, areaMap}
Expand Down
17 changes: 16 additions & 1 deletion src/modules/sabaki.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class Sabaki extends EventEmitter {
findVertex: null,
deadStones: [],
blockedGuesses: [],
estimateOverrides: {},

// Goban

Expand Down Expand Up @@ -244,6 +245,8 @@ class Sabaki extends EventEmitter {
setMode(mode) {
if (this.state.mode === mode) return

this.setState({estimateOverrides: {}})

let stateChange = {mode}

if (['scoring', 'estimator'].includes(mode)) {
Expand Down Expand Up @@ -960,7 +963,19 @@ class Sabaki extends EventEmitter {
this.editVertexData = null
}
} else if (['scoring', 'estimator'].includes(this.state.mode)) {
if (button !== 0 || board.get(vertex) === 0) return
if (button !== 0) return

if (board.get(vertex) === 0) {
let {estimateOverrides} = this.state

let clickCount = estimateOverrides[vertex[1] + 'x' + vertex[0]]
clickCount = !clickCount ? 1 : clickCount + 1

estimateOverrides[vertex[1] + 'x' + vertex[0]] = clickCount

this.setState({estimateOverrides})
return
}

let {mode, deadStones} = this.state
let dead = deadStones.some(v => helper.vertexEquals(v, vertex))
Expand Down