Bug 403 (Invalid, Minister, Move)

Summary: It's found that a valid move of the minister is determined to be invaild by the program.
Product: CS3343 2020 Group 9_Chinese Chess Reporter: Marco <kaipewang2-c>
Component: ChessGameAssignee: Marco <kaipewang2-c>
Status: CONFIRMED ---    
Severity: critical CC: guohan2-c, kaipewang2-c, longtduan2-c, yfeng28-c, yinuowang3-c, yujiawang7-c
Priority: High    
Version: V2.0   
Hardware: PC   
OS: Windows   
Attachments: Source code of the Minister Class.

Description Marco 2020-11-14 13:37:25 HKT
Summary:
The bug is found when I try to undo a minister movement. The program prompted that the move of minister is judged invalid. But I'm confident to say that it's a valid move of minister according to rules of Chinese Chess.

Steps to Reproduce:
1. Run the program
2. Input command "new game"
3. Input command "2 0 4 2"

Actual Results:
The program prompt "The move you want to make is invalid!"

Expected Results:
This move is judged valid and successfully performed. No error message will be shown.
Comment 1 Marco 2020-11-14 13:48:45 HKT
Created attachment 42 [details]
Source code of the Minister Class.

For HAN Guo's reference.
Bug may exist in getPossibleMove() function.
Comment 2 guohan2-c 2020-12-06 18:54:50 HKT
(In reply to Marco from comment #1)
> Created attachment 42 [details]
> Source code of the Minister Class.
> 
> For HAN Guo's reference.
> Bug may exist in getPossibleMove() function.

Bugs are found in getPossibleMove() function. Since the boundary of the loop is set wrongly. The code has changed as below
int[] possibleX = {curx-2, curx+2};
            int[] possibleY = {cury-2, cury+2};
            
            for(int x1: possibleX){
                    for(int y1: possibleY){
                            if(checkLegal(x1, y1))
                                  res.add(new ChessPosition(x1, y1));
                    }
            }
            return res; 

problem solved