Android Open Source - BoardGameDirector Counter Manager






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 ww  .j a v a  2  s.c o m*/
import java.util.HashMap;

/**
 * Created with IntelliJ IDEA.
 * User: pseudo
 * Date: 8/3/13
 * Time: 4:17 PM
 * To change this template use File | Settings | File Templates.
 */

public class CounterManager {


    static private CounterManager counterManager;

    private HashMap<String, Counter> counters;


    public static CounterManager getInstance()
    {
        if(counterManager == null)
        {
            counterManager = new CounterManager();
        }
        return counterManager;
    }


    public CounterManager()
    {
        counters = new HashMap<String,Counter>();
    }

    public Counter put(String key, Counter value) {
        return counters.put(key, value);
    }

    public void increment(String counterName)
    {
        counters.get(counterName).increment() ;
    }

    public void decrement(String counterName)
    {
        counters.get(counterName).decrement() ;
    }

    public void setCount(String counterName, int i)
    {
        counters.get(counterName).setCount(i);
    }

    public int getCount(String counterName)
    {
        return counters.get(counterName).getCount();
    }

    public void resetCounter(String counterName)
    {
        setCount(counterName, 0);
    }


    public void resetTurnCounters() {
        for(Counter counter : counters.values())
        {
            if(counter.isResetOnNewTurn())
            {
                counter.reset();
            }
        }
    }
}




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