feat:add assistant
This commit is contained in:
parent
723636c902
commit
2ccb2193d0
@ -222,6 +222,7 @@ class GoBangVH extends ViewHolder {
|
|||||||
result!: Text
|
result!: Text
|
||||||
targetZone: View[] = []
|
targetZone: View[] = []
|
||||||
gameMode!: Text
|
gameMode!: Text
|
||||||
|
assistant!: Text
|
||||||
build(root: Group): void {
|
build(root: Group): void {
|
||||||
this.root = root
|
this.root = root
|
||||||
}
|
}
|
||||||
@ -285,7 +286,7 @@ class GoBangVH extends ViewHolder {
|
|||||||
textColor: Color.WHITE,
|
textColor: Color.WHITE,
|
||||||
layoutConfig: layoutConfig().most().configHeight(LayoutSpec.JUST),
|
layoutConfig: layoutConfig().most().configHeight(LayoutSpec.JUST),
|
||||||
height: 50,
|
height: 50,
|
||||||
backgroundColor: colors[3],
|
backgroundColor: colors[8],
|
||||||
}),
|
}),
|
||||||
hlayout([
|
hlayout([
|
||||||
this.currentRole = text({
|
this.currentRole = text({
|
||||||
@ -307,6 +308,14 @@ class GoBangVH extends ViewHolder {
|
|||||||
]).apply({
|
]).apply({
|
||||||
layoutConfig: layoutConfig().fit().configWidth(LayoutSpec.MOST),
|
layoutConfig: layoutConfig().fit().configWidth(LayoutSpec.MOST),
|
||||||
} as IHLayout),
|
} as IHLayout),
|
||||||
|
this.assistant = text({
|
||||||
|
text: "提示",
|
||||||
|
textSize: 20,
|
||||||
|
textColor: Color.WHITE,
|
||||||
|
layoutConfig: layoutConfig().just().configWidth(LayoutSpec.MOST),
|
||||||
|
height: 50,
|
||||||
|
backgroundColor: colors[3],
|
||||||
|
}),
|
||||||
])
|
])
|
||||||
.apply({
|
.apply({
|
||||||
layoutConfig: layoutConfig().fit(),
|
layoutConfig: layoutConfig().fit(),
|
||||||
@ -430,6 +439,25 @@ class GoBangVM extends ViewModel<GoBangState, GoBangVH>{
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
vh.assistant.onClick = () => {
|
||||||
|
const it = this.getState()
|
||||||
|
if (it.gameState !== 'idle') {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.computeNextStep(it)
|
||||||
|
if (it.gameState !== 'idle') {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (it.role === 'black' && it.gameMode === GameMode.C2P) {
|
||||||
|
setTimeout(() => {
|
||||||
|
this.computeNextStep(it)
|
||||||
|
}, 0)
|
||||||
|
} else if (it.role === 'white' && it.gameMode === GameMode.P2C) {
|
||||||
|
setTimeout(() => {
|
||||||
|
this.computeNextStep(it)
|
||||||
|
}, 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
computeNextStep(it: GoBangState) {
|
computeNextStep(it: GoBangState) {
|
||||||
const tempMatrix: State[] = new Array(count * count).fill(0).map((_, idx) => {
|
const tempMatrix: State[] = new Array(count * count).fill(0).map((_, idx) => {
|
||||||
|
Reference in New Issue
Block a user