View Javadoc
1 /* 2 * PlayerStatsAdapter.java 3 * 4 * Created on April 24, 2003, 12:30 AM 5 */ 6 package com.mlw.fps.model.business.dao.memmory.vlh; 7 8 import java.util.ArrayList; 9 import java.util.HashMap; 10 import java.util.Iterator; 11 import java.util.Map; 12 13 import com.mlw.fps.model.business.dao.memmory.StaticData; 14 import com.mlw.fps.model.business.vo.Kill; 15 import com.mlw.fps.model.business.vo.KillPlayer; 16 import com.mlw.fps.model.business.vo.Player; 17 import com.mlw.fps.model.business.vo.stats.PlayerStats; 18 import com.mlw.vlh.ValueList; 19 import com.mlw.vlh.ValueListAdapter; 20 import com.mlw.vlh.ValueListInfo; 21 import com.mlw.vlh.impl.DefaultValueList; 22 /*** 23 * 24 * @author Matthew Wilson 25 */ 26 public class PlayerMatchupAdapter implements ValueListAdapter 27 { 28 29 /*** Creates a new instance of PlayerStatsAdapter */ 30 public PlayerMatchupAdapter() 31 { 32 } 33 34 /*** This method tells the Service what still needs to be done on the 35 * Collection before returning the data. 36 * 37 * @return A bitwise or combination of DO_NOTHING, 38 * DO_SORT, DO_PAGE and DO_FILTER. For example:<br> 39 * <pre> 40 * public int getAdapterType(){ 41 * retuyrnDO_SORT && DO_PAGE; 42 * }</pre> 43 */ 44 public int getAdapterType() 45 { 46 return DO_SORT; 47 } 48 49 /*** Gets a ValueList 50 * @param info The <CODE>ValueList</CODE> information 51 * @param name The name of the <CODE>ValueList</CODE> 52 * @return The <CODE>ValueList</CODE> 53 */ 54 public ValueList getValueList(ValueListInfo info) 55 { 56 Map stats = new HashMap(); 57 PlayerStats killerStats = null; 58 59 String killerPk = (String)info.getFilters().get("killerPk"); 60 61 for( Iterator iter = StaticData.instance().getKills(info.getFilters()).iterator(); iter.hasNext();) 62 { 63 Kill kill = (Kill)iter.next(); 64 Player killer = ((KillPlayer)kill.getPlayers().get("killer")).getPlayer(); 65 Player victim = ((KillPlayer)kill.getPlayers().get("victim")).getPlayer(); 66 67 if( killer.getPk().equals(killerPk) ) 68 {//Save a kill by the active player. 69 killerStats = (PlayerStats)stats.get( victim.getPk() ); 70 if( killerStats == null ) 71 { 72 //Store it in the map with the player thats not the active player (victim) as the key 73 stats.put(victim.getPk(), killerStats=new PlayerStats(victim, killer) ); 74 } 75 killerStats.getWeapon().addKills(1); 76 } 77 else if( victim.getPk().equals(killerPk) ) 78 {//Save a death to the active player 79 killerStats = (PlayerStats)stats.get( killer.getPk() ); 80 if( killerStats == null ) 81 { 82 //Store it in the map with the player thats not the active player (killer) as the key 83 stats.put(killer.getPk(), killerStats=new PlayerStats(killer, victim) ); 84 } 85 killerStats.getWeapon().addDeaths(1); 86 } 87 88 } 89 90 return new DefaultValueList(new ArrayList(stats.values()), info); 91 } 92 93 }

This page was automatically generated by Maven