This repository was archived by the owner on Aug 30, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbasicCalculations.js
More file actions
70 lines (64 loc) · 1.38 KB
/
basicCalculations.js
File metadata and controls
70 lines (64 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/// -----------------
/// BasicCalculations
/// -----------------
//
// A few constants for various uses on LeekWars.
//
// Highest required level : 1
// Highest required cores : 1
/*
* Calculates the raw damages inflicted by an attack, taking Force into account
*
* Level : 1
* Cores : 1
*/
function calcPower(damage, force) {
return damage*(1+force/100);
}
/*
* Calculates the net damages inflicted by an attack, taking attacker's Force
* and defender's Shields into account
*
* Level : 1
* Cores : 1
*/
function calcDamage(damage, enemyAbsoluteShield, enemyRelativeShield) {
return max(0, (damage*(100-enemyRelativeShield)/100)-enemyAbsoluteShield);
}
/*
* Calculates the total amount of Absolute Shield, taking Agility into account
*
* Level : 1
* Cores : 1
*/
function calcAbsoluteShield(shield, agility) {
return shield*(1+agility/100);
}
/*
* Calculates the total amount of Relative Shield, taking Agility into account
*
* Level : 1
* Cores : 1
*/
function calcRelativeShield(shield, agility) {
return shield+agility/50;
}
/*
* Calculates the total amount of health restored by a heal, taking Agility
* into account
*
* Level : 1
* Cores : 1
*/
function calcHeal(damage, agility) {
return damage*(1+agility/100);
}
/*
* Calculates the mean damage inflicted by an attack
*
* Level : 1
* Cores : 1
*/
function meanDamages(min, max) {
return (min + max)/2;
}