-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerateData.php
143 lines (113 loc) · 4.05 KB
/
generateData.php
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<?php
/**
* Created by PhpStorm.
* User: Jayasurya
* Date: 2/18/2016
* Time: 10:08 PM
*/
ini_set("display_errors", "1");
error_reporting(E_ALL);
include($_SERVER['DOCUMENT_ROOT']."/util/php/include_classes.php");
$helper = new Helper();
$query = "SELECT * FROM matches;";
$params = null;
$result = $helper->queryDB($query,$params,false);
foreach($result as $match){
$slots = array(
array("red",1),
array("red",2),
array("red",3),
array("red",4),
array("red",5),
array("blue",1),
array("blue",2),
array("blue",3),
array("blue",4),
array("blue",5)
);
$numbers = range(1, 9);
shuffle($numbers);
$red = array_slice($numbers,0,5);
shuffle($numbers);
$blue = array_slice($numbers,0,5);
$defenses = array_merge($red,$blue);
$query = "INSERT IGNORE INTO matchdefenses(matchID,side,slot,defenseID) VALUES(:matchID,:side,:slot,:defenseID)";
foreach($slots as $ind => $slot){
$params = array(
":matchID" => $match['id'],
":side" => $slot[0],
":slot" => $slot[1],
":defenseID" => $defenses[$ind]
);
$helper->queryDB($query,$params,true);
}
$query = "SELECT * FROM teammatches WHERE matchID = :matchID;";
$params = array(":matchID" => $match['id']);
$result2 = $helper->queryDB($query,$params,false);
$teleAuto = ['tele','auto'];
$names = $helper->getScouters();
foreach($result2 as $teamMatch){
$name = array_rand($names);
$query = "UPDATE teamMatches SET scouterName = :scouterName WHERE id = :id";
$params = array(":scouterName" => $names[$name], ":id" => $teamMatch['id']);
$result = $helper->queryDB($query,$params,true);
$teamMatchID = $teamMatch['id'];
for($i = 0;$i<=rand(1,12);$i++){
$query = "INSERT INTO matchFeeds(teamMatchID,orderID,`mode`,zoneID)
VALUES(:teamMatchID,:orderID,:mode,:zone)";
$params = array(
":teamMatchID" => $teamMatchID,
":orderID" => 1,
":mode" => $teleAuto[array_rand($teleAuto)],
":zone" => array_rand([1,2,3,4,5,6,7]) + 1
);
var_dump($params);
$helper->queryDB($query,$params,false);
}
for($i = 0;$i<=rand(1,12);$i++){
$query = "INSERT INTO matchBreaches(teamMatchID,orderID,`mode`,startZone,defenseID,endZone,fail)
VALUES(:teamMatchID,:orderID,:mode,
:startZone
,:defenseID,
:endZone,:fail)";
$params = array(
":teamMatchID" => $teamMatchID,
":orderID" => 1,
":mode" => $teleAuto[array_rand($teleAuto)],
":startZone" => rand(1,7),
":defenseID" => $defenses[array_rand($defenses)],
":endZone" => rand(1,7),
":fail" => rand(0,1)
);
var_dump($params);
$helper->queryDB($query,$params,false);
}
for($i = 0;$i<=rand(1,12);$i++){
$query = "INSERT INTO matchShoots(teamMatchID,orderID,`mode`,coordX,coordY,highLow,scoreMiss)
VALUES(:teamMatchID,:orderID,:mode,:coordX,:coordY,:highLow,:scoreMiss)";
$params = array(
":teamMatchID" => $teamMatchID,
":orderID" => 1,
":mode" => $teleAuto[array_rand($teleAuto)],
":coordX" => rand(0,$helper::HALF_FIELD_LENGTH_INCHES),
":coordY" => rand(0,$helper::HALF_FIELD_HEIGHT_INCHES),
":highLow" => rand(0,1),
":scoreMiss" => rand(0,1)
);
$helper->queryDB($query,$params,false);
}
$query = "INSERT INTO matchClimbs(teamMatchID, `mode`,batterReached,duration,defensiveRating,offensiveRating,success)
VALUES(:teamMatchID,:mode,:batterReached,:duration,:defensiveRating,:offensiveRating,:success)";
$params = array(
":teamMatchID" => $teamMatchID,
":mode" => "tele",
":batterReached" => rand(0,1),
":duration" => rand(0,20),
":defensiveRating" => rand(1,10),
":offensiveRating" => rand(1,10),
":success" => rand(0,1)
);
$helper->queryDB($query,$params,false);
}
echo "done";
}