1 /*
2 * WeaponStats.java
3 *
4 * Created on February 7, 2003, 10:02 AM
5 */
6
7 package com.mlw.fps.model.business.vo.stats;
8
9 import com.mlw.fps.model.business.vo.Player;
10 import com.mlw.fps.model.business.vo.Weapon;
11 import com.mlw.fps.model.business.vo.WeaponUsage;
12 /***
13 *
14 * @author Matthew Wilson
15 */
16 public class WeaponStats extends WeaponUsage
17 {
18 //private long usage;
19 private long total;
20
21 private Player killer;
22 private Player victim;
23
24 /*** Creates a new instance of WeaponStats
25 */
26 public WeaponStats()
27 {
28 }
29
30 /*** Creates a new instance of WeaponStats
31 */
32 public WeaponStats(Weapon weapon)
33 {
34 super(weapon);
35 this.total = 0;
36 }
37
38 /*** Creates a new instance of WeaponStats
39 */
40 public WeaponStats(Weapon weapon, Player victim)
41 {
42 this(weapon);
43 this.victim = victim;
44 }
45
46 /*** Creates a new instance of WeaponStats
47 */
48 public WeaponStats(Weapon weapon, Long total)
49 {
50 super(weapon);
51 this.total = (total==null)?0:total.longValue();
52 }
53
54 public Double getPercentage()
55 {
56 if( kills==0 )
57 {
58 return new Double(0);
59 }
60 return new Double( (double)kills/(double)total);
61 }
62
63 /*** Getter for property usage.
64 * @return Value of property usage.
65 */
66 public Long getKills()
67 {
68 return new Long(kills);
69 }
70
71 /*** Getter for property killer.
72 * @return Value of property killer.
73 */
74 public Player getKiller()
75 {
76 return this.killer;
77 }
78
79 /*** Setter for property killer.
80 * @param killer New value of property killer.
81 */
82 public void setKiller(Player killer)
83 {
84 this.killer = killer;
85 }
86
87 /*** Getter for property victim.
88 * @return Value of property victim.
89 */
90 public Player getVictim()
91 {
92 return this.victim;
93 }
94
95 /*** Setter for property victim.
96 * @param victim New value of property victim.
97 */
98 public void setVictim(Player victim)
99 {
100 this.victim = victim;
101 }
102
103 /*** Getter for property received.
104 * @return Value of property received.
105 */
106 public Long getDeaths()
107 {
108 return new Long(deaths);
109 }
110
111 public Long getAdvantage()
112 {
113 return new Long( kills-deaths );
114 }
115
116 public Double getKillToDeathRatio()
117 {
118 if( kills==0 && deaths==0 )
119 {
120 return new Double(0);
121 }
122 else if( deaths == 0 )
123 {
124 return new Double(Double.POSITIVE_INFINITY);
125 }
126 else
127 {
128 return new Double( (double)kills/(double)deaths );
129 }
130 }
131
132 public Double getAccuracy()
133 {
134 if( shots==0 )
135 {
136 return new Double(Double.NEGATIVE_INFINITY);
137 }
138 else if( hits == 0 )
139 {
140 return new Double(0);
141 }
142 else
143 {
144 return new Double( 100*((double)hits/(double)shots) );
145 }
146 }
147
148 public Double getEffeciency()
149 {
150 if( shots==0 )
151 {
152 return new Double(Double.NEGATIVE_INFINITY);
153 }
154 else if( hits==0 || damage == 0 )
155 {
156 return new Double(0);
157 }
158 else
159 {
160 return new Double( (double)damage/(double)hits );
161 }
162 }
163
164 public Long getAdvantagePercentage()
165 {
166 double total = kills+deaths;
167 if( total == 0 ) return new Long(0);
168
169 return new Long( (long)(kills/total*100) );
170 }
171
172 public Long getDisAdvantagePercentage()
173 {
174 double total = kills+deaths;
175 if( total == 0 ) return new Long(100);
176
177 return new Long( (long)(deaths/total*100) );
178 }
179
180 /*** Getter for property shots.
181 * @return Value of property shots.
182 */
183 public Long getShots()
184 {
185 return new Long(this.shots);
186 }
187
188 /*** Getter for property hits.
189 * @return Value of property hits.
190 */
191 public Long getHits()
192 {
193 return new Long(this.hits);
194 }
195
196 /*** Getter for property damage.
197 * @return Value of property damage.
198 */
199 public Long getDamage()
200 {
201 return new Long(this.damage);
202 }
203
204 }
This page was automatically generated by Maven