public void processAction(PMAction action, PMMob target)
 {
     // Each action is responsable for itself
     // The battle controller just tells the action when
     // to do it's thing.
     action.activate(target);
 }
Example #2
0
 public void onEquip(PMMob holder)
 {
     foreach (IEquipable childBehavior in this.behaviors)
     {
         childBehavior.onEquip(holder);
     }
 }
    public HashSet <int> getEnemyTeam(PMMob m)
    {
        int           myTeam = getMyTeam(m);
        HashSet <int> result = new HashSet <int>(this.teams);

        result.Remove(myTeam);
        return(result);
    }
Example #4
0
    public PMAction getNextAction(PMBattleController battleController)
    {
        PMMob enemy = battleController.getEnemy(this);

        if (this.myActions.Count == 0)
        {
            return(new ActionAttack(1));
        }
        return(myActions[0]);
    }
Example #5
0
    public bool activate(PMMob target)
    {
        bool result = true;

        foreach (PMAction action in this.behaviors)
        {
            result &= action.activate(target);
        }
        return(result);
    }
 public PMMob getEnemy(PMMob m)
 {
     if (getMyTeam(m) == 1)
     {
         return(ch2);
     }
     else
     {
         return(ch1);
     }
 }
    private void Start()
    {
        Dictionary <string, int> m1Stats = new Dictionary <string, int> {
            { BattleStats.CURRENT_HEALTH, 10 }, { BattleStats.MAX_HEALTH, 10 }
        };
        Dictionary <string, int> m2Stats = new Dictionary <string, int>(m1Stats);

        m1      = new PMMob(m1Stats);
        m2      = new PMMob(m2Stats);
        this.bc = new PMBattleController(m1, m2);
        turn    = true;
        loopN   = 0;
    }
    public PMBattleController(PMMob team1, PMMob team2)
    {
        this.ch1 = team1;
        this.ch2 = team2;

        mobToTeam = new Dictionary <PMMob, int>(2)
        {
            { team1, 1 },
            { team2, 2 }
        };

        turnOrder = new List <PMMob>();
        turnOrder.Add(ch1);
        turnOrder.Add(ch2);
    }
    private void testEquipablePipe()
    {
        Dictionary <string, int> m1Stats = new Dictionary <string, int> {
            { BattleStats.CURRENT_HEALTH, 10 }, { BattleStats.MAX_HEALTH, 10 }, { BattleStats.SPEED, 0 }
        };
        Dictionary <string, int> m2Stats = new Dictionary <string, int>(m1Stats);
        PMMob m1 = new PMMob(m1Stats);
        PMMob m2 = new PMMob(m2Stats);

        Pipe <int> speedUp = new PipeSum(new ExpireNever <Pipe <int> >(), new Flagable(), 5);

        speedUp.addFlag(BattleStats.SPEED);
        IEquipable helmOfSpeed = new EquipablePipe(EquipSlots.HELM, speedUp);

        m1.equip(helmOfSpeed);


        IEquipable e = m1.peekEquipmentSlot(EquipSlots.HELM);

        if (e.targetSlot() == EquipSlots.HELM)
        {
            Debug.Log("Nocab test 2.1 passed");
        }
        else
        {
            Debug.Log("Nocab test 2.1 fail");
        }

        if (m1.getStat(BattleStats.SPEED) == 5)
        {
            Debug.Log("Nocab test 2.2 passed");
        }
        else
        {
            Debug.Log("Nocab test 2.2 failed");
        }

        m1.unequip(EquipSlots.HELM);

        if (m1.getStat(BattleStats.SPEED) == 0)
        {
            Debug.Log("Nocab test 2.3 passed");
        }
        else
        {
            Debug.Log("Nocab test 2.3 failed: Equipable pipe did not reset value after unequip");
        }
    }
    private void testEquipableAction()
    {
        Dictionary <string, int> m1Stats = new Dictionary <string, int> {
            { BattleStats.CURRENT_HEALTH, 10 }, { BattleStats.MAX_HEALTH, 10 }
        };
        Dictionary <string, int> m2Stats = new Dictionary <string, int>(m1Stats);
        PMMob m1 = new PMMob(m1Stats);
        PMMob m2 = new PMMob(m2Stats);

        PMAction   swordSlash  = new ActionAttack(5);
        IEquipable attackSword = new ActionEquipable(EquipSlots.MAIN_HAND, swordSlash);

        m1.equip(attackSword);


        IEquipable e = m1.peekEquipmentSlot(EquipSlots.MAIN_HAND);

        if (e.targetSlot() == EquipSlots.MAIN_HAND)
        {
            Debug.Log("Nocab test 1.1 passed");
        }
        else
        {
            Debug.Log("Nocab test 1.1 fail");
        }

        PMBattleController bc = new PMBattleController(m1, m2);

        PMAction a = m1.getNextAction(bc);

        a.activate(m2);

        if (m2.getStat(BattleStats.CURRENT_HEALTH) == 5)
        {
            Debug.Log("Nocab test 1.2 passed");
        }
        else
        {
            Debug.Log("Nocab test 1.2 failed");
        }

        m1.unequip(EquipSlots.MAIN_HAND);
    }
