Code:


package skills;

import AXJava.DrawRnd;
import AXJava.Responder;
import LivinGrimoire.DiSkillV2;

import java.util.ArrayList;

public class DiActivity extends DiSkillV2 {
    /* for multistep activities
    uses step machine code algorithm to
    step between sub activities of activity
    see DiHuggyWuggy for example skill
    * */
    private ArrayList<DrawRnd> activities = new ArrayList<>();
    private int index = -1;
    // commands
    private String start = "start activity";
    private String stop = "stop";
    private Responder skip = new Responder("skip","next","ok");
    private String doNext = "";
    public void setStart(String start) {
        this.start = start;
    }

    public void setStop(String stop) {
        this.stop = stop;
    }

    public void setSkip(Responder skip) {
        this.skip = skip;
    }
    public void addActivity(DrawRnd drawRnd){activities.add(drawRnd);}
    @Override
    public void input(String ear, String skin, String eye) {
        if(ear.equals(start)){
            index=0;
            for (int i = 0; i < activities.size(); i++) {
                activities.get(i).reset();
            }
        } // start activity
        // activity on?
        if(index>-1){
            if(ear.equals(stop)){index = -1;return;} // stop activity
            else if((skip.responsesContainsStr(ear))||activities.get(index).isEmptied()){
                index++; // skip current activity
            }
            if (index > activities.size()-1){index=-1;return;} // no more activities?
            doNext = activities.get(index).draw();
//            setSimpleAlg(activities.get(index).draw());
        }
        if (doNext.isEmpty()){return;}
        // you can expand the activity to a specialized algorithm here:
        switch (doNext) {
            default:
                setSimpleAlg(doNext);
                doNext = "";
                break;
        }
    }
}


example skill for usage:

Code:

package skills;

import AXJava.DrawRnd;

public class DiHuggyWuggy {
    private DiActivity o1 = new DiActivity();

    public DiHuggyWuggy() {
        o1.addActivity(new DrawRnd("approaches you","wide grin"));
        o1.addActivity(new DrawRnd("hugs you"));
        o1.addActivity(new DrawRnd("hugs you tighter","nuzzles","snuggles","plays with your hair"));
    }
    public DiActivity retSkill(){return this.o1;}
}

adding the skill:
b1.logicChobit.addSkill(new DiHuggyWuggy().retSkill());

the code is self explanatory, and this post will probably only get like 200 views in 3 years so I won't go in to details
but yeah it's a great skill template.

I also like how the c'tor is on a different class, to separate the data from the algorithm. blush