public boolean upgradeWeapon(String weapon) { Debug.debug(username + " upgrading his " + weapon); if (primaryWeapon.equals(weapon)) { Debug.stub("upgrading primary weapon (" + weapon + ")"); boolean success = subtractResourcesForWeaponUpgrade(weapon, primaryWeaponLevel); if (success) { primaryWeaponLevel++; Debug.guiMessage(username + " upgrades his " + weapon); return true; } else { return false; } } else if (secondaryWeapon.equals(weapon)) { boolean success = subtractResourcesForWeaponUpgrade(weapon, secondaryWeaponLevel); if (success) { secondaryWeaponLevel++; Debug.guiMessage(username + " upgrades his " + weapon); return true; } else { return false; } } else { Debug.warn(username + " tried to upgrade weapon '" + weapon + "', but doesn't have it."); return false; } }
public void damagePlayer(int hitpoints, AIConnection dealingPlayer) { if (health <= 0) { Debug.warn("Player is already dead."); return; } Debug.stub( "'" + this.username + "' received " + hitpoints + " damage from '" + dealingPlayer.username + "'!"); health -= hitpoints; if (!(dealingPlayer.username.equals(this.username))) { dealingPlayer.givePoints(hitpoints); // damaged user other than // self, award points } if (health <= 0) { Debug.game(this.username + " got killed by " + dealingPlayer.username); if (!(dealingPlayer.username.equals(this.username))) { dealingPlayer.givePoints(20); // 20 bonus points for killing // someone } score -= 40; health = 0; hasToPass = true; needsRespawn = true; } }