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

This page was automatically generated by Maven