This repository was archived by the owner on Nov 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNPJsonGen
More file actions
162 lines (129 loc) · 4.81 KB
/
NPJsonGen
File metadata and controls
162 lines (129 loc) · 4.81 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
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
import java.util.Random;
import java.util.Scanner;
/*public class NPJsonGen {
public static void main(String[] args) {
Scanner inp = new Scanner(System.in);
Random rand = new Random();
// number of players
System.out.print("Number of players:");
int numPl = inp.nextInt();
System.out.println("Due to bugs, the number of players is defaulted to 8");
numPl = 8;
// total stars per player
System.out.print("Number of stars per player:");
int starPl = inp.nextInt();
//staring stars per player
System.out.print("Number of starting stars per player:");
int startStarPl = inp.nextInt() ;
LocRet pos = new LocRet(numPl);
NPstar star1 = new NPstar();
double starx;
double stary;
double radius;
int starnum = 1;
int arrayAdd = 0;
ScaleCalc scaler = new ScaleCalc();
int res;
//Home Star positions
/*double posxH = rand.nextDouble() + (double) rand.nextInt(10,30);
double posyH = rand.nextDouble() + (double) rand.nextInt((int)(posxH/2));
pos.LocIn(posxH,posyH);*/
// todo change from point, point to length, angle
double radCen = rand.nextDouble() + (double) rand.nextInt(10,30);
CircleHelp home = new CircleHelp();
home.setRadiusLY(radCen);
double[] point = home.point(rand.nextInt(44));
double posxH = point[0];
double posyH = point[1];
pos.LocIn(posxH,posyH);
String[] homeArray;
homeArray = new String[8];
for(int num = 1; num<9; num++){
star1.NPcap(starnum, pos.LocPlX(num), pos.LocPlY(num), num);
homeArray[arrayAdd] = star1.jsonret();
arrayAdd++;
starnum++;
}
arrayAdd = 0;
//code to generate Claimed star array
//Does not include Home star
CircleHelp claimed = new CircleHelp();
double[] point2;
String[] ownedArray;
ownedArray = new String[((startStarPl-1)*8)];
for(int i = 1; i < startStarPl; i++)
{
// todo change to radius, angle system
//starx = posxH + (rand.nextBoolean() ? (rand.nextDouble()/4) : -(rand.nextDouble()/4));
//stary = posyH + (rand.nextBoolean() ? (rand.nextDouble()/4) : -(rand.nextDouble()/4));
claimed.setRadius(rand.nextDouble(0.2));
point2 = claimed.point(rand.nextInt(359));
starx = point2[0];
stary = point2[1];
pos.LocIn(starx,stary);
res = rand.nextInt(5,50);
for(int num = 1; num < 9; num++)
{
star1.NPclaimed(starnum, pos.LocPlX(num), pos.LocPlY(num),res);
star1.setPuid(num,true);
ownedArray[arrayAdd] = star1.jsonret();
arrayAdd++;
starnum++;
}
}
arrayAdd = 0;
star1.setPuid(0,true);
//End code for claimed star array
//Code for unclaimed stars array
//Code to calculate number of indexes to create
int notCl = starPl - startStarPl;
String[] notClArray = new String[(notCl*8)];
//Creates new circle helper to make a new circle at 0,0
CircleHelp notCirc = new CircleHelp();
double[] point1;
//Repeat for every 8 stars
for(int i = 1; i <= notCl; i++)
{
//todo change to radius, angle method
/*double starx1 = rand.nextDouble() + (double) rand.nextInt(1,10);
double stary1;
try
{
stary1 = rand.nextDouble() + (double) rand.nextInt((int)(starx1/2));
}
catch (Exception e){
stary1 = rand.nextDouble();
}*/
//Randomly generates radius and angle from 0 degrees before returning the point at
//that spot
double radnotCirc = (double) rand.nextInt(2,30)+rand.nextDouble();
notCirc.setRadiusLY(radnotCirc);
point1 = notCirc.point(rand.nextInt());
starx = point1[0];
stary = point1[1];
//sets point to generate points
pos.LocIn(starx,stary);
for(int num = 1; num<9; num++)
{
star1.NPclaimed(starnum,pos.LocPlX(num),pos.LocPlY(num), 0, false);
notClArray[arrayAdd] = star1.jsonret();
arrayAdd++;
starnum++;
}
}
System.out.println("{\"stars\": [ ");
for(String i : homeArray)
{
System.out.println(i);
}
for (String i : ownedArray)
{
System.out.println(i);
}
for (String i : notClArray)
{
System.out.println(i);
}
System.out.println("]");
}
}*/