Android Open Source - BoardGameDirector Decision






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;
//from   w  ww.  j  av  a 2s. c  o m
/**
 * Created with IntelliJ IDEA.
 * User: pseudo
 * Date: 8/3/13
 * Time: 11:09 AM
 * To change this template use File | Settings | File Templates.
 */

/**
 * A Decision represents something  that should be determined either by the counter and conditions or the player.
 */
public class Decision extends BaseEvent implements TurnEvent {



    TurnEvent trueTurnEvent;
    TurnEvent falseTurnEvent;
    CounterCondition counterCondition;

    public Decision(String message, TurnEvent trueTurnEvent, TurnEvent falseTurnEvent)
    {
         super(message);
         this.trueTurnEvent = trueTurnEvent;
         this.falseTurnEvent = falseTurnEvent;
    }

    public Decision(String s) {
        super(s);
    }

    public Decision(CounterCondition counterCondition, TurnEvent trueTurnEvent, TurnEvent falseTurnEvent) {
        super("Not a user decision");
        this.trueTurnEvent = trueTurnEvent;
        this.falseTurnEvent = falseTurnEvent;
        this.counterCondition = counterCondition;
    }

    public Decision(CounterCondition counterCondition) {
        super("not a user decision");
        this.counterCondition = counterCondition;
    }

    public void setTrueTurnEvent(TurnEvent trueTurnEvent) {
        this.trueTurnEvent = trueTurnEvent;
    }

    public void setFalseTurnEvent(TurnEvent falseTurnEvent) {
        this.falseTurnEvent = falseTurnEvent;
    }

    @Override
    public TurnEvent getNext(boolean response) {


        if(!requiresHumanInteraction())
        {
             response = evaluate();
        }

        if(response)
        {
            return this.trueTurnEvent;
        }  else {
            return this.falseTurnEvent;
        }




    }

    private boolean evaluate() {
        if(counterCondition != null)
        {
            return counterCondition.checkCondition();
        }
        return false;
    }

    public boolean requiresHumanInteraction() {
         return counterCondition == null;
    }
}




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