-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakeScores.js
More file actions
62 lines (57 loc) · 1.57 KB
/
makeScores.js
File metadata and controls
62 lines (57 loc) · 1.57 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
const toScore25 = require("./score.dummyFeed");
const pool = require("./server/modules/pool");
const fs = require("fs");
const squadinfo = require("./squadinfo");
for (toScore of squadinfo) {
// toScore.fullScore = 0;
let shooterAccuracy = getRandomInt(101);
for (i = 0; i < 25; i++) {
let thisScore = 0;
let currentShot = getRandomInt(101);
if (currentShot < shooterAccuracy) {
thisScore = 1;
}
console.log(
"(" +
toScore.squad_trap_id +
"," +
toScore.shooter_event_id +
"," +
thisScore +
"),"
);
// toScore.fullScore += thisScore;
}
}
for (toScore of squadinfo) {
console.log(toScore.fullScore);
}
function getRandomInt(max) {
return Math.floor(Math.random() * Math.floor(max));
}
//DO NOT DELETE
// function getSquadInfo() {
// pool
// .query(
// `
// SELECT
// "squad_trap"."id" as "squad_trap_id",
// "shooter_event"."id" as "shooter_event_id" FROM "squad_trap"
// JOIN "squad" ON "squad_trap"."squad_id" = "squad"."id"
// JOIN "event" ON "squad"."event_id" = "event"."id"
// JOIN "shooter_event" ON "event"."id" = "shooter_event"."event_id" AND "shooter_event"."squad_id" = "squad"."id"
// JOIN "shooter" ON "shooter_event"."shooter_id" = "shooter"."id"
// WHERE "event"."id" < 4
// ORDER BY "shooter_event"."id"
// ;
// `
// )
// .then(results => {
// console.log(results.rows);
// fs.writeFile("squadinfo.js", JSON.stringify(results.rows), err => {
// console.log("Error writing file", err);
// });
// });
// return;
// }
getSquadInfo();