-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameplay.java
More file actions
71 lines (54 loc) · 2.03 KB
/
Gameplay.java
File metadata and controls
71 lines (54 loc) · 2.03 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
import java.util.*;
public class Gameplay{
static Random r = new Random();
//shot attempt formula
public static boolean shootBall(int shooter, int defender, int distance, PlayerCreation[] players){
PlayerCreation o = players[shooter];
PlayerCreation d = players[defender];
//sets min and max odds to 10% and 90%, regardless of stats
int base = 50 + (o.shooting * 4) - (d.block * 3) - (distance * 10);
if(base < 10){
base = 10;
}
if(base > 90){
base = 90;
}
int roll = r.nextInt(100);// 0 - 99
IO.println("Shot chance: " + base + "% (rolled " + roll + ")");
return roll < base;//if roll < base, attempt failed
}
//pass attempt formula
public static boolean passBall(int passer, int defender, int distance, int target,
PlayerCreation[] players){
PlayerCreation p = players[passer];
PlayerCreation d = players[defender];
//sets min and max odds to 10% and 90%, regardless of stats
int base = 65 + (p.passing * 3) - (d.steal * 4) - (distance * 5);
if(base < 10){
base = 10;
}
if(base > 90){
base = 90;
}
int roll = r.nextInt(100);// 0 - 99
IO.println("Pass chance: " + base + "% (rolled " + roll + ")");
return roll < base;//if roll < base, attempt failed
}
//dribble attempt formula
public static boolean dribbleBall(int dribbler, int defender, int distance,
PlayerCreation[] players){
PlayerCreation o = players[dribbler];
PlayerCreation d = players[defender];
//sets min and max odds to 10% and 90%, regardless of stats
int base = 60 + (o.dribbling * 4) - (d.speed * 4);
if(base < 10){
base = 10;
}
if(base > 90){
base = 90;
}
int roll = r.nextInt(100);// 0 - 99
IO.println("Dribble chance: " + base + "% (rolled " + roll + ")");
return roll < base;//if roll < base, attempt failed
}
}