| Summary: | It's found that when one player checkmate and already wins the game, the opponent can still act by input "undo" and move command | ||
|---|---|---|---|
| Product: | CS3343 2020 Group 9_Chinese Chess | Reporter: | Marco <kaipewang2-c> |
| Component: | ChessGame | Assignee: | Marco <kaipewang2-c> |
| Status: | CONFIRMED --- | ||
| Severity: | major | CC: | guohan2-c, kaipewang2-c, longtduan2-c, yfeng28-c, yinuowang3-c, yujiawang7-c |
| Priority: | --- | ||
| Version: | V2.0 | ||
| Hardware: | PC | ||
| OS: | Windows | ||
| Deadline: | 2020-10-30 | ||
|
Description
Marco
2020-11-13 21:09:59 HKT
(In reply to Marco from comment #0) > Summary: > It's found that when one player checkmate and already wins the game, the > opponent can still act by input "undo" and move command. > > Steps to Reproduce: > 1. Run the program > 2. Input "new game" > 3. Input "4 3 4 4" > 4. Input "1 7 4 7" > 5. Input "4 4 4 5" > 6. Input "4 6 4 5" > 7. Input "0 0 0 1" > 8. Input "4 7 4 0" > 9. Input "undo" > > Actual Result: > The move "0 0 0 1" is undone. > > Expected Result: > No further command is acceptable when one player already wins. And error > message needs to be prompted. Solution provided by Marco: The bug is solved by adding a new boolean variable called "gameOver" in ChessBoard.java and it will be changed into "true" whenever game ends: case ErrorCode.GAME_ALREADY_OVER: gameOver = true; System.out.println("The game is over!"); break; In this case, when we issue "undo" after game ends, the program will first check the value of "gameOver": public int undo() { if (gameOver) { System.out.println("The game is over! Undo is not allowed."); return ErrorCode.GAME_ALREADY_OVER; } ... ... } Then this bug is successfully fixed. |