Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix enums and add image processor #9

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.imgscalr</groupId>
<artifactId>imgscalr-lib</artifactId>
<version>4.2</version>
</dependency>
<dependency>
<groupId>com.drewnoakes</groupId>
<artifactId>metadata-extractor</artifactId>
<version>2.18.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
Expand Down
38 changes: 19 additions & 19 deletions src/main/java/com/appdev/allin/DataInitializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ private void populatePlayers() {
new Player(
"Chris",
"Manon",
new Position[] {Position.Guard},
new Position[] {Position.GUARD},
30,
"6'5",
209,
Expand All @@ -46,7 +46,7 @@ private void populatePlayers() {
new Player(
"Nazir",
"Williams",
new Position[] {Position.Guard},
new Position[] {Position.GUARD},
1,
"6'3",
180,
Expand All @@ -57,7 +57,7 @@ private void populatePlayers() {
new Player(
"Isaiah",
"Gray",
new Position[] {Position.Guard},
new Position[] {Position.GUARD},
13,
"6'3",
219,
Expand All @@ -68,7 +68,7 @@ private void populatePlayers() {
new Player(
"Guy",
"Ragland Jr.",
new Position[] {Position.Forward},
new Position[] {Position.FORWARD},
21,
"6'8",
246,
Expand All @@ -79,7 +79,7 @@ private void populatePlayers() {
new Player(
"Sean",
"Hansen",
new Position[] {Position.Forward},
new Position[] {Position.FORWARD},
20,
"6'9",
246,
Expand All @@ -90,7 +90,7 @@ private void populatePlayers() {
new Player(
"Cooper",
"Noard",
new Position[] {Position.Guard},
new Position[] {Position.GUARD},
31,
"6'2",
190,
Expand All @@ -101,7 +101,7 @@ private void populatePlayers() {
new Player(
"AK",
"Okereke",
new Position[] {Position.Forward},
new Position[] {Position.FORWARD},
12,
"6'7",
235,
Expand All @@ -112,7 +112,7 @@ private void populatePlayers() {
new Player(
"Keller",
"Boothby",
new Position[] {Position.Forward},
new Position[] {Position.FORWARD},
15,
"6'7",
223,
Expand All @@ -123,7 +123,7 @@ private void populatePlayers() {
new Player(
"Ian",
"Imegwu",
new Position[] {Position.Forward},
new Position[] {Position.FORWARD},
2,
"6'9",
226,
Expand All @@ -134,7 +134,7 @@ private void populatePlayers() {
new Player(
"Jake",
"Fiegen",
new Position[] {Position.Guard},
new Position[] {Position.FORWARD},
22,
"6'4",
205,
Expand All @@ -145,7 +145,7 @@ private void populatePlayers() {
new Player(
"Jacob",
"Beccles",
new Position[] {Position.Guard},
new Position[] {Position.GUARD},
5,
"6'3",
178,
Expand All @@ -156,7 +156,7 @@ private void populatePlayers() {
new Player(
"Max",
"Watson",
new Position[] {Position.Guard},
new Position[] {Position.GUARD},
25,
"6'4",
195,
Expand All @@ -167,7 +167,7 @@ private void populatePlayers() {
new Player(
"Chris",
"Cain",
new Position[] {Position.Forward},
new Position[] {Position.FORWARD},
33,
"6'8",
223,
Expand All @@ -178,7 +178,7 @@ private void populatePlayers() {
new Player(
"Evan",
"Williams",
new Position[] {Position.Forward},
new Position[] {Position.FORWARD},
0,
"6'7",
220,
Expand All @@ -189,7 +189,7 @@ private void populatePlayers() {
new Player(
"Adam",
"Tsang Hinton",
new Position[] {Position.Guard},
new Position[] {Position.GUARD},
11,
"6'5",
213,
Expand All @@ -200,7 +200,7 @@ private void populatePlayers() {
new Player(
"DJ",
"Nix",
new Position[] {Position.Forward},
new Position[] {Position.FORWARD},
23,
"6'6",
216,
Expand All @@ -211,7 +211,7 @@ private void populatePlayers() {
new Player(
"Ryan",
"Kiachian",
new Position[] {Position.Forward, Position.Center},
new Position[] {Position.FORWARD, Position.CENTER},
3,
"6'10",
228,
Expand All @@ -222,7 +222,7 @@ private void populatePlayers() {
new Player(
"Darius",
"Ervin",
new Position[] {Position.Guard},
new Position[] {Position.GUARD},
14,
"5'8",
170,
Expand All @@ -233,7 +233,7 @@ private void populatePlayers() {
new Player(
"Hayden",
"Franson",
new Position[] {Position.Forward},
new Position[] {Position.FORWARD},
10,
"6'8",
218,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public Contract generateContract(User user, Player player, Double buyPrice, Rari
buyPrice,
rarity,
opposingTeam,
"src/main/resources/static/images/teams/" + opposingTeam + ".png",
"src/main/resources/static/images/teams/" + opposingTeam.toString().toLowerCase() + ".png",
event,
eventThreshold,
LocalDate.now(),
Expand Down
22 changes: 11 additions & 11 deletions src/main/java/com/appdev/allin/contract/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
import java.util.concurrent.ThreadLocalRandom;

public enum Event {
Points,
Minutes,
Field_Goals,
Three_Pointers,
Free_Throws,
Rebounds,
Assists,
Steals,
Blocks,
Turnovers,
Fouls;
POINTS,
MINUTES,
FIELD_GOALS,
THREE_POINTERS,
FREE_THROWS,
REBOUNDS,
ASSISTS,
STEALS,
BLOCKS,
TURNOVERS,
FOULS;

public static Event getRandomEvent() {
return values()[(int) (ThreadLocalRandom.current().nextDouble() * values().length)];
Expand Down
44 changes: 22 additions & 22 deletions src/main/java/com/appdev/allin/contract/OpposingTeam.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,28 @@
import java.util.concurrent.ThreadLocalRandom;

public enum OpposingTeam {
Lehigh,
Morrisville,
Fordham,
George,
Fullerton,
Utah,
Monmouth,
Lafayette,
Syracuse,
Siena,
Robert,
Colgate,
Baylor,
Columbia,
Penn,
Brown,
Wells,
Princeton,
Dartmouth,
Harvard,
Yale,
Ohio;
LEHIGH,
MORRISVILLE,
FORDHAM,
GEORGE,
FULLERTON,
UTAH,
MONMOUTH,
LAFAYETTE,
SYRACUSE,
SIENA,
ROBERT,
COLGATE,
BAYLOR,
COLUMBIA,
PENN,
BROWN,
WELLS,
PRINCETON,
DARTMOUTH,
HARVARD,
YALE,
OHIO;

public static OpposingTeam getRandomOpposingTeam() {
return values()[(int) (ThreadLocalRandom.current().nextDouble() * values().length)];
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/com/appdev/allin/contract/Rarity.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
import java.util.concurrent.ThreadLocalRandom;

public enum Rarity {
Common,
Rare,
Epic,
Legendary;
COMMON,
RARE,
EPIC,
LEGENDARY;

public static Rarity getRandomRarity() {
double random = ThreadLocalRandom.current().nextDouble();
if (random < 0.55) {
return Common;
return COMMON;
} else if (random < 0.8) {
return Rare;
return RARE;
} else if (random < 0.95) {
return Epic;
return EPIC;
} else {
return Legendary;
return LEGENDARY;
}
}
}
6 changes: 3 additions & 3 deletions src/main/java/com/appdev/allin/player/Position.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.appdev.allin.player;

public enum Position {
Guard,
Forward,
Center
GUARD,
FORWARD,
CENTER
}
22 changes: 11 additions & 11 deletions src/main/java/com/appdev/allin/playerData/PlayerData.java
Original file line number Diff line number Diff line change
Expand Up @@ -269,27 +269,27 @@ public String toString() {

public Integer getEvent(Event e) {
switch (e) {
case Points:
case POINTS:
return getPoints();
case Minutes:
case MINUTES:
return getMinutes();
case Field_Goals:
case FIELD_GOALS:
return getFieldGoals();
case Three_Pointers:
case THREE_POINTERS:
return getThreePointers();
case Free_Throws:
case FREE_THROWS:
return getFreeThrows();
case Rebounds:
case REBOUNDS:
return getRebounds();
case Assists:
case ASSISTS:
return getAssists();
case Steals:
case STEALS:
return getSteals();
case Blocks:
case BLOCKS:
return getBlocks();
case Turnovers:
case TURNOVERS:
return getTurnovers();
case Fouls:
case FOULS:
return getFouls();
default:
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,17 @@ public void populate() throws IOException {
int index = opposingTeamElement.get(0).text().indexOf("vs ");
String opposingTeam = opposingTeamElement.get(0).text().substring(index + 3);
if (opposingTeam.equals("SUNY Morrisville")) {
opposingTeam = "Morrisville";
opposingTeam = "MORRISVILLE";
} else if (opposingTeam.equals("George Mason")) {
opposingTeam = "George";
opposingTeam = "GEORGE";
} else if (opposingTeam.equals("Cal St. Fullerton")) {
opposingTeam = "Fullerton";
opposingTeam = "FULLERTON";
} else if (opposingTeam.equals("Utah Valley")) {
opposingTeam = "Utah";
opposingTeam = "UTAH";
} else if (opposingTeam.equals("Robert Morris")) {
opposingTeam = "Robert";
opposingTeam = "ROBERT";
} else if (opposingTeam.equals("Ohio St.")) {
opposingTeam = "Ohio";
opposingTeam = "OHIO";
}
Elements sections = doc.getElementsByTag("section");
// check which section whose aria label contains Cornell
Expand Down Expand Up @@ -93,7 +93,7 @@ public void populate() throws IOException {
new PlayerData(
player,
gameDate,
OpposingTeam.valueOf(opposingTeam),
OpposingTeam.valueOf(opposingTeam.toUpperCase()),
points,
minutes,
fieldGoalsMade,
Expand Down
Loading
Loading