-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgen.es
97 lines (87 loc) · 2.01 KB
/
gen.es
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import { sortedMapIds } from './map-exp'
// generate some random instance of structures (mainly for testing)
const getRandomArbitrary = (min, max) =>
Math.floor(Math.random() * (max - min)) + min
const getRandomInt = (minR, maxR) => {
const min = Math.ceil(minR)
const max = Math.floor(maxR)
return Math.floor(Math.random() * (max - min)) + min
}
const getOneOf = xs => xs[getRandomInt(0,xs.length)]
const genMapId = () => getOneOf(sortedMapIds)
const genTernary = () => getOneOf(['yes','no','maybe'])
const genRank = () => {
const ret = [];
['S','A','B','C','D','E'].map( x => {
if (getOneOf([true,false]))
ret.push(x)
})
return ret
}
const genExpValue = () => {
const type = getOneOf(['single','range'])
if (type === 'single')
return {
type,
value: getRandomArbitrary(1000,3000),
}
if (type === 'range') {
const min = getRandomArbitrary(1000,2000)
const max = getRandomArbitrary(min+100, 5000)
return { type, min, max }
}
}
const genBaseExp = () => {
const type = getOneOf(['standard','custom'])
if (type === 'standard') {
return {
type, mapId: genMapId(),
}
}
if (type === 'custom') {
return {
type, value: genExpValue(),
}
}
}
const genMethod = () => {
const type = getOneOf(['sortie','custom'])
if (type === 'sortie') {
return {
type,
flagship: genTernary(),
mvp: genTernary(),
rank: genRank(),
baseExp: genBaseExp(),
}
}
if (type === 'custom') {
return {
type, exp: genExpValue(),
}
}
}
const genStypes = () => {
const ret = []
for (let i=1; i<=22; ++i)
if (getOneOf([true,false]))
ret.push(i)
return ret
}
const genTemplateList = () => {
const len = getRandomInt(5,10+1)
const tl = []
for (let i=0; i<len; ++i)
tl.push( {
type: 'custom',
method: genMethod(),
enabled: getOneOf([true,false]),
stypes: genStypes(),
})
tl.push( {
type: 'main',
method: genMethod(),
})
return tl
}
export { genTemplateList }