Bug 417

Summary: Error in isSquareSwappableExist() in Map.java
Product: CandyCrush 2020 Reporter: ziruichen6-c
Component: Source CodeAssignee: jli262-c
Status: CONFIRMED ---    
Severity: enhancement    
Priority: ---    
Version: 1.0   
Hardware: PC   
OS: Windows   

Description ziruichen6-c 2020-11-18 22:14:13 HKT
The bug was found when running the JUnit test. testSquareExist8() and testSquareExist9() return false.

Steps to Reproduce:
Run testSquareExist8() and testSquareExist9() in TestMap.java

Actual Results:testSquareExist8() and testSquareExist9() in TestMap.java failures which means the isSquareSwappableExist() could not judge below situations:
X    |                         
  X  | X   X                             
X X  |   X X


Expected Results: testSquareExist8() and testSquareExist9() in TestMap.java pass the JUnit test
Comment 1 ziruichen6-c 2020-11-18 22:20:13 HKT
The error was caused by the error of judgment condition in isSquareSwappableExist().
The solution would be to correct the judgment condition in isSquareSwappableExist() in Map.java

Previous version:
(itemArray[i+1][j+1].isSame(itemArray[i+1][j]) && itemArray[i+1][j+1].isSame(itemArray[i][j+1]) && ((i > 0 && itemArray[i][j].isSame(itemArray[i-1][j])) || (j > 0 && itemArray[i][j].isSame(itemArray[i][j-1])))

After correcting:
itemArray[i+1][j+1].isSame(itemArray[i+1][j]) && itemArray[i+1][j+1].isSame(itemArray[i][j+1]) && ((i > 0 && itemArray[i+1][j+1].isSame(itemArray[i-1][j])) || (j > 0 && itemArray[i+1][j+1].isSame(itemArray[i][j-1])))
Comment 2 ziruichen6-c 2020-11-29 11:51:37 HKT
In version2, After further research, it is found that the four conditions detected in isSquareSwappableExist() will be covered by isHorizontalSwappableExist() and isVerticalSwappableExist(), so this function is deleted.