Android Open Source - umpire_buddy Game Stat Update Event






From Project

Back to project page umpire_buddy.

License

The source code is released under:

Apache License

If you think the Android project umpire_buddy 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.bluefairyapps.java.android.umpirebuddy.event.game;
//from   ww  w  .  ja va2  s.  c om
import java.util.HashMap;
import java.util.Set;

import com.bluefairyapps.java.android.umpirebuddy.enums.EventsEnum;
import com.bluefairyapps.java.android.umpirebuddy.enums.GameStatsEnum;
import com.bluefairyapps.java.android.umpirebuddy.event.Event;

/**
 * This {@link Event} is dispatched whenever a game stat is updated and carries a list of names
 * of the updated stats as well as their corresponding new values.
 * @author Matt Parish
 */
public class GameStatUpdateEvent extends Event {
  
  private HashMap<GameStatsEnum, Integer> mUpdatedStatsMap;
  
  /**
   * <b>public GameStatUpdateEvent()</b><br>
   * Constructor
   * @param updatedStats A primitive array of the game stats that have been updated.
   * @param newValues A primitive array of the new values.
   */
  public GameStatUpdateEvent(GameStatsEnum[] updatedStats, int[] newValues) {
    super(EventsEnum.EVENT_UPDATE_VIEWS);
    
    mUpdatedStatsMap = new HashMap<GameStatsEnum, Integer>();
    
    for(int i=0; i<updatedStats.length; i++) {
      
      mUpdatedStatsMap.put(updatedStats[i], newValues[i]);
    }
  }

  /**
   * Retrieve a list of names of the game stats that have been updated.
   * @return A {@link Set} of {@link GameStatsEnum} values.
   */
  public Set<GameStatsEnum> getStatsTypeList() {
    
    return mUpdatedStatsMap.keySet();
  }
  
  /**
   * Retrieve the new value of the specified game stat carried with this event.
   * @param statType The name of the stat to be retrieved.
   * @return The new value of the specified stat.
   */
  public int getStat(GameStatsEnum statType) {
    
    return mUpdatedStatsMap.get(statType).intValue();
  }
}




Java Source Code List

com.bluefairyapps.java.android.umpirebuddy.AboutActivity.java
com.bluefairyapps.java.android.umpirebuddy.MainActivity.java
com.bluefairyapps.java.android.umpirebuddy.enums.EventsEnum.java
com.bluefairyapps.java.android.umpirebuddy.enums.GameStatsEnum.java
com.bluefairyapps.java.android.umpirebuddy.event.EventListener.java
com.bluefairyapps.java.android.umpirebuddy.event.Event.java
com.bluefairyapps.java.android.umpirebuddy.event.game.GameStatUpdateEvent.java
com.bluefairyapps.java.android.umpirebuddy.systems.AudioSystem.java
com.bluefairyapps.java.android.umpirebuddy.systems.BaseballGameSystem.java
com.bluefairyapps.java.android.umpirebuddy.systems.EventManager.java
com.bluefairyapps.java.android.umpirebuddy.utils.BaseballRules.java
com.bluefairyapps.java.android.umpirebuddy.utils.GameStats.java