to use this type of skills 2 lines of codes are required in the chobit class c'tor
adding a lv1 skill : with super class : DiTglrAdapter containing the desired skill

and adding a DiTglrSkill preferably as a lv3 skill. refer to class doc for more



Code:

package chobit;

public class DiTglrAdapter extends DISkill {
   // adapts a skill to be toggled on or off be a DiTglrSkill
   // this skills should be added only as level1 skills, example in the chobit
   // c'tor:
   // dClassesLv1.add(new DiTglrAdptrMommy(kokoro));
   private Boolean alive = true;
   private String conjuration = "";
   private DISkill diSkill;
   public DiTglrAdapter(Kokoro kokoro, String conjuration, DISkill diSkill) {
      super(kokoro);
      this.diSkill = diSkill;
      this.conjuration = conjuration;
   }

   public DiTglrAdapter(Boolean startAsActive, Kokoro kokoro, String conjuration, DISkill diSkill) {
      super(kokoro);
      this.diSkill = diSkill;
      this.conjuration = conjuration;
      this.alive = startAsActive;
   }
   @Override
   public void input(String ear, String skin, String eye) {
      // toggle :
      String meirei = this.kokoro.toHeart.getOrDefault(conjuration, "");
      if (meirei.contains(conjuration + " off")) {
         this.alive = false;
         this.kokoro.toHeart.remove(conjuration);
         return;
      }
      if (meirei.contains(conjuration + " on")) {
         this.alive = true;
         this.kokoro.toHeart.remove(conjuration);
         return;
      }
      // engage :
      if (alive) {
         this.diSkill.input(ear, skin, eye);
      }
   }

   @Override
   public void output(Neuron noiron) {
      if (alive) {
         this.diSkill.output(noiron);
      }
   }

}


DiTglrSkill :

Code:

package chobit;

import java.util.ArrayList;

public class DiTglrSkill extends DISkill {
   // this toggles a skill, logically a level 1 skill
   /*
    * thus one can use hidden skills without the chobits hidden name and use select
    * cases rather than string.contains for a speed beef up as well
    */
   private ArrayList<String> conjurtions = new ArrayList<String>();
   private String outString = "";
   private DISkillUtils diSkillUtils = new DISkillUtils();

   public DiTglrSkill(Kokoro kokoro, String... conjurationsTemp) {
      super(kokoro);
      for (int i = 0; i < conjurationsTemp.length; i++) {
         this.conjurtions.add(conjurationsTemp[i]);
      }
   }

   private String strContainsList(String str1) {
      for (String temp : conjurtions) {
         if (str1.contains(temp)) {
            return temp;
         }
      }
      return "";
   }
   @Override
   public void input(String ear, String skin, String eye) {
      // toggle :
      if (ear.contains("dislike")) {
         String conjurati = strContainsList(ear);
         if (!conjurati.isEmpty()) {
            kokoro.toHeart.put(conjurati, conjurati + " off");
            outString = "you dislike it";
            return;
         }
      }
      if (ear.contains("like")) {
         String conjurati = strContainsList(ear);
         if (!conjurati.isEmpty()) {
            kokoro.toHeart.put(conjurati, conjurati + " on");
            outString = "ok";
            return;
         }
      }
   }

   @Override
   public void output(Neuron noiron) {
      if (!outString.isEmpty()) {
         noiron.algParts.add(diSkillUtils.verbatimGorithm(new APVerbatim(outString)));
         outString = "";
      }
   }
}


:cop2: :chii: 👮 :s6: :s6: :s6: