Bug 583

Summary: The Sprite disappear after it is surrounded but not died
Product: CS3343_Kunkun_Loves_English Reporter: konolmyda <mingyaliu8-c>
Component: Game ObjectAssignee: xuezhwang2-c
Status: RESOLVED FIXED    
Severity: major    
Priority: ---    
Version: 1.0   
Hardware: PC   
OS: Mac OS   

Description konolmyda 2021-11-20 11:20:49 HKT
Summary: 
Hi, I found that when I was playing the "GRE" version of the game (I guess it is also applicable to other version), when the sprite is surrounded, i.e. it still has some places to move, but it can never go to the boundary. The sprite on the screen just disappeared.

Steps to reproduce:

1. Enter the login scene and click the "GRE" button
2. In the GRE game,
   click basketballs at (5,7), (5, 8), (4, 5), (4, 7), (4, 6), (6, 5), (6, 7), (6, 6) in order and enter correct word.

Expected outcome:

After the sprite is surrounded but not died, the picture displayed should be angry cxk.

Actual outcome:

After the sprite is surrounded but not died, nothing is displayed at the sprite's location.

Guess:

I guess the reason is because there is some mistake in loading the pictures from file system in the game object Dio.
Comment 1 xuezhwang2-c 2021-11-20 11:31:34 HKT
(In reply to konolmyda from comment #0)
> Summary: 
> Hi, I found that when I was playing the "GRE" version of the game (I guess
> it is also applicable to other version), when the sprite is surrounded, i.e.
> it still has some places to move, but it can never go to the boundary. The
> sprite on the screen just disappeared.
> 
> Steps to reproduce:
> 
> 1. Enter the login scene and click the "GRE" button
> 2. In the GRE game,
>    click basketballs at (5,7), (5, 8), (4, 5), (4, 7), (4, 6), (6, 5), (6,
> 7), (6, 6) in order and enter correct word.
> 
> Expected outcome:
> 
> After the sprite is surrounded but not died, the picture displayed should be
> angry cxk.
> 
> Actual outcome:
> 
> After the sprite is surrounded but not died, nothing is displayed at the
> sprite's location.
> 
> Guess:
> 
> I guess the reason is because there is some mistake in loading the pictures
> from file system in the game object Dio.

Hi, Mingyang!

This is the original code inside class Dio.java:

	public void recomputeShortestPath(boolean shouldMove) {

		if (isAlive()) {
			MapNode dir = null; 
			//whether change to surround from normal / death from surround
			if(!isTrapped) {
				s = new ShortestPath();
				MapNodeInfo info = node.getNodeInformation();	
				dir = s.computeDecision(info.abstractPos);
				if(dir==null) {
					setSurround(true);
				}
			        if(isTrapped()) {
				        dir = moveSurround();
			        }
			}
			if(dir!=null && shouldMove) {
				setNode(dir);
			}
		}
	}

The problem is that the code segment to judge whether Dio is trapped (surrounded in your language) is inside the code segment if(!isTrapped), this means that after you update the information of boolean variable trapped. moveSurround will directly be executed without first change the update().

I fix this bug by change the code into the following:

	public void recomputeShortestPath(boolean shouldMove) {

		if (isAlive()) {
			MapNode dir = null; 
			//whether change to surround from normal / death from surround
			if(!isTrapped) {
				s = new ShortestPath();
				MapNodeInfo info = node.getNodeInformation();	
				dir = s.computeDecision(info.abstractPos);
				if(dir==null) {
					setSurround(true);
				}
			}
			if(isTrapped()) {
				dir = moveSurround();
			}
			if(dir!=null && shouldMove) {
				setNode(dir);
			}
		}
	}