double dragon design pattern

owly

闇の伝説
Staff member
戦闘 コーダー
double the dragon double the fun!
gamification skill addapter
@fukurou

setter and getter ver
 

fukurou

the supreme coder
ADMIN
Java:
package skills;

import AXJava.AXGamification;
import LivinGrimoire.DiSkillV2;
import LivinGrimoire.Neuron;

public class GamificationP extends DiSkillV2 {
    // the grind side of the game, see GamificationN for the reward side
    private int gain = 1;
    private DiSkillV2 skill;
    private AXGamification axGamification = new AXGamification();

    public GamificationP(DiSkillV2 skill) {
        this.skill = skill;
    }

    public void setGain(int gain) {
        if (gain >0){
            this.gain = gain;}
    }

    public AXGamification getAxGamification() {
        // shallow ref
        return axGamification;
    }

    @Override
    public void output(Neuron noiron) {
        // skill activation increases gaming credits
        if (outAlg != null) {axGamification.incrementBy(gain);}
        super.output(noiron);
    }
}
 

fukurou

the supreme coder
ADMIN
Java:
package LivinGrimoire;

import java.util.ArrayList;

public class DiSkillV2 {
    protected Kokoro kokoro = new Kokoro(new AbsDictionaryDB()); // consciousness, shallow ref class to enable interskill communications
    protected DISkillUtils diSkillUtils = new DISkillUtils();
    protected Algorithm outAlg = null; // skills output
    protected int outpAlgPriority = -1; // defcon 1->5

    public DiSkillV2() {
        super();
    }
    // skill triggers and algorithmic logic
    public void input(String ear, String skin, String eye) {
    }
    // extraction of skill algorithm to run (if there is one)
    public void output(Neuron noiron) {
        if (outAlg != null) {
            noiron.insertAlg(this.outpAlgPriority,outAlg);
            outpAlgPriority = -1;
            outAlg = null;
        }
    }
    public void setKokoro(Kokoro kokoro) {
        // use this for telepathic communication between different chobits objects
        this.kokoro = kokoro;
    }
    // in skill algorithm building shortcut methods:
    protected void setVerbatimAlg(int priority, String... sayThis){
        // build a simple output algorithm to speak string by string per think cycle
        // uses varargs param
        this.outAlg = this.diSkillUtils.simpleVerbatimAlgorithm(sayThis);
        this.outpAlgPriority = priority; // 1->5 1 is the highest algorithm priority
    }
    protected void setVerbatimAlgFromList(int priority, ArrayList<String> sayThis){
        // build a simple output algorithm to speak string by string per think cycle
        // uses list param
        this.outAlg = this.diSkillUtils.algBuilder(new APVerbatim(sayThis));
        this.outpAlgPriority = priority; // 1->5 1 is the highest algorithm priority
    }
    protected void algPartsFusion(int priority,Mutatable... algParts){
        // build a custom algorithm out of a chain of algorithm parts(actions)
        this.outAlg = this.diSkillUtils.algBuilder(algParts);
        this.outpAlgPriority = priority; // 1->5 1 is the highest algorithm priority
    }
    public Boolean pendingAlgorithm(){
        // is an algorithm pending?
        return this.outAlg != null;
    }
}
 

fukurou

the supreme coder
ADMIN
Java:
package skills;

import AXJava.AXGamification;
import LivinGrimoire.DiSkillV2;
import LivinGrimoire.Neuron;

public class GamificationP extends DiSkillV2 {
    // the grind side of the game, see GamificationN for the reward side
    private int gain = 1;
    private DiSkillV2 skill;
    private AXGamification axGamification = new AXGamification();

    public GamificationP(DiSkillV2 skill) {
        this.skill = skill;
    }

    public void setGain(int gain) {
        if (gain >0){
            this.gain = gain;}
    }

    public AXGamification getAxGamification() {
        // shallow ref
        return axGamification;
    }

    @Override
    public void input(String ear, String skin, String eye) {
        skill.input(ear, skin, eye);
    }

    @Override
    public void output(Neuron noiron) {
        // skill activation increases gaming credits
        if (skill.pendingAlgorithm()) {axGamification.incrementBy(gain);}
        skill.output(noiron);
    }
}
 

fukurou

the supreme coder
ADMIN
Java:
package AXJava;

public class AXGamification {
    // this auxiliary module can add fun to tasks, skills, and abilities simply by
    // tracking their usage, and maximum use count.
    private int counter = 0;
    private int max = 0;

    public int getCounter() {
        return counter;
    }

    public int getMax() {
        return max;
    }
    public void resetCount(){
        counter = 0;
    }
    public void resetAll(){
        max = 0;
        counter = 0;
    }
    public void increment(){
        counter++;
        if (counter > max) {
            max = counter;
        }
    }
    public void incrementBy(int n){
        counter+= n;
        if (counter > max) {
            max = counter;
        }
    }
    public Boolean reward(int cost){
        // game grind points used for rewards
        // consumables, items or upgrades this makes games fun
        if (cost>counter){return false;}
        counter-=cost;
        return true;
    }
    public Boolean surplus(int cost){
        // has surplus for reward?
        if (cost>counter){return false;}
        return true;
    }
}
 

fukurou

the supreme coder
ADMIN
Java:
package skills;

import AXJava.AXGamification;
import LivinGrimoire.DiSkillV2;
import LivinGrimoire.Neuron;

public class GamificationN extends DiSkillV2 {
    private AXGamification axGamification;
    private int cost = 3;
    private DiSkillV2 skill;

    public GamificationN(DiSkillV2 skill, GamificationP rewardBank) {
        this.skill = skill;
        axGamification = rewardBank.getAxGamification();
    }

    public void setCost(int cost) {
        this.cost = cost;
    }

    @Override
    public void input(String ear, String skin, String eye) {
        // engage skill only if a reward is possible
        if (axGamification.surplus(cost)){skill.input(ear, skin, eye);}
    }

    @Override
    public void output(Neuron noiron) {
        // charge reward if an algorithm is pending
        if (skill.pendingAlgorithm()) {axGamification.reward(cost);skill.output(noiron);}
    }
}
 

owly

闇の伝説
Staff member
戦闘 コーダー
these are the updates:
AXNPC:
learn->bool
strLearn : ear.isEmpty case

DiEngager
DiBlabber

*AXNPC2 swift python ported?

DiSkillV2
pendingAlgorithm?

AXGamification
surplus->boolean

GamificationP,N

AX: AXGamification, AXNPC,AXNPC2
skills: GamificationP,N,DiEngager, DiBlabber
core: DiskillV2

we will need to add a time skill to test the gamification pattern. and also to port all that shit.
 
Top