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.Collection; 11 import java.util.HashMap; 12 import java.util.Iterator; 13 import java.util.Map; 14 15 import com.mlw.fps.model.business.dao.memmory.StaticData; 16 import com.mlw.fps.model.business.vo.Game; 17 import com.mlw.fps.model.business.vo.GameRecap; 18 import com.mlw.fps.model.business.vo.Kill; 19 import com.mlw.fps.model.business.vo.KillPlayer; 20 import com.mlw.fps.model.business.vo.Round; 21 import com.mlw.fps.model.business.vo.WeaponUsage; 22 import com.mlw.fps.model.business.vo.stats.MapStats; 23 import com.mlw.vlh.ValueList; 24 import com.mlw.vlh.ValueListAdapter; 25 import com.mlw.vlh.ValueListInfo; 26 import com.mlw.vlh.impl.DefaultValueList; 27 /*** 28 * 29 * @author Matthew Wilson 30 */ 31 public class MapStatsAdapter implements ValueListAdapter 32 { 33 34 /*** Creates a new instance of PlayerStatsAdapter */ 35 public MapStatsAdapter() 36 { 37 } 38 39 /*** This method tells the Service what still needs to be done on the 40 * Collection before returning the data. 41 * 42 * @return A bitwise or combination of DO_NOTHING, 43 * DO_SORT, DO_PAGE and DO_FILTER. For example:<br> 44 * <pre> 45 * public int getAdapterType(){ 46 * retuyrnDO_SORT && DO_PAGE; 47 * }</pre> 48 */ 49 public int getAdapterType() 50 { 51 return DO_SORT; 52 } 53 54 /*** Gets a ValueList 55 * @param info The <CODE>ValueList</CODE> information 56 * @param name The name of the <CODE>ValueList</CODE> 57 * @return The <CODE>ValueList</CODE> 58 */ 59 public ValueList getValueList(ValueListInfo info) 60 { 61 String killerPk = (String)info.getFilters().get("killerPk"); 62 63 Map stats = new HashMap(); 64 Collection collection = null; 65 66 for (Iterator iter = StaticData.instance().getGames(info.getFilters()).iterator(); iter.hasNext();) 67 { 68 Game game = (Game)iter.next(); 69 70 MapStats ms = (MapStats)stats.get(game.getMap().getPk()); 71 if (ms == null) 72 stats.put(game.getMap().getPk(), (ms = new MapStats(game.getMap()))); 73 ms.addUsage(); 74 for (Iterator rounds = game.getRounds().iterator(); rounds.hasNext();) 75 { 76 Round round = (Round)rounds.next(); 77 for (Iterator kills = round.getKills().iterator(); kills.hasNext();) 78 { 79 Kill kill = (Kill)kills.next(); 80 if ((collection = (Collection)info.getFilters().get("weapons")) == null 81 || collection.isEmpty() 82 || collection.contains(kill.getWeapon().getPk())) 83 { 84 if (killerPk == null || ((KillPlayer)kill.getPlayers().get("killer")).getPlayer().getPk().equals(killerPk)) 85 { 86 ms.getWeapon().addKills(1); 87 } 88 89 if (killerPk == null || ((KillPlayer)kill.getPlayers().get("victim")).getPlayer().getPk().equals(killerPk)) 90 { 91 ms.getWeapon().addDeaths(1); 92 } 93 } 94 } 95 } 96 97 for (Iterator iter2 = game.getRecaps().keySet().iterator(); iter2.hasNext();) 98 { 99 String key = (String)iter2.next(); 100 101 if (killerPk == null || key.equals(killerPk)) 102 { 103 GameRecap recap = (GameRecap)game.getRecaps().get(key); 104 for (Iterator iter3 = recap.getWeaponUsage().values().iterator(); iter3.hasNext();) 105 { 106 WeaponUsage usage = (WeaponUsage)iter3.next(); 107 108 //WeaponPk filter 109 String weaponPk = (String)info.getFilters().get("weaponPk"); 110 if (weaponPk == null || usage.getWeapon().getPk().equals(weaponPk)) 111 { 112 //Weapon Filter 113 if ((collection = (Collection)info.getFilters().get("weapons")) == null 114 || collection.isEmpty() 115 || collection.contains(usage.getWeapon().getPk())) 116 { 117 ms.getWeapon().add(usage); 118 } 119 } 120 } 121 } 122 } 123 } 124 125 return new DefaultValueList(new ArrayList(stats.values()), info); 126 } 127 128 }

This page was automatically generated by Maven