make pacmen be able to resurrect
[IRC.git] / Robust / src / Benchmarks / MMG / Java / Map.java
index 4720b2e826b7c3d44dc66477462803a6e8cda1b7..33127364e1131cec3e0e782b963e7e4d7da16eb3 100755 (executable)
@@ -10,6 +10,10 @@ public class Map {
     public int[] m_pacMenX;\r
     public int[] m_pacMenY;\r
     public int[] m_directions;\r
+    public int[] m_pacOriX;\r
+    public int[] m_pacOriY;\r
+    public int[] m_leftLives;\r
+    public int[] m_leftLevels;\r
     public int[] m_desX;\r
     public int[] m_desY;\r
     public int m_paccount;\r
@@ -35,6 +39,10 @@ public class Map {
        this.m_pacMenX = new int[this.m_nrofpacs];\r
        this.m_pacMenY = new int[this.m_nrofpacs];\r
        this.m_directions = new int[this.m_nrofpacs];\r
+       this.m_pacOriX = new int[this.m_nrofpacs];\r
+       this.m_pacOriY = new int[this.m_nrofpacs];\r
+       this.m_leftLives = new int[this.m_nrofpacs];\r
+       this.m_leftLevels = new int[this.m_nrofpacs];\r
        this.m_desX = new int[this.m_nrofpacs];\r
        this.m_desY = new int[this.m_nrofpacs];\r
        this.m_paccount = 0;\r
@@ -59,6 +67,9 @@ public class Map {
        //System.printString("step 2\n");\r
        for(int i = 0; i < this.m_nrofpacs; i++) {\r
            this.m_pacMenX[i] = this.m_pacMenY[i] = -1;\r
+           this.m_directions[i] = 0;\r
+           this.m_pacOriX[i] = this.m_pacOriY[i] = -1;\r
+           this.m_leftLives[i] = this.m_leftLevels[i] = 0;\r
            this.m_desX[i] = this.m_desY[i] = -1;\r
            this.m_pacmen[i] = null;\r
        }\r
@@ -109,6 +120,9 @@ public class Map {
        while((!death) && (i < this.m_ghostsX.length)) {\r
            if((t.m_locX == this.m_ghostsX[i]) && (t.m_locY == this.m_ghostsY[i])) {\r
                death = true;\r
+               t.m_death = true;\r
+               t.m_leftLives--;\r
+               //System.printString("Pacman " + t.m_index + " caught! " + t.m_leftLives + "\n");\r
            }\r
            i++;\r
        }\r
@@ -116,16 +130,29 @@ public class Map {
            // reach the destination\r
            //System.printString("Hit destination!\n");\r
            death = true;\r
+           t.m_success = true;\r
+           t.m_leftLevels--;\r
+           //System.printString("Pacman " + t.m_index + " hit, upgrade! " + t.m_leftLevels + "\n");\r
        }\r
        if(death) {\r
-           // pacman caught by ghost\r
-           // set pacman as death\r
-           t.m_death = true;\r
-           // kick it out\r
-           //this.m_map[t.y * this.m_nrofblocks + t.x - 1] -= 16;\r
-           this.m_deathcount++;\r
-           this.m_pacMenX[t.m_index] = -1;\r
-           this.m_pacMenY[t.m_index] = -1;\r
+           if(t.isFinish()) {\r
+               // pacman has no more lives or no more levels\r
+               // kick it out\r
+               this.m_deathcount++;\r
+               this.m_pacMenX[t.m_index] = -1;\r
+               this.m_pacMenY[t.m_index] = -1;\r
+           } else {\r
+               if(t.m_death) {\r
+                   this.m_leftLives[t.m_index]--;\r
+               } else if(t.m_success) {\r
+                   this.m_leftLevels[t.m_index]--;\r
+               }\r
+               t.reset();\r
+               this.m_pacMenX[t.m_index] = t.m_locX;\r
+               this.m_pacMenY[t.m_index] = t.m_locY;\r
+               this.m_directions[t.m_index] = 0;\r
+               //System.printString("Pacman " + t.m_index + " reset: (" + t.m_locX + ", " + t.m_locY + ")\n");\r
+           }\r
        }\r
        return death;\r
     }\r