battle programmers alliance
Would you like to react to this message? Create an account in a few clicks or log in to continue.


battle programming a forum for elite programmers with extreme will power to sharpen their skills
 
HomeGallerySearchRegisterLog in
 

 toggler type skills for the living grimoire AGI platform

Go down 
AuthorMessage
Moti Barski
super
super
Moti Barski

Posts : 511
Join date : 2011-08-02

toggler type skills for the living grimoire AGI platform Empty
PostSubject: toggler type skills for the living grimoire AGI platform   toggler type skills for the living grimoire AGI platform EmptySun Dec 27, 2020 9:26 pm

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 cop emp it up emp it up emp it up

_________________
MB over and out emp it up
Back to top Go down
 
toggler type skills for the living grimoire AGI platform
Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
battle programmers alliance :: battle programming alliance :: the LivinGrimoire-
Jump to: