Reveal selected ball centres before native split and verify exact selected IDs
This commit is contained in:
@@ -53,13 +53,18 @@ function SplitReal([int]$Stage,[int]$Selected,[string]$Name) {
|
||||
$before=Save "$Name-before-$attempt"; $board=Board $before $Stage
|
||||
$group=@($board.groups|Sort-Object {$_.ballIds.Count} -Descending)[0]
|
||||
$ids=@(if($Stage-eq13-and$Selected-eq2){$group.ballIds[0];$group.ballIds[-1]}else{$group.ballIds|Select-Object -First $Selected})
|
||||
if(@($ids|Where-Object{!(BallClear $board $_)}).Count){Orbit "$Name-reveal-selected-$attempt" $board;continue}
|
||||
TapBall "$Name-choose-$attempt" $board $ids[0]
|
||||
Step "$Name-mode-$attempt" @('shell','input','tap','312','832')
|
||||
foreach($id in $ids){TapBall "$Name-select-$attempt-$id" $board $id}
|
||||
$point=BallPoint $board $ids[0]
|
||||
Step "$Name-drag-$attempt" @('shell','input','swipe',"$($point[0])","$($point[1])","$($point[0])","$($point[1]-160)",'500')
|
||||
$after=Save "$Name-after-$attempt"; $actual=Board $after $Stage
|
||||
if($null-eq$actual-or$actual.groups.Count-gt$board.groups.Count){return $after}
|
||||
if($null-eq$actual){$actual=$after.latestFreePlay}
|
||||
if($actual.groups.Count-gt$board.groups.Count){
|
||||
Check "$Name-exact-selected-ids-$attempt" (@($actual.groups|Where-Object{(($_.ballIds|Sort-Object)-join',')-eq(($ids|Sort-Object)-join',')}).Count-eq1) 'Native split group is exactly the tapped selection, not an occluded substitute'
|
||||
return $after
|
||||
}
|
||||
# Cancel failed selection before a new view; do not silently turn an invalid selection into a solve.
|
||||
Step "$Name-cancel-$attempt" @('shell','input','tap','312','832')
|
||||
Orbit "$Name-orbit-$attempt" $board
|
||||
|
||||
@@ -35,6 +35,21 @@ function BallPoint($Board,[string]$Id) {
|
||||
return @([int][Math]::Round(($width/2)+$local.X*$scale),[int][Math]::Round(($height/2)-$local.Y*$scale))
|
||||
}
|
||||
function WorldSafe($Point) { return $Point[0]-ge530-and$Point[0]-le1850-and$Point[1]-ge280-and$Point[1]-le750 }
|
||||
function BallClear($Board,[string]$Id) {
|
||||
$point=BallPoint $Board $Id
|
||||
if(!(WorldSafe $point)){return $false}
|
||||
$camera=$Board.camera
|
||||
$rotation=[Numerics.Quaternion]::new($camera.rotation.x,$camera.rotation.y,$camera.rotation.z,$camera.rotation.w)
|
||||
$origin=[Numerics.Vector3]::new($camera.target.x,($camera.target.y+.65),$camera.target.z)+[Numerics.Vector3]::Transform([Numerics.Vector3]::new(0,0,-$camera.distance),$rotation)
|
||||
foreach($ball in $Board.balls){
|
||||
if($ball.id-eq$Id){continue}
|
||||
$other=BallPoint $Board $ball.id
|
||||
$local=[Numerics.Vector3]::Transform([Numerics.Vector3]::new($ball.position.x,$ball.position.y,$ball.position.z)-$origin,[Numerics.Quaternion]::Inverse($rotation))
|
||||
$radius=540*.55/([Math]::Tan(31*[Math]::PI/180)*$local.Z)
|
||||
if([Math]::Pow($point[0]-$other[0],2)+[Math]::Pow($point[1]-$other[1],2)-lt[Math]::Pow($radius+8,2)){return $false}
|
||||
}
|
||||
return $true
|
||||
}
|
||||
function TapBall([string]$Name,$Board,[string]$Id) {
|
||||
$point=BallPoint $Board $Id
|
||||
if(!(WorldSafe $point)){throw "Refused unsafe native ball tap $Id at $($point-join',')"}
|
||||
|
||||
Reference in New Issue
Block a user