Bug 688 - Garbled characters shown in user interface
Summary: Garbled characters shown in user interface
Status: RESOLVED FIXED
Alias: None
Product: River-Crossing-Puzzle-Solver
Classification: Unclassified
Component: UI (show other bugs)
Version: v0.9.5
Hardware: PC Mac OS
: High critical
Assignee: tsunychau2-c
URL:
Depends on:
Blocks:
 
Reported: 2022-11-05 18:24 HKT by tsunychau2-c
Modified: 2022-11-05 18:30 HKT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description tsunychau2-c 2022-11-05 18:24:23 HKT
In player mode, the user interface show garbled characters instead of "~" character.
Comment 1 tsunychau2-c 2022-11-05 18:27:43 HKT
Way to Reproduce:

1. Run Main.java inside the folder (Puzzle.UI)

2. Input character "2" on the console and press enter.

3. Input character "1" on the console and press enter.

Actual result:

Please enter the number to select the mode:  1-Solver  2-One Player
2
Please enter the number to select the game level: 1-easy  2-hard  3-import custom rule json file path.
1

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The puzzle name: 	Farmer-tiger-sheep-grass
The game rule: 		tiger eat sheep, but farmer can protect sheep. Sheep eat grass if farmer not around. Only farmer can drive the boat
The game role: 		[farmer, tiger, sheep, grass]


[0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= 
[0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ 
[0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ 
[0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ 
[0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ 
[0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ 
[0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ 
[0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [1;36m. . . . . . . . . B o a t . . . . . . . . . [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ 
[0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [1;36m[                                       [1;36m  ][0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ [0;37m~ 
[0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= [0;32m= 
[1;33mfarmer [1;33mtiger [1;33msheep [1;33mgrass [0;37m

---------------------------------------------------------------------------------------------------------

Please use the following command to take action: 
FULL NAME 			 Choose a role on the boat side and Enter the full role name put the role to the boat
's' 				 To start the boat
'e' 				 To exit the program
'u' 				 To undo the action if exist
'r' 				 To redo the action if exist
You command: 

Expect result:

Please enter the number to select the mode:  1-Solver  2-One Player
2
Please enter the number to select the game level: 1-easy  2-hard  3-import custom rule json file path.
1

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~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~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ 
~ ~ ~ ~ ~ ~ ~ . . . . . . . . . B o a t . . . . . . . . . ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ 
~ ~ ~ ~ ~ ~ ~ [                                         ]~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ 
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
farmer tiger sheep grass 

---------------------------------------------------------------------------------------------------------

Please use the following command to take action: 
FULL NAME 			 Choose a role on the boat side and Enter the full role name put the role to the boat
's' 				 To start the boat
'e' 				 To exit the program
'u' 				 To undo the action if exist
'r' 				 To redo the action if exist
You command:
Comment 2 tsunychau2-c 2022-11-05 18:29:45 HKT
Bug is confirmed. The reason is the missing of "AnsiConsole.systemInstall();"

Modification of code:

package Puzzle.UI;
import java.util.*;
import org.fusesource.jansi.AnsiConsole;

public class Main{
 
    public static void main(String[] args) {
    	AnsiConsole.systemInstall();
    	GameFlow m;
    	GameFlowFactory f = new GameFlowFactory();
    	Scanner s = new Scanner(System.in);
    	
    	if(args.length > 0) {
	    	if(args[0].equals("-s")) {
	    		String jsonPath = args[1];
	    		m = f.getGameFlow("1", jsonPath);
		        m.run();
	    	}else if(args[0].equals("-p")) {
	    		String jsonPath = args[1];
	    		m = f.getGameFlow("2", jsonPath);
		        m.run();
	    	}
    	}else {
	    	ArrayList<String> commandList = new ArrayList<String>();
	    	commandList.add("1");
	    	commandList.add("2");
	    	    	
	    	String mode;
	    	do{
		        System.out.println("Please enter the number to select the mode:  1-Solver  2-One Player");
		        mode = s.next();
	    	}while(!commandList.contains(mode));
	    	
	        m = f.getGameFlow(mode);
	        m.run();
    	}	    	
    	
        s.close();
    }
}