Android Open Source - BoardGameDirector Counter Condition






From Project

Back to project page BoardGameDirector.

License

The source code is released under:

GNU General Public License

If you think the Android project BoardGameDirector listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.dilph.bgd.engine;
//  w w w .  j a  v  a 2 s  . c om
/**
 * Created with IntelliJ IDEA.
 * User: pseudo
 * Date: 8/3/13
 * Time: 5:16 PM
 * To change this template use File | Settings | File Templates.
 */

/**
 * A condition which can be evaluated against a counter
 */
public class CounterCondition {
    enum Condition { EQUAL, LTE,GTE, LT, GT }
    Condition condition;
    String counterName;
    int value ;

    public CounterCondition(String counterName, Condition condition, int value) {
        this.condition = condition;
        this.counterName = counterName;
        this.value = value;
    }

    public boolean checkCondition()
    {
         int otherValue = CounterManager.getInstance().getCount(counterName);
         switch(condition)
         {
             case EQUAL:
                return otherValue == value;
             case LTE:
                 return otherValue <= value;
             case GTE:
                return otherValue >= value;
             case LT:
                 return otherValue < value;
             case GT:
                 return otherValue > value;
             default:
                 return false;
         }
    }
}




Java Source Code List

com.dilph.bgd.engine.BaseEvent.java
com.dilph.bgd.engine.CounterAction.java
com.dilph.bgd.engine.CounterCondition.java
com.dilph.bgd.engine.CounterManager.java
com.dilph.bgd.engine.Counter.java
com.dilph.bgd.engine.Decision.java
com.dilph.bgd.engine.EndTurnEvent.java
com.dilph.bgd.engine.GameAction.java
com.dilph.bgd.engine.GameManager.java
com.dilph.bgd.engine.Player.java
com.dilph.bgd.engine.TurnEvent.java
com.dilph.bgd.engine.Turn.java
com.dilph.bgd.front.BoardGameDirector.java
com.dilph.bgd.front.MainMenu.java
com.dilph.bgd.front.PlayerManagement.java