JavaScript
function Ammo(damage, name) {
this.damage = damage;
this.name = name;
}
var ammo = {
f556: new Ammo(80, '5.56'),
t308: new Ammo(300, '.308'),
n9mm: new Ammo(80, '9mm'),
f45: new Ammo(120, '45acp'),
s76239: new Ammo(150, '7.62x39'),
t22: new Ammo(15, '.22'),
t300win: new Ammo(600, '300win'),
t3006: new Ammo(400, '30-06'),
s76254: new Ammo(400, '7.62x54')
};
function Guns(accuracy, damage, speed, capacity, ammo, range, name) {
this.accuracy = accuracy;
this.damage = damage;
this.speed = speed;
this.capacity = capacity;
this.ammo = ammo;
this.range = range;
this.name = name;
}
function RangedWeapon(accuracy, damage, speed, capacity, ammo, range, name) {
Guns.call(this, accuracy, damage, speed, capacity, ammo, range, name);
this.id = 0;
this.attachments = [];
this.upgrades = [];
}
RangedWeapon.prototype = Object.create(Guns.prototype);
RangedWeapon.prototype.attachmentAdd = function(attachment) {
this.attachments.push(attachment);
}
RangedWeapon.prototype.attachmentRemove = function(attachment) {
var index = this.attachments.indexOf(attachment);
this.attachments.splice(index, 1);
}
RangedWeapon.prototype.upgradeAdd = function(upgrade) {
this.upgrades.push(upgrade);
}
function Attachment(accuracy, damage, speed, capacity, ammo, range, name) {
Guns.call(accuracy, damage, speed, capacity, ammo, range, name);
}
Attachment.prototype = Object.create(Guns.prototype);
var rangedWeapons = {
mdr: new RangedWeapon(90, ammo.t308.damage, 80, 20, ammo.t308, 400, 'mdr'),
tavor: new RangedWeapon(70, ammo.f556.damage, 90, ammo.f556, 200, 'tavor'),
ar15: new RangedWeapon(85, ammo.f556.damage, 80, 30, ammo.f556, 300, 'AR15'),
ar10: new RangedWeapon(85, ammo.t308.damage, 65, 20, ammo.t308, 400, 'AR10'),
akm: new RangedWeapon(60, ammo.s76239.damage, 70, 30, ammo.s76239, 300, 'AKM')
};
var attributes;
var skills;
var player = {
name: ' ',
level: 1,
health: 100,
hunger: 1000,
hydration: 350,
energy:...