battle programming a forum for elite programmers with extreme will power to sharpen theire skills
 
HomeSearchRegisterLog in
Post new topic   Reply to topicShare
 

 automatic skill : DAlarmer an example alarm clock skyle

Go down 
AuthorMessage
Moti Barski
super
super
Moti Barski

Posts : 394
Join date : 2011-08-02

automatic skill : DAlarmer an example alarm clock skyle Empty
PostSubject: automatic skill : DAlarmer an example alarm clock skyle   automatic skill : DAlarmer an example alarm clock skyle EmptyThu Oct 24, 2019 1:46 am

DAlarmer java class :

Code:
package chobit;
import java.util.ArrayList;

/*creates algorithms with alg parts that can become dormant
 * can wake a dormant algorithm
 * should use notify if you add more cloudians to a wake one of many said algorithm
 * */
public class DAlarmer extends AbsCmdReq implements Neuronable {
   private RegexUtil regexUtil = new RegexUtil();
   private String jikan = "";
   private Cloudian cloudian = new Cloudian();
   private String representation = "";
   private Boolean summon = false;
   private String ear = "";

   @Override
   public void output(Neuron noiron) {
      if (summon) {
         // AbsAlgPart itte = new APCldAlarm(cloudian, jikan);
         AbsAlgPart itte = new APCldAlarm(cloudian, jikan);
         ArrayList<AbsAlgPart> algParts1 = new ArrayList<>();
         algParts1.add(itte);
         Algorithm algorithm = new Algorithm("alm", representation, algParts1);
         this.cloudian.setAlgorithm(algorithm); // ***
         noiron.algParts.add(algorithm);
         reset();
         return;
      }
      if (this.cloudian.updateStat(ear, "")) {
         noiron.algParts.add(this.cloudian.getAlgorithm());
      }
   }

   private void reset() {
      representation = "";
      summon = false;
   }

   @Override
   public void input(String ear, String skin, String eye) {
      this.ear = ear;
      jikan = regexUtil.regexChecker("\\d+:\\d+", ear);
      if (eye.contains("wake me at") && !jikan.isEmpty()) {
         summon = true;
         representation = ear;
      }
   }

   @Override
   public Boolean auto() {
      // this skill can be triggered by time
      return true;
   }
}

uses classes :

Cloudian :

Code:

/*a trigger for reviving a dormant algorithm
 * there should be a cloudian per APCld (alg part cloudian user)
 * */
public class Cloudian {
   private Boolean active = false;
   private Algorithm algorithm = null;
   private String timeTrig = ""; // time trigger
   private String earTrig = "zhakhrixxer";
   private String eyeTrig = "zhakhrixxer";
   private int countDown = 0;
   private Boolean dead = false;

   public Boolean getDead() {
      return dead;
   }

   private Boolean fin = false;

   public Boolean getFin() {
      return fin;
   }

   private PlayGround playGround = new PlayGround();

   public Boolean updateStat(String ear, String eye) {
      Boolean result = false;
      if (ear.contains(earTrig) || eye.contains(eyeTrig)) {
         fin = true;
         result = true;
      }
      if (playGround.getCurrentTimeStamp().equals(this.timeTrig)) {
         result = true;
      }
      result = result && !active;
      if (result) {
         active = true;
      }
      return result;
   }

   public int getCountDown() {
      return countDown;
   }

   public void setCountDown(int countDown) {
      this.countDown = countDown;
   }

   public void reset() {
      active = false;
      algorithm = null;
      timeTrig = ""; // time trigger
      earTrig = "zhakhrixxer";
      eyeTrig = "zhakhrixxer";
      countDown = 0;
      dead = false;
      fin = false;
   }

   public void setMe(int count, String ear, String eye, String setAlmTo) {
      this.countDown = count;
      this.earTrig = ear;
      this.eyeTrig = eye;
      this.timeTrig = setAlmTo;
   }

   public void sleep(int dormantFor) {
      if (this.countDown > 0) {
         this.countDown--;
      } else {
         this.dead = true;
      }
      // this.timeTrig = playGround.getFutureInXMin(dormantFor);
      this.timeTrig = playGround.getFutureFromXInYMin(dormantFor, this.timeTrig);
   }
   public Boolean getActive() {
      return active;
   }

   public void setActive(Boolean active) {
      this.active = active;
   }

   public Algorithm getAlgorithm() {
      return algorithm;
   }

   public void setAlgorithm(Algorithm algorithm) {
      this.algorithm = algorithm;
   }

   public String getTimeTrig() {
      return timeTrig;
   }

   public void setTimeTrig(String timeTrig) {
      this.timeTrig = timeTrig;
   }

   public String getEarTrig() {
      return earTrig;
   }

   public void setEarTrig(String earTrig) {
      this.earTrig = earTrig;
   }

   public String getEyeTrig() {
      return eyeTrig;
   }

   public void setEyeTrig(String eyeTrig) {
      this.eyeTrig = eyeTrig;
   }

}

RegexUtil

Code:
import java.util.regex.Matcher;
import java.util.regex.Pattern;

// returns expression of type theRegex from the string str2Check
public class RegexUtil {
    public String regexChecker(String theRegex, String str2Check) {
        Pattern checkRegex = Pattern.compile(theRegex);
        Matcher regexMatcher = checkRegex.matcher(str2Check);
        while (regexMatcher.find()) {
            if (regexMatcher.group().length() != 0) {
                return regexMatcher.group().trim();
            }
        }
        return "";
    }
}

rain shinny

_________________
MB over and out emp it up
Back to top Go down
 
automatic skill : DAlarmer an example alarm clock skyle
Back to top 
Page 1 of 1

Permissions in this forum:You can reply to topics in this forum
battle programmers alliance :: battle programming alliance :: the LivinGrimoire-
Post new topic   Reply to topicJump to: