View Javadoc
1 /* 2 * PlayerStats.java 3 * 4 * Created on February 7, 2003, 12:10 AM 5 */ 6 7 package com.mlw.fps.model.business.vo.stats; 8 9 import com.mlw.fps.model.business.vo.Player; 10 /*** 11 * 12 * @author Matthew Wilson 13 */ 14 public class PlayerStats 15 { 16 private Player player; 17 private long kills; 18 private long deaths; 19 private Double advantage; 20 21 /*** Holds value of property shots. */ 22 private long shots; 23 /*** Holds value of property hits. */ 24 private long hits; 25 /*** Holds value of property damage. */ 26 private long damage; 27 28 private long secondsAlive= 0; 29 private long secondsPlaying= 0; 30 31 /*** Holds value of property victim. 32 */ 33 private Player victim; 34 35 /*** Holds value of property weapon. */ 36 private WeaponStats weapon= new WeaponStats(); 37 38 /*** Creates a new instance of PlayerStats 39 */ 40 public PlayerStats(Player player) 41 { 42 this.player= player; 43 } 44 /*** Creates a new instance of PlayerStats 45 */ 46 public PlayerStats(Player player, Player victim) 47 { 48 this.player= player; 49 this.victim= victim; 50 } 51 52 /*** Getter for property player. 53 * @return Value of property player. 54 */ 55 public Player getPlayer() 56 { 57 return this.player; 58 } 59 60 /*** Getter for property kills. 61 * @return Value of property kills. 62 */ 63 public Long getKills() 64 { 65 return new Long(kills); 66 } 67 68 /*** Setter for property kills. 69 * @param kills New value of property kills. 70 */ 71 public void addKill() 72 { 73 this.kills++; 74 } 75 76 /*** Getter for property deaths. 77 * @return Value of property deaths. 78 */ 79 public Long getDeaths() 80 { 81 return new Long(deaths); 82 } 83 84 /*** Setter for property deaths. 85 * @param deaths New value of property deaths. 86 */ 87 public void addDeath() 88 { 89 this.deaths++; 90 } 91 92 /*** Getter for property advantage. 93 * @return Value of property advantage. 94 */ 95 public Double getAdvantage() 96 { 97 if (kills == 0 && deaths == 0) 98 return new Double(0); 99 if (deaths == 0) 100 return new Double(Double.POSITIVE_INFINITY); 101 return new Double((double)kills / (double)deaths); 102 } 103 104 public Double getAliveTimePercentage() 105 { 106 return new Double((double)secondsAlive/(double)secondsPlaying); 107 } 108 109 public Double getPower() 110 { 111 return new Double(weapon.getDamage().doubleValue()/weapon.getKills().doubleValue()); 112 } 113 114 /*** Getter for property victim. 115 * @return Value of property victim. 116 */ 117 public Player getVictim() 118 { 119 return this.victim; 120 } 121 122 /*** Setter for property victim. 123 * @param victim New value of property victim. 124 */ 125 public void setVictim(Player victim) 126 { 127 this.victim= victim; 128 } 129 130 /*** Getter for property weapon. 131 * @return Value of property weapon. 132 */ 133 public WeaponStats getWeapon() 134 { 135 return this.weapon; 136 } 137 /*** 138 * @return 139 */ 140 public Long getSecondsAlive() 141 { 142 return new Long(secondsAlive); 143 } 144 145 /*** 146 * @param l 147 */ 148 public void addSecondsAlive(long more) 149 { 150 secondsAlive += more; 151 } 152 153 public void addSecondsPlaying(long more) 154 { 155 secondsPlaying += more; 156 } 157 158 public Long getSecondsPlaying() 159 { 160 return new Long(secondsPlaying); 161 } 162 163 public Double getKillsPerMin() 164 { 165 long kills= (weapon == null || weapon.getKills() == null) ? this.kills : weapon.getKills().longValue(); 166 167 return new Double((double)kills / (((double)secondsAlive) / 60)); 168 } 169 170 public Double getDeathsPerMin() 171 { 172 long deaths= (weapon == null || weapon.getDeaths() == null) ? this.kills : weapon.getDeaths().longValue(); 173 174 return new Double((double)deaths / (((double)secondsAlive) / 60)); 175 } 176 }

This page was automatically generated by Maven