Bug 575 - The program will remove the invalid start move piece
Summary: The program will remove the invalid start move piece
Status: CONFIRMED
Alias: None
Product: CS3343 Chinese Checker
Classification: Unclassified
Component: Algorithm Component (show other bugs)
Version: unspecified
Hardware: All All
: --- normal
Assignee: yutongmen2-c
URL:
Depends on:
Blocks:
 
Reported: 2021-11-18 00:37 HKT by yutongmen2-c
Modified: 2021-11-29 15:56 HKT (History)
2 users (show)

See Also:


Attachments
The image shows a piece disappeared after an invalid input (45.72 KB, image/jpeg)
2021-11-18 00:37 HKT, yutongmen2-c
Details

Note You need to log in before you can comment on or make changes to this bug.
Description yutongmen2-c 2021-11-18 00:37:59 HKT
Created attachment 89 [details]
The image shows a piece disappeared after an invalid input

The program still removes the start move piece if it is invalid which results in the wrong total pieces number.

Steps to reproduce:
1. Start the game.
2. Select a piece that is invalid.

Actual outcome:
1. The program prints "Not valid start move, please input again."
2. The selected piece is removed by the program.

Expected outcome:
1. The program prints "Not valid start move, please input again."
2. The selected piece is not influenced and the program asks for another valid input.
Comment 1 zhengyxue3-c 2021-11-29 15:56:39 HKT
Previous code:
    public void giveTips(){          // API to demo in GUI
        //...
        judge_point.setStatus(0);
        ArrayList<Point> result = new ArrayList<>();
        result = Judge.find(judge_point, g, 0);

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

After Modification:
    public void giveTips(){          // API to demo in GUI
        int prev_status = judge_point.getStatus();

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

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