Example #11
0
 public virtual void onEquip(PMMob holder)
 {
     //Debug.Log("ActionEquipable onEquip() called");
     this.holder = holder;
     this.holder.addAction(providedAction);
 }
Example #12
0
 public void onEquip(PMMob holder)
 {
     this.holder = holder;
     holder.addOutPipe(this._pipe);
 }
Example #13
0
 public bool activate(PMMob target)
 {
     //Debug.Log("ActionAttack has been activated");
     target.modifyStat(BattleStats.CURRENT_HEALTH, dmg);
     return(true);
 }
    private void testMultiPipe()
    {
        Dictionary <string, int> m1Stats = new Dictionary <string, int> {
            { BattleStats.CURRENT_HEALTH, 10 }, { BattleStats.MAX_HEALTH, 10 }, { BattleStats.SPEED, 0 }
        };
        Dictionary <string, int> m2Stats = new Dictionary <string, int>(m1Stats);
        PMMob m1 = new PMMob(m1Stats);
        PMMob m2 = new PMMob(m2Stats);

        Pipe <int> speedUp = new PipeSum(new ExpireNever <Pipe <int> >(), new Flagable(), 5);

        speedUp.addFlag(BattleStats.SPEED);
        IEquipable           helmOfSpeed = new EquipablePipe(EquipSlots.HELM, speedUp);
        PMAction             swordSlash  = new ActionAttack(5);
        IEquipable           attackSword = new ActionEquipable(EquipSlots.MAIN_HAND, swordSlash);
        HashSet <IEquipable> subEquips   = new HashSet <IEquipable>()
        {
            helmOfSpeed,
            attackSword
        };
        IEquipable multiItem = new MultiBehaviorEquipable(EquipSlots.HELM, subEquips);

        m1.equip(multiItem);

        IEquipable e = m1.peekEquipmentSlot(EquipSlots.HELM);

        if (e.targetSlot() == EquipSlots.HELM)
        {
            Debug.Log("Nocab test 3.1 passed");
        }
        else
        {
            Debug.Log("Nocab test 3.1 fail");
        }

        PMBattleController bc = new PMBattleController(m1, m2);
        PMAction           a  = m1.getNextAction(bc);

        a.activate(m2);

        if (m2.getStat(BattleStats.CURRENT_HEALTH) == 5)
        {
            Debug.Log("Nocab test 3.2 passed");
        }
        else
        {
            Debug.Log("Nocab test 3.2 failed");
        }

        if (m1.getStat(BattleStats.SPEED) == 5)
        {
            Debug.Log("Nocab test 3.3 passed");
        }
        else
        {
            Debug.Log("Nocab test 3.3 failed");
        }



        m1.unequip(EquipSlots.HELM);



        if (m1.getStat(BattleStats.SPEED) == 0)
        {
            Debug.Log("Nocab test 3.4 passed");
        }
        else
        {
            Debug.Log("Nocab test 3.4 failed");
        }
        if (m2.getStat(BattleStats.CURRENT_HEALTH) == 5)
        {
            Debug.Log("Nocab test 3.5 passed");
        }
        else
        {
            Debug.Log("Nocab test 3.5 failed");
        }
    }
 public int getMyTeam(PMMob m)
 {
     return(this.mobToTeam[m]);
 }