RPGの成長システム
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 |
function p(a){ console.log(a); } function probabilityOf(d){ return Math.random() * 100 < d; } function main(){ var lvUpPercents = { str : 50, int : 50, tec : 50, agl : 50, def : 50, res : 50 } var character = { lv : 0, str : 0, int : 0, tec : 0, agl : 0, def : 0, res : 0 } p(character); for(var i=0; i<100; i++){ character.lv++; character.str += probabilityOf(lvUpPercents.str) ? 1 : 0; character.int += probabilityOf(lvUpPercents.int) ? 1 : 0; character.tec += probabilityOf(lvUpPercents.tec) ? 1 : 0; character.agl += probabilityOf(lvUpPercents.agl) ? 1 : 0; character.def += probabilityOf(lvUpPercents.def) ? 1 : 0; character.res += probabilityOf(lvUpPercents.res) ? 1 : 0; } p(character); } main(); |
1 2 |
{ lv: 0, str: 0, int: 0, tec: 0, agl: 0, def: 0, res: 0 } { lv: 100, str: 51, int: 53, tec: 51, agl: 49, def: 54, res: 48 } |