const WeaponModel = require("./WeaponModel"), { getMaxDamage, getDamage } =…
- User
const WeaponModel = require("./WeaponModel"), { getMaxDamage, getDamage } = require("./server");
class ShaftModel extends WeaponModel {
codeonData(socket, args) { if (this.battle === null || this.user === null) return; try { if (args[0] === "quick_shot_shaft" || args[0] === "fire") { const data = JSON.parse(args[1]); let damage = 0; if (args[0] === "quick_shot_shaft") { damage = getDamage(this.name, this.modification); this.battle.broadcast("shaft_quick_shot;" + this.user.nickname + ";" + args[1]); } if (args[0] === "fire") { damage = getMaxDamage(this.name, this.modification) / 100 * (100 - data.energy / 10); this.battle.broadcast("fire;" + this.user.nickname + ";" + args[1]); } if (data.targets.length === 0) return; const target = data.targets[0]; const killer = this.user; const user = this.battle.getUser(target.target_id || target.target.id); if (user) user.attack(killer, damage, socket.tank.garage.mounted_turret, user.team_type.toUpperCase(), this.battle.getFriendlyFire()); } } catch (e) { } }}
module.exports = ShaftModel; гже хдесь балон пушки
- Assistant
The code you have provided is a JavaScript class definition named "ShaftModel" that extends the "WeaponModel" class. It exports the "ShaftModel" class as a module.
Here's a breakdown of the code:
-
It imports the "WeaponModel" class from "./WeaponModel" and the functions "getMaxDamage" and "getDamage" from "./server".
-
The "ShaftModel" class definition starts and extends the "WeaponModel" class.
-
The "onData" method is defined, which handles the data received from the server.
-
Inside the "onData" method, there is a check for the battle and user existence. If either is null, the method returns early.
-
The method then parses the received data and checks the value of args[0] to determine the type of action being performed.
-
If args[0] is either "quick_shot_shaft" or "fire", it proceeds to calculate the damage based on the action type and the weapon name and modification.
-