Comparing version 0.0.15 to 0.0.16
@@ -53,3 +53,3 @@ 'use strict'; | ||
this.units.forEach(function (unit) { | ||
if (!unit.dead) { | ||
if (!unit.dead && unit.spec.attack > 0) { | ||
var skills = unit.spec.skills || {}; | ||
@@ -73,2 +73,7 @@ var skillsMessage = skills.splash ? 'splash (' + skills.splash.range + ') ' : ''; | ||
}); | ||
this.units.forEach(function (unit) { | ||
if (unit.spec.defense === 0) unit.kill(); | ||
}); | ||
this.takeSplashDamages(splashDamages); | ||
@@ -123,2 +128,7 @@ this.takeNormalDamages(normalDamages); | ||
this.updateAliveStatus(); | ||
} | ||
}, { | ||
key: 'updateAliveStatus', | ||
value: function updateAliveStatus() { | ||
var unitsAlive = this.units.filter(function (unit) { | ||
@@ -125,0 +135,0 @@ return !unit.dead; |
@@ -7,3 +7,3 @@ { | ||
"name": "Headquarters", | ||
"desc": "The headquarters coordinate the development speed of your empire. The higher the level of the office, the quicker the other buildings will develop.", | ||
"desc": "The headquarters coordinate the development speed of your empire. The higher the level of the office and the faster the expansion of your Empire will be.", | ||
"feature": "Reduce the upgrade time for buildings", | ||
@@ -84,3 +84,3 @@ "drugs_cost": 400, | ||
"name": "Crack House", | ||
"desc": "A crack house is where your drug dealers produce DRUGS... slowly but surely", | ||
"desc": "No tattletale will see the upcoming Empire through the cracks. You can produce DRUGS without fear and at your own pace.", | ||
"production_type": "drugs", | ||
@@ -101,3 +101,3 @@ "production_rate": 0.002, | ||
"name": "Hydroponic Farm", | ||
"desc": "A good solution for producing more DRUGS without soil is to use the Hydroculture.", | ||
"desc": "Transform an abandoned building into a farm and produce more DRUGS while saving on water and energy.", | ||
"production_type": "drugs", | ||
@@ -118,3 +118,3 @@ "production_rate": 0.005, | ||
"name": "Meth Lab", | ||
"desc": "This building contains drug experts which produce DRUGS with a comfortable speed.", | ||
"desc": "This building is all White and it’s your way to honor the Crystal Meth King by producing more and more DRUGS at a comfortable speed.", | ||
"production_type": "drugs", | ||
@@ -135,3 +135,3 @@ "production_rate": 0.01, | ||
"name": "Cocina", | ||
"desc": "We call it 'LaCocina' or 'LaCuisine', it produces more DRUGS with a better speed.", | ||
"desc": "We call it 'LaCocina' or 'LaCuisine'. Add some salt, spices, sour, sugar to your DRUGS and it will be produced at a “Yes, Chef” speed.", | ||
"production_type": "drugs", | ||
@@ -182,3 +182,3 @@ "production_rate": 0.02, | ||
"name": "Ammunition Factory", | ||
"desc": "This is your first building to produce WEAPONS.", | ||
"desc": "This is the Ammunition shop that you’ve stolen and transformed into a factory to start a small production of WEAPONS.", | ||
"production_type": "weapons", | ||
@@ -199,3 +199,3 @@ "production_rate": 0.004, | ||
"name": "Weapon Factory", | ||
"desc": "Want to produce more WEAPONS? The solution may be the weapon factory", | ||
"desc": "No more only Ammunitions, it’s time to get to a bigger league by producing more WEAPONS in your factory.", | ||
"production_type": "weapons", | ||
@@ -216,3 +216,3 @@ "production_rate": 0.008, | ||
"name": "Smuggle", | ||
"desc": "Smuggling can be worth it and it produces more WEAPONS.", | ||
"desc": "Start your weapon business by smuggling them all over the place and to produces more WEAPONS.", | ||
"production_type": "weapons", | ||
@@ -233,3 +233,3 @@ "production_rate": 0.015, | ||
"name": "Black Market", | ||
"desc": "The black market is the good place to trade weapons, it produces WEAPONS.", | ||
"desc": "This market is a way for you to expand your business and to trade your stuff for even more WEAPONS. Buyers and resellers can’t bargain with you.", | ||
"production_type": "weapons", | ||
@@ -250,3 +250,3 @@ "production_rate": 0.025, | ||
"name": "3D Metal printing", | ||
"desc": "This is the ultimate way to produce WEAPONS fast.", | ||
"desc": "You are not like any other Drug Lords, you are always after new technology and you know this is the revolution to build WEAPONS at a light speed in your backyard.", | ||
"production_type": "weapons", | ||
@@ -267,3 +267,3 @@ "production_rate": 0.05, | ||
"name": "Weapon Storage", | ||
"desc": "This building helps you to stock more WEAPONS and keep them safe from enemies.", | ||
"desc": "This building helps you to stock more WEAPONS and keep them safe from enemies.", | ||
"drugs_cost": 1000, | ||
@@ -282,3 +282,3 @@ "weapons_cost": 1000, | ||
"name": "Traditional Distillery", | ||
"desc": "This is your first building to produce ALCOHOLS.", | ||
"desc": "This building is the start of your homemade ALCOHOL production", | ||
"production_type": "alcohol", | ||
@@ -299,3 +299,3 @@ "production_rate": 0.004, | ||
"name": "Bar", | ||
"desc": "Want to produce more ALCOHOLS? The solution may be the bar", | ||
"desc": "The best way to live in an addiction denial is to own a bar and to cut customer consumption with wather to produce more ALCOHOL. ", | ||
"production_type": "alcohol", | ||
@@ -316,3 +316,3 @@ "production_rate": 0.008, | ||
"name": "Brewery", | ||
"desc": "Smuggling can be worth it and it produces more ALCOHOLS.", | ||
"desc": "According to chemistry, ALCOHOL is a solution, then the Brewery is producing more solutions at a good pace.", | ||
"production_type": "alcohol", | ||
@@ -333,3 +333,3 @@ "production_rate": 0.015, | ||
"name": "Castle", | ||
"desc": "The Castle produces ALCOHOLS by transforming grapes into wine.", | ||
"desc": "The Castle produces ALCOHOL by transforming grapes into wine.", | ||
"production_type": "alcohol", | ||
@@ -350,3 +350,3 @@ "production_rate": 0.025, | ||
"name": "Industrial Distillery", | ||
"desc": "This is the ultimate way to produce faster ALCOHOLS .", | ||
"desc": "The ultimate way to produce ALCOHOL that could fill your water fountain, your bathtub, your swimming pool and your pond in a blink of an eye.", | ||
"production_type": "alcohol", | ||
@@ -367,3 +367,3 @@ "production_rate": 0.05, | ||
"name": "Alcohol Silo", | ||
"desc": "This building helps you to stock more ALCOHOLS and keep them safe from enemies.", | ||
"desc": "This building helps you to stock more ALCOHOL and keep them safe from enemies.", | ||
"drugs_cost": 1000, | ||
@@ -370,0 +370,0 @@ "weapons_cost": 1000, |
@@ -40,2 +40,4 @@ 'use strict'; | ||
var targetArmy = new _army2.default(this.targetUnits, 'target', this.log); | ||
attackerArmy.updateAliveStatus(); | ||
targetArmy.updateAliveStatus(); | ||
var round = 0; | ||
@@ -42,0 +44,0 @@ |
@@ -42,7 +42,12 @@ 'use strict'; | ||
} else { | ||
this.log.add('[' + this.name + '] ' + this.key + ' (' + this.i + ') is dead'); | ||
this.health = 0; | ||
this.dead = true; | ||
this.kill(); | ||
} | ||
} | ||
}, { | ||
key: 'kill', | ||
value: function kill() { | ||
this.log.add('[' + this.name + '] ' + this.key + ' (' + this.i + ') is dead'); | ||
this.health = 0; | ||
this.dead = true; | ||
} | ||
}]); | ||
@@ -49,0 +54,0 @@ return Unit; |
{ | ||
"hobo": { | ||
"id": "hobo", | ||
"type": "Melee", | ||
"score": 6, | ||
"name": "Hobo", | ||
"desc": "He will fall into an ethylic coma after his first punch.", | ||
"feature": "At the end of the first round, this unit will die.", | ||
"attack": 2, | ||
"defense": 0, | ||
"speed": 13, | ||
"range": 1, | ||
"time": 57, | ||
"capacity": 10, | ||
"supply": 1, | ||
"priority": 30, | ||
"coeff": 0.54, | ||
"drugs_cost": 0, | ||
"weapons_cost": 0, | ||
"alcohols_cost": 400 | ||
}, | ||
"rowdy": { | ||
@@ -45,3 +65,3 @@ "id": "rowdy", | ||
"name": "Knifer", | ||
"desc": "He does not look dangerous... at first sight.", | ||
"desc": "He only speaks with his knives and he is nothing without them.", | ||
"attack": 12, | ||
@@ -65,3 +85,3 @@ "defense": 5, | ||
"name": "Gunman", | ||
"desc": "He's armed and ready to shoot.", | ||
"desc": "The legend says that he was born with a gun in his hand.", | ||
"attack": 25, | ||
@@ -80,2 +100,21 @@ "defense": 12, | ||
}, | ||
"spy": { | ||
"id": "spy", | ||
"type": "Melee", | ||
"score": 18, | ||
"name": "Spy", | ||
"desc": "He can only gather informations but he does it at the speed of lightning.", | ||
"attack": 0, | ||
"defense": 1, | ||
"speed": 3, | ||
"range": 5, | ||
"time": 67, | ||
"capacity": 10, | ||
"supply": 0, | ||
"priority": 120, | ||
"coeff": 3.84, | ||
"drugs_cost": 100, | ||
"weapons_cost": 100, | ||
"alcohols_cost": 300 | ||
}, | ||
"sniper": { | ||
@@ -86,3 +125,3 @@ "id": "sniper", | ||
"name": "Sniper", | ||
"desc": "The Sniper provides a long range.", | ||
"desc": "He will protect his bros by hook or by crook.", | ||
"attack": 40, | ||
@@ -106,3 +145,3 @@ "defense": 8, | ||
"name": "Hitman", | ||
"desc": "His name isn't enought? He'll just do the job!", | ||
"desc": "He is meticulous, perfectionist and precise, he will never fail his job.", | ||
"attack": 30, | ||
@@ -126,9 +165,9 @@ "defense": 15, | ||
"name": "Ninja", | ||
"desc": "Particularly fast and powerful.", | ||
"desc": "Cold as a sashimi, powerful like a wasabi, faster than a sushi master.", | ||
"attack": 50, | ||
"defense": 20, | ||
"speed": 5, | ||
"speed": 6, | ||
"range": 5, | ||
"time": 67, | ||
"capacity": 250, | ||
"capacity": 150, | ||
"supply": 2, | ||
@@ -146,3 +185,3 @@ "priority": 70, | ||
"name": "Big Mama", | ||
"desc": "Big Mama has a Big defense.", | ||
"desc": "With her motherly instinct, she will protect her kids until death does you apart.", | ||
"attack": 12, | ||
@@ -166,3 +205,4 @@ "defense": 110, | ||
"name": "Bazooka Guy", | ||
"desc": "He owns a bazooka! Be careful with him.", | ||
"desc": "He would destroy a whole army as a sunday hobby.", | ||
"feature": "Splash Damage : Hit 5 enemies at once.", | ||
"attack": 145, | ||
@@ -191,3 +231,3 @@ "defense": 25, | ||
"name": "Mercenary", | ||
"desc": "Mercenaries are always freelancers but you won't regret to hire them.", | ||
"desc": "He is a freelancer that will only listen to money, but you won’t regret spending on him.", | ||
"attack": 120, | ||
@@ -194,0 +234,0 @@ "defense": 75, |
{ | ||
"name": "drugwars", | ||
"version": "0.0.15", | ||
"version": "0.0.16", | ||
"description": "A lightweight JavaScript library for DrugWars", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -22,3 +22,3 @@ import { orderBy } from 'lodash'; | ||
this.units.forEach(unit => { | ||
if (!unit.dead) { | ||
if (!unit.dead && unit.spec.attack > 0) { | ||
const skills = unit.spec.skills || {}; | ||
@@ -39,2 +39,7 @@ const skillsMessage = skills.splash ? `splash (${skills.splash.range}) ` : ''; | ||
const normalDamages = damages.filter(damage => !damage[1] || !damage[1].splash); | ||
this.units.forEach(unit => { | ||
if (unit.spec.defense === 0) unit.kill(); | ||
}); | ||
this.takeSplashDamages(splashDamages); | ||
@@ -83,2 +88,6 @@ this.takeNormalDamages(normalDamages); | ||
this.updateAliveStatus(); | ||
} | ||
updateAliveStatus() { | ||
const unitsAlive = this.units.filter(unit => !unit.dead).length; | ||
@@ -85,0 +94,0 @@ if (!unitsAlive) { |
@@ -7,3 +7,3 @@ { | ||
"name": "Headquarters", | ||
"desc": "The headquarters coordinate the development speed of your empire. The higher the level of the office, the quicker the other buildings will develop.", | ||
"desc": "The headquarters coordinate the development speed of your empire. The higher the level of the office and the faster the expansion of your Empire will be.", | ||
"feature": "Reduce the upgrade time for buildings", | ||
@@ -84,3 +84,3 @@ "drugs_cost": 400, | ||
"name": "Crack House", | ||
"desc": "A crack house is where your drug dealers produce DRUGS... slowly but surely", | ||
"desc": "No tattletale will see the upcoming Empire through the cracks. You can produce DRUGS without fear and at your own pace.", | ||
"production_type": "drugs", | ||
@@ -101,3 +101,3 @@ "production_rate": 0.002, | ||
"name": "Hydroponic Farm", | ||
"desc": "A good solution for producing more DRUGS without soil is to use the Hydroculture.", | ||
"desc": "Transform an abandoned building into a farm and produce more DRUGS while saving on water and energy.", | ||
"production_type": "drugs", | ||
@@ -118,3 +118,3 @@ "production_rate": 0.005, | ||
"name": "Meth Lab", | ||
"desc": "This building contains drug experts which produce DRUGS with a comfortable speed.", | ||
"desc": "This building is all White and it’s your way to honor the Crystal Meth King by producing more and more DRUGS at a comfortable speed.", | ||
"production_type": "drugs", | ||
@@ -135,3 +135,3 @@ "production_rate": 0.01, | ||
"name": "Cocina", | ||
"desc": "We call it 'LaCocina' or 'LaCuisine', it produces more DRUGS with a better speed.", | ||
"desc": "We call it 'LaCocina' or 'LaCuisine'. Add some salt, spices, sour, sugar to your DRUGS and it will be produced at a “Yes, Chef” speed.", | ||
"production_type": "drugs", | ||
@@ -182,3 +182,3 @@ "production_rate": 0.02, | ||
"name": "Ammunition Factory", | ||
"desc": "This is your first building to produce WEAPONS.", | ||
"desc": "This is the Ammunition shop that you’ve stolen and transformed into a factory to start a small production of WEAPONS.", | ||
"production_type": "weapons", | ||
@@ -199,3 +199,3 @@ "production_rate": 0.004, | ||
"name": "Weapon Factory", | ||
"desc": "Want to produce more WEAPONS? The solution may be the weapon factory", | ||
"desc": "No more only Ammunitions, it’s time to get to a bigger league by producing more WEAPONS in your factory.", | ||
"production_type": "weapons", | ||
@@ -216,3 +216,3 @@ "production_rate": 0.008, | ||
"name": "Smuggle", | ||
"desc": "Smuggling can be worth it and it produces more WEAPONS.", | ||
"desc": "Start your weapon business by smuggling them all over the place and to produces more WEAPONS.", | ||
"production_type": "weapons", | ||
@@ -233,3 +233,3 @@ "production_rate": 0.015, | ||
"name": "Black Market", | ||
"desc": "The black market is the good place to trade weapons, it produces WEAPONS.", | ||
"desc": "This market is a way for you to expand your business and to trade your stuff for even more WEAPONS. Buyers and resellers can’t bargain with you.", | ||
"production_type": "weapons", | ||
@@ -250,3 +250,3 @@ "production_rate": 0.025, | ||
"name": "3D Metal printing", | ||
"desc": "This is the ultimate way to produce WEAPONS fast.", | ||
"desc": "You are not like any other Drug Lords, you are always after new technology and you know this is the revolution to build WEAPONS at a light speed in your backyard.", | ||
"production_type": "weapons", | ||
@@ -267,3 +267,3 @@ "production_rate": 0.05, | ||
"name": "Weapon Storage", | ||
"desc": "This building helps you to stock more WEAPONS and keep them safe from enemies.", | ||
"desc": "This building helps you to stock more WEAPONS and keep them safe from enemies.", | ||
"drugs_cost": 1000, | ||
@@ -282,3 +282,3 @@ "weapons_cost": 1000, | ||
"name": "Traditional Distillery", | ||
"desc": "This is your first building to produce ALCOHOLS.", | ||
"desc": "This building is the start of your homemade ALCOHOL production", | ||
"production_type": "alcohol", | ||
@@ -299,3 +299,3 @@ "production_rate": 0.004, | ||
"name": "Bar", | ||
"desc": "Want to produce more ALCOHOLS? The solution may be the bar", | ||
"desc": "The best way to live in an addiction denial is to own a bar and to cut customer consumption with wather to produce more ALCOHOL. ", | ||
"production_type": "alcohol", | ||
@@ -316,3 +316,3 @@ "production_rate": 0.008, | ||
"name": "Brewery", | ||
"desc": "Smuggling can be worth it and it produces more ALCOHOLS.", | ||
"desc": "According to chemistry, ALCOHOL is a solution, then the Brewery is producing more solutions at a good pace.", | ||
"production_type": "alcohol", | ||
@@ -333,3 +333,3 @@ "production_rate": 0.015, | ||
"name": "Castle", | ||
"desc": "The Castle produces ALCOHOLS by transforming grapes into wine.", | ||
"desc": "The Castle produces ALCOHOL by transforming grapes into wine.", | ||
"production_type": "alcohol", | ||
@@ -350,3 +350,3 @@ "production_rate": 0.025, | ||
"name": "Industrial Distillery", | ||
"desc": "This is the ultimate way to produce faster ALCOHOLS .", | ||
"desc": "The ultimate way to produce ALCOHOL that could fill your water fountain, your bathtub, your swimming pool and your pond in a blink of an eye.", | ||
"production_type": "alcohol", | ||
@@ -367,3 +367,3 @@ "production_rate": 0.05, | ||
"name": "Alcohol Silo", | ||
"desc": "This building helps you to stock more ALCOHOLS and keep them safe from enemies.", | ||
"desc": "This building helps you to stock more ALCOHOL and keep them safe from enemies.", | ||
"drugs_cost": 1000, | ||
@@ -370,0 +370,0 @@ "weapons_cost": 1000, |
@@ -15,2 +15,4 @@ import Army from './army'; | ||
const targetArmy = new Army(this.targetUnits, 'target', this.log); | ||
attackerArmy.updateAliveStatus(); | ||
targetArmy.updateAliveStatus(); | ||
let round = 0; | ||
@@ -17,0 +19,0 @@ |
@@ -22,7 +22,11 @@ import units from './units.json'; | ||
} else { | ||
this.log.add(`[${this.name}] ${this.key} (${this.i}) is dead`); | ||
this.health = 0; | ||
this.dead = true; | ||
this.kill(); | ||
} | ||
} | ||
kill() { | ||
this.log.add(`[${this.name}] ${this.key} (${this.i}) is dead`); | ||
this.health = 0; | ||
this.dead = true; | ||
} | ||
} |
{ | ||
"hobo": { | ||
"id": "hobo", | ||
"type": "Melee", | ||
"score": 6, | ||
"name": "Hobo", | ||
"desc": "He will fall into an ethylic coma after his first punch.", | ||
"feature": "At the end of the first round, this unit will die.", | ||
"attack": 2, | ||
"defense": 0, | ||
"speed": 13, | ||
"range": 1, | ||
"time": 57, | ||
"capacity": 10, | ||
"supply": 1, | ||
"priority": 30, | ||
"coeff": 0.54, | ||
"drugs_cost": 0, | ||
"weapons_cost": 0, | ||
"alcohols_cost": 400 | ||
}, | ||
"rowdy": { | ||
@@ -45,3 +65,3 @@ "id": "rowdy", | ||
"name": "Knifer", | ||
"desc": "He does not look dangerous... at first sight.", | ||
"desc": "He only speaks with his knives and he is nothing without them.", | ||
"attack": 12, | ||
@@ -65,3 +85,3 @@ "defense": 5, | ||
"name": "Gunman", | ||
"desc": "He's armed and ready to shoot.", | ||
"desc": "The legend says that he was born with a gun in his hand.", | ||
"attack": 25, | ||
@@ -80,2 +100,21 @@ "defense": 12, | ||
}, | ||
"spy": { | ||
"id": "spy", | ||
"type": "Melee", | ||
"score": 18, | ||
"name": "Spy", | ||
"desc": "He can only gather informations but he does it at the speed of lightning.", | ||
"attack": 0, | ||
"defense": 1, | ||
"speed": 3, | ||
"range": 5, | ||
"time": 67, | ||
"capacity": 10, | ||
"supply": 0, | ||
"priority": 120, | ||
"coeff": 3.84, | ||
"drugs_cost": 100, | ||
"weapons_cost": 100, | ||
"alcohols_cost": 300 | ||
}, | ||
"sniper": { | ||
@@ -86,3 +125,3 @@ "id": "sniper", | ||
"name": "Sniper", | ||
"desc": "The Sniper provides a long range.", | ||
"desc": "He will protect his bros by hook or by crook.", | ||
"attack": 40, | ||
@@ -106,3 +145,3 @@ "defense": 8, | ||
"name": "Hitman", | ||
"desc": "His name isn't enought? He'll just do the job!", | ||
"desc": "He is meticulous, perfectionist and precise, he will never fail his job.", | ||
"attack": 30, | ||
@@ -126,9 +165,9 @@ "defense": 15, | ||
"name": "Ninja", | ||
"desc": "Particularly fast and powerful.", | ||
"desc": "Cold as a sashimi, powerful like a wasabi, faster than a sushi master.", | ||
"attack": 50, | ||
"defense": 20, | ||
"speed": 5, | ||
"speed": 6, | ||
"range": 5, | ||
"time": 67, | ||
"capacity": 250, | ||
"capacity": 150, | ||
"supply": 2, | ||
@@ -146,3 +185,3 @@ "priority": 70, | ||
"name": "Big Mama", | ||
"desc": "Big Mama has a Big defense.", | ||
"desc": "With her motherly instinct, she will protect her kids until death does you apart.", | ||
"attack": 12, | ||
@@ -166,3 +205,4 @@ "defense": 110, | ||
"name": "Bazooka Guy", | ||
"desc": "He owns a bazooka! Be careful with him.", | ||
"desc": "He would destroy a whole army as a sunday hobby.", | ||
"feature": "Splash Damage : Hit 5 enemies at once.", | ||
"attack": 145, | ||
@@ -191,3 +231,3 @@ "defense": 25, | ||
"name": "Mercenary", | ||
"desc": "Mercenaries are always freelancers but you won't regret to hire them.", | ||
"desc": "He is a freelancer that will only listen to money, but you won’t regret spending on him.", | ||
"attack": 120, | ||
@@ -194,0 +234,0 @@ "defense": 75, |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
1939857
2329