Commit 9c41dc66 authored by Martin LOISEAU's avatar Martin LOISEAU 🎄
Browse files

Reinitialize node elements at trigger to allow multiple call

parent 809b6e79
package com.example.qrquest.actions;
import android.util.Log;
import com.example.qrquest.MainActivity;
public class ClearNodes extends Action {
public ClearNodes(MainActivity mainActivity, int nodeID) {
super(mainActivity, nodeID);
}
public void Do()
{
super.Do();
this.mainActivity.OpenNodes.clear();
Log.d("Debug2", "Every open node cleared");
End();
}
}
package com.example.qrquest.node;
import android.util.Log;
import com.example.qrquest.MainActivity;
import com.example.qrquest.actions.Action;
import com.example.qrquest.atom.Atom;
import java.util.ArrayList;
import java.util.List;
public class Node {
......@@ -11,7 +14,7 @@ public class Node {
* It triggers when the player has gathered every required atoms
*/
public List<Action> Actions; // initialized at the beginning and doesn't change
private List<Action> Actions; // initialized at the beginning and doesn't change
private List<Action> TODOActions; // copy of Actions that empty itself when actions are done (contains the remaining actions)
public List<Atom> Conditions;
public int ID;
......@@ -23,7 +26,6 @@ public class Node {
this.ID = ID;
this.Actions = Actions;
this.Conditions = Conditions;
this.TODOActions = Actions;
}
public boolean CheckConditions(List<Atom> AvailableAtoms)
......@@ -41,6 +43,9 @@ public class Node {
public void Trigger()
{
if(this.ID == 3) Log.d("Debug2", "Node 3 triggered");
this.TODOActions = new ArrayList<>(Actions);
if(this.ID == 3) Log.d("Debug2", Integer.toString(TODOActions.size()) + " actions to do for node 3");
TODOActions.get(0).Do();
/*
for (Action a: Actions
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment