| Summary: | Error in isSwappableExist() in Map.java | ||
|---|---|---|---|
| Product: | CandyCrush 2020 | Reporter: | ziruichen6-c |
| Component: | Source Code | Assignee: | jli262-c |
| Status: | CONFIRMED --- | ||
| Severity: | enhancement | ||
| Priority: | --- | ||
| Version: | 1.0 | ||
| Hardware: | PC | ||
| OS: | Windows | ||
|
Description
ziruichen6-c
2020-11-18 21:58:02 HKT
The error was caused by the lack of judgment condition in isHorizontalSwappableExist() and isVerticalSwappableExist().
The solution would be adding judgment conditions to these two functions.
The previous version could not judge below four conditions:
X X | X | X | X
X | X X | X | X
| | X | X
Added code:
Horizontal:
(j<SIZE-3&&itemArray[i][j].isSame(itemArray[i][j+2])&&((i>0&&itemArray[i][j].isSame(itemArray[i-1][j+1]))||(i<SIZE-1&&itemArray[i][j].isSame(itemArray[i+1][j+1]))))
Vertical:
(i<SIZE-3&&itemArray[i][j].isSame(itemArray[i+2][j])&&((j>0&&itemArray[i][j].isSame(itemArray[i+1][j-1]))||(j<SIZE-1&&itemArray[i][j].isSame(itemArray[i+1][j+1]))))
The function isHorizontalSwappableExist() and isVerticalSwappableExist() have been modified into new function, isEndingSwappableExist() and isMiddleSwappableExist(). The four situation mentioned before would be tested in isMiddleSwappableExist(). |