-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdanger.js
32 lines (30 loc) · 1.18 KB
/
danger.js
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
include('chips');
include('item');
include('math.js');
include('array.js');
include('game-state.js');
/**
* averageDamageOnCell : Cell -> LeekState -> Int
*/
function averageDmgFromLeekOnCell(@cell) { return function(@leek) {
var pos = leek[POS];
var dist = getCellDistance(cell, pos) + (lineOfSight(cell, pos) ? 0 : 2) - leek[MP];
var dmgMultiplier = (100 + leek[STR]) / 100;
var poiMultiplier = (100 + leek[MAG]) / 100;
var critMultiplier = 1 + 0.4 * (leek[AGI] / 1000);
var dangerousItems =@ aFilter(lookup(cAttaques))(leek[CHIPS]);
dangerousItems += leek[UNEQ];
var eq = leek[EQ];
if (eq !== null) { push(dangerousItems, eq); }
dangerousItems =@ aFilter(compose(inferior(dist))(lookup(ITEM_MAX_RANGE)))(dangerousItems);
var dmgAvg = defaultDiv(0)(sum(daMap(lookup(ITEM_DMG_TP))(dangerousItems)))(count(dangerousItems));
return dmgAvg * dmgMultiplier * critMultiplier * leek[TP];
};}
/**
* averageDmgFromLeeksOnCell : (LeekState -> Bool) -> Cell -> Array LeekState -> Int
*/
function averageDmgFromLeeksOnCell(@p) { return function(@cell) { return function(@leeks) {
return arrayFoldLeft(leeks, function(@acc, @l) {
return acc + (p(l) ? averageDmgFromLeekOnCell(cell)(l) : 0);
}, 0);
};};}