Moved random handler to different package

This commit is contained in:
Clisprail
2014-04-27 01:15:47 +02:00
parent 69bcf4db92
commit e2060fe8d7
2 changed files with 2 additions and 2 deletions
@@ -0,0 +1,21 @@
package org.parabot.environment.scripts.randoms;
/**
*
* @author Everel
*
*/
public interface Random {
/**
* Determines whether this random should activate
* @return <b>true</b> if this random should activate
*/
public boolean activate();
/**
* Executes this random
*/
public void execute();
}
@@ -0,0 +1,38 @@
package org.parabot.environment.scripts.randoms;
import java.util.ArrayList;
/**
*
* @author Everel
*
*/
public class RandomHandler {
private ArrayList<Random> randoms;
public RandomHandler() {
randoms = new ArrayList<Random>();
}
/**
* Adds a random to the random list
* @param random
*/
public void addRandom(Random random) {
randoms.add(random);
}
/**
* Checks if random occures and runs it
* @return returns <b>true</b> if a random has been executed, otherwise <b>false</b>
*/
public boolean checkAndRun() {
for(Random r : randoms) {
if(r.activate()) {
r.execute();
return true;
}
}
return false;
}
}