Attempt 2

This commit is contained in:
dginovker
2019-07-16 08:05:39 -04:00
commit 16d2e8140e
64 changed files with 2274 additions and 0 deletions
@@ -0,0 +1,45 @@
package scriptfactory.Actions.Logic;
import scriptfactory.Actions.Action;
import org.rev317.min.api.methods.*;
import java.util.ArrayList;
import static scriptfactory.VarsMethods.log;
import static scriptfactory.VarsMethods.toPintArray;
public class LogicHandler {
public boolean determineIf(Action a) {
switch (a.getMethod().replaceAll("-", " "))
{
case "Item is in Inventory":
return Inventory.getCount(a.getParam(0)) >= (a.getParamAsString(1).equals("") ? 0 : a.getParam(1));
case "Inventory slots used":
return Inventory.getCount() >= a.getParam(0);
case "Item is on Ground":
return GroundItems.getGroundItems(o-> o.getId() == a.getParam(0)).length > 0;
case "Entity is around":
ArrayList<Integer> ids = new ArrayList<>();
for (int i = 0; i < a.getParamCount(); i++)
ids.add(a.getParam(i));
return Npcs.getClosest(toPintArray(ids)) != null ||
SceneObjects.getClosest(toPintArray(ids)) != null;
case "Hitpoints is below":
return Players.getMyPlayer().getHealth() < a.getParam(0);
case "In Combat":
return Players.getMyPlayer().isInCombat();
default:
log("Error: Unimplemented conditional: " + a.getAction());
}
return false;
}
public String determineIfAsBoolString(Action a)
{
return determineIf(a) ? "True" : "False";
}
public String determineIfNotAsBoolString(Action a) {
return determineIfAsBoolString(a).equals("True") ? "False" : "True";
}
}