Bug 620

Summary: A start move peg's status would change even if the judge function said it to be invalid.
Product: CS3343 Chinese Checker Reporter: yutongmen2-c
Component: Algorithm ComponentAssignee: yutongmen2-c
Status: CONFIRMED ---    
Severity: normal CC: yutongmen2-c
Priority: ---    
Version: unspecified   
Hardware: All   
OS: All   

Description yutongmen2-c 2021-11-29 11:57:30 HKT
Short description:
A start move peg's status would change even if the judge function said it to be invalid.

Steps To Reproduce:
Choose a peg to be the start move at any turn. Then choose an invalid end move position. Check if the start move peg has its status unchanged.

Actual Output:
The start move peg changed its status to 0 (empty flag) even if it did not move at all.

Expected Output:
The start move peg's status would not change.
Comment 1 yutongmen2-c 2021-11-29 11:58:09 HKT
Previous code:

public void giveTips(){
        judge_point.setStatus(0);
        ArrayList<Point> result = new ArrayList<>();
        result = new Judge().find(judge_point, g, 0);

        for (Point point : result) {
            pArray.add(point);
        }
    }

Modified code:

public void giveTips(){
        int prev_status = judge_point.getStatus();

        judge_point.setStatus(0);
        ArrayList<Point> result = new ArrayList<>();
        result = new Judge().find(judge_point, g, 0);

        for (Point point : result) {
            pArray.add(point);
        }
        if(result.isEmpty())    judge_point.setStatus(prev_status);
    }