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.Iterator;
11 import java.util.List;
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.KillStats;
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 KillChartStatsAdapter implements ValueListAdapter
27 {
28
29 /*** Creates a new instance of PlayerStatsAdapter */
30 public KillChartStatsAdapter()
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_NOTHING;
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 String killerPk = (String)info.getFilters().get("killerPk");
57
58 List list = new ArrayList();
59
60 int factor = 0;
61 long advantage = 0;
62
63 for( Iterator iter = StaticData.instance().getKills(info.getFilters()).iterator(); iter.hasNext();)
64 {
65 Kill kill = (Kill)iter.next();
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() ) || killerPk.equals( victim.getPk() ))
70 {
71 factor = killerPk.equals( killer.getPk() )?1:-1;
72 advantage += factor;
73 list.add( new KillStats(kill, advantage, factor) );
74 }
75
76 }
77
78 return new DefaultValueList(list, info);
79 }
80
81 }
This page was automatically generated by Maven