import AXJava.Cron;
import LivinGrimoire.DiSkillV2;
public class DiCron extends DiSkillV2 {
private String sound = "moan";
private Cron cron = new Cron("12:05",40,2);//Cron(String startTime, int minutes, int limit)
// setters
public DiCron setSound(String sound) {
this.sound = sound;
return this;
}
public DiCron setCron(Cron cron) {
this.cron = cron;
return this;
}
@Override
public void input(String ear, String skin, String eye) {
if (cron.trigger()){
setVerbatimAlg(4,sound);
}
}
}
public class DiMagic8Ball extends DiSkillV2 {
public Magic8Ball magic8Ball = new Magic8Ball();
// skill toggle params:
public AXContextCmd skillToggler = new AXContextCmd();
private Boolean isActive = true;
public DiMagic8Ball() {
skillToggler.contextCommands.add("toggle eliza");
skillToggler.contextCommands.add("toggle magic 8 ball");
skillToggler.contextCommands.add("toggle magic eight ball");
skillToggler.commands.add("again");skillToggler.commands.add("repeat");
}
@Override
public void input(String ear, String skin, String eye) {
// toggle the skill off/on
if(skillToggler.engageCommand(ear)){isActive = !isActive;setVerbatimAlg(4, isActive? "skill activated":"skill inactivated");return;}
if (!isActive){return;}
// skill logic:
if (magic8Ball.engage(ear)){
setVerbatimAlg(4, magic8Ball.reply());
}
}
}
public class Magic8Ball {
private Responder questions = new Responder();
private Responder answers = new Responder();
public void setQuestions(Responder questions) {
this.questions = questions;
}
public void setAnswers(Responder answers) {
this.answers = answers;
}
public Responder getQuestions() {
return questions;
}
public Responder getAnswers() {
return answers;
}
public Magic8Ball() {
// answers :
// Affirmative Answers
answers.addResponse("It is certain");
answers.addResponse("It is decidedly so");
answers.addResponse("Without a doubt");
answers.addResponse("Yes definitely");
answers.addResponse("You may rely on it");
answers.addResponse("As I see it, yes");
answers.addResponse("Most likely");
answers.addResponse("Outlook good");
answers.addResponse("Yes");
answers.addResponse("Signs point to yes");
// Non – Committal Answers
answers.addResponse("Reply hazy, try again");
answers.addResponse("Ask again later");
answers.addResponse("Better not tell you now");
answers.addResponse("Cannot predict now");
answers.addResponse("Concentrate and ask again");
// Negative Answers
answers.addResponse("Don’t count on it");
answers.addResponse("My reply is no");
answers.addResponse("My sources say no");
answers.addResponse("Outlook not so good");
answers.addResponse("Very doubtful");
// questions :
questions = new Responder("will i", "can i expect", "should i", "may i","is it a good idea","will it be a good idea for me to","is it possible","future hold","will there be");
}
public Boolean engage(String ear){
if (ear.isEmpty()){return false;}
if (questions.strContainsResponse(ear)){return true;}
// String temp = new RegexUtil().firstWord(ear);
// if (temp.equals("does")||temp.equals("is")){return true;}
return false;
}
public String reply(){return answers.getAResponse();}
}
class Magic8Ball:
def __init__(self):
self.__questions: Responder = Responder()
self.__answers: Responder = Responder()
# answers:
# Affirmative answers
self.__answers.addResponse("It is certain")
self.__answers.addResponse("It is decidedly so")
self.__answers.addResponse("Without a doubt")
self.__answers.addResponse("Yes definitely")
self.__answers.addResponse("You may rely on it")
self.__answers.addResponse("As I see it, yes")
self.__answers.addResponse("Most likely")
self.__answers.addResponse("Outlook good")
self.__answers.addResponse("Yes")
self.__answers.addResponse("Signs point to yes")
# Non – Committal answers
self.__answers.addResponse("Reply hazy, try again")
self.__answers.addResponse("Ask again later")
self.__answers.addResponse("Better not tell you now")
self.__answers.addResponse("Cannot predict now")
self.__answers.addResponse("Concentrate and ask again")
# Negative answers
self.__answers.addResponse("Don’t count on it")
self.__answers.addResponse("My reply is no")
self.__answers.addResponse("My sources say no")
self.__answers.addResponse("Outlook not so good")
self.__answers.addResponse("Very doubtful")
# questions:
self.__questions = Responder("will i", "can i expect", "should i", "may i", "is it a good idea",
"will it be a good idea for me to", "is it possible", "future hold", "will there be")
def setQuestions(self, q: Responder):
self.__questions = q
def setAnswers(self,answers: Responder):
self.__answers = answers
def getQuestions(self) -> Responder:
return self.__questions
def getAnswers(self) -> Responder:
return self.__answers
def engage(self, ear: str) -> bool:
if len(ear) == 0:
return False
if self.__questions.strContainsResponse(ear):
return True
return False
def reply(self) -> str:
return self.__answers.getAResponse()
class DiMagic8Ball(DiSkillV2):
def __init__(self):
super().__init__()
self.magic8Ball: Magic8Ball = Magic8Ball()
# Override
def input(self, ear: str, skin: str, eye: str):
# skill logic:
if self.magic8Ball.engage(ear):
self.setVerbatimAlg(4, self.magic8Ball.reply())
public class AXShoutOut {
private Boolean isActive = false;
public Responder handshake = new Responder();
public void activate(){
// make engagable
isActive = true;
}
public Boolean engage(String ear){
if (ear.isEmpty()) {return false;}
if (isActive){
if (handshake.strContainsResponse(ear)){
isActive = false;return true; // shout out was replied!
}
}
// unrelated reply to shout out, shout out context is outdated
isActive = false;
return false;
}
}
class AXShoutOut:
def __init__(self):
self.__isActive: bool = False
self.handshake: Responder = Responder()
def activate(self):
# make engage-able
self.__isActive = True
def engage(self, ear: str) -> bool:
if len(ear) == 0:
return False
if self.__isActive:
if self.handshake.strContainsResponse(ear):
self.__isActive = False;
return True # shout out was replied!
# unrelated reply to shout out, shout out context is outdated
self.__isActive = False
return False
public class AXHandshake {
/*example use
if (handshake.engage(ear)){ // ear reply like: what do you want?/yes
setVerbatimAlg(4,"now I know you are here");return;
}
if (handshake.trigger()){setVerbatimAlg(4,handshake.getUser_name());return;}// user, user!
* */
private TrgTime trgTime = new TrgTime();
private TrgTolerance trgTolerance = new TrgTolerance(10);
private AXShoutOut shoutOut = new AXShoutOut();
private String user_name = "user";
private PercentDripper dripper = new PercentDripper();
public AXHandshake() {
// default handshakes (valid reply to shout out)
shoutOut.handshake = new Responder("what", "yes", "i am here");
}
// setters
public AXHandshake setTimeStamp(String time_stamp){
// when will the shout-out happen?
// example time stamp: 9:15
trgTime.setTime(time_stamp);
return this;
}
public AXHandshake setShoutOutLim(int lim){
// how many times should user be called for, per shout out?
trgTolerance.setMaxrepeats(lim);
return this;
}
public AXHandshake setHandShake(Responder responder){
// which responses would acknowledge the shout-out?
// such as *see default handshakes for examples suggestions
shoutOut.handshake = responder;
return this;
}
public AXHandshake setDripperPercent(int n){
// when shout out to user how frequent will it be?
dripper.setLimis(n);
return this;
}
public void setUser_name(String user_name) {
this.user_name = user_name;
}
// getters
public String getUser_name() {
return user_name;
}
public Boolean engage(String ear){
if (trgTime.alarm()){trgTolerance.reset();}
// stop shout out
if (shoutOut.engage(ear)){trgTolerance.disable();return true;}
return false;
}
public Boolean trigger(){
if (trgTolerance.trigger()){
if (dripper.drip()){shoutOut.activate();return true;}
}
return false;
}
}