diff --git a/src/main/java/team5/smartTowns/rewards/RewardsRepositoryJDBC.java b/src/main/java/team5/smartTowns/rewards/RewardsRepositoryJDBC.java index bd35f10f54ed8d582a8adbcdf461659afccecb93..d2369267560413e19117f2b139d4793f6cabbca2 100644 --- a/src/main/java/team5/smartTowns/rewards/RewardsRepositoryJDBC.java +++ b/src/main/java/team5/smartTowns/rewards/RewardsRepositoryJDBC.java @@ -33,7 +33,7 @@ public class RewardsRepositoryJDBC implements RewardsRepository { private void setStickerMapper(){ stickerMapper = (rs, i) -> new Sticker( - rs.getInt("stickerID"), + rs.getInt("id"), rs.getString("name"), rs.getString("description"), rs.getInt("rarity"), diff --git a/src/main/java/team5/smartTowns/rewards/Sticker.java b/src/main/java/team5/smartTowns/rewards/Sticker.java index d9d5bc7259ee00dcc29d742f93c7b91714f80970..0dd4e825196a44caf724f1ce7be7e11d1200f040 100644 --- a/src/main/java/team5/smartTowns/rewards/Sticker.java +++ b/src/main/java/team5/smartTowns/rewards/Sticker.java @@ -30,7 +30,7 @@ public class Sticker extends Reward{ this.hasSticker = hasSticker; } public String getVisibility(){ - return hasSticker? "" : "grayedOut"; + return hasSticker ? "gotSticker" : "grayedSticker"; } } diff --git a/src/main/java/team5/smartTowns/users/User.java b/src/main/java/team5/smartTowns/users/User.java index c2637917df72ac942c4e029b160d2922512a1a73..632984b98d224718ed9a33c7e60766cdb687ff6f 100644 --- a/src/main/java/team5/smartTowns/users/User.java +++ b/src/main/java/team5/smartTowns/users/User.java @@ -15,16 +15,14 @@ public class User { String email; //Validation would be done by email, since they will have that String name; String imgPath; - int dragonProgress; Map<Badge, Integer> badgeProgress = new HashMap<>(); // Demonstrates the progress towards a specific badge (0-100) Map<Sticker, Boolean> hasStickers = new HashMap<>(); // True if User has sticker (key) - public User(int id, String email, String name, int dragonProgress) { + public User(int id, String email, String name) { this.id = id; this.email = email; this.name = name; - this.dragonProgress = dragonProgress; imgPath = findImagePath(); } diff --git a/src/main/java/team5/smartTowns/users/UserController.java b/src/main/java/team5/smartTowns/users/UserController.java index c85260db9a9bc3eb6799e40287c719a47719430f..58ce89287d678d74f512b0070db9fd968e9c1e6d 100644 --- a/src/main/java/team5/smartTowns/users/UserController.java +++ b/src/main/java/team5/smartTowns/users/UserController.java @@ -41,7 +41,6 @@ public class UserController { @GetMapping("/user/{id}") public ModelAndView getUserPage(@PathVariable int id) { ModelAndView mav = new ModelAndView("users/userProfile"); - List<Badge> badges = rewardsRepository.getAllBadges(); /*DEPRECATED FOR THE MOMENT*/ List<Sticker> allStickers = rewardsRepository.getAllStickers(); List<Pack> allPacks = rewardsRepository.getAllPacks(); @@ -77,7 +76,7 @@ public class UserController { for (Long stickerID : userStickers.keySet()) { //Finds and updates visibility of stickers based on what the user has allStickers.stream() .filter(sticker -> sticker.getId()==stickerID) - .findFirst().ifPresent(sticker -> sticker.setVisibility(userStickers.get(stickerID))); + .findFirst().ifPresent(sticker -> sticker.setVisibility(true)); } mav.addObject("stickers", allStickers); diff --git a/src/main/java/team5/smartTowns/users/UserRepositoryJDBC.java b/src/main/java/team5/smartTowns/users/UserRepositoryJDBC.java index 74e6ad0594e9fe6d08b4209799539187f306458e..214929ede1901587d23a5255b7ba5550e25b13a8 100644 --- a/src/main/java/team5/smartTowns/users/UserRepositoryJDBC.java +++ b/src/main/java/team5/smartTowns/users/UserRepositoryJDBC.java @@ -23,10 +23,9 @@ public class UserRepositoryJDBC implements UserRepository{ private void setUserMapper(){ userMapper = (rs, i) -> new User( - rs.getInt("userID"), + rs.getInt("id"), rs.getString("email"), - rs.getString("name"), - rs.getInt("dragonProgress") + rs.getString("name") ); } @@ -38,7 +37,7 @@ public class UserRepositoryJDBC implements UserRepository{ @Override public User getUser(int id){ - String sql= "SELECT * FROM users WHERE userID="+id; + String sql= "SELECT * FROM users WHERE id="+id; List<User> result = jdbc.query(sql, userMapper); return result.get(0); } @@ -51,6 +50,7 @@ public class UserRepositoryJDBC implements UserRepository{ for (Map<String, Object> result : query) { progress.put((Long)result.get("stickerID"), (boolean)result.get("hasSticker")); } + System.out.println(progress); return progress; } diff --git a/src/main/resources/data.sql b/src/main/resources/data.sql index 849bcc24a2eb1694d26c527b9f2509cf20686da8..abd792c293fcebb3720a57b942fd1bf7e2d1fca0 100644 --- a/src/main/resources/data.sql +++ b/src/main/resources/data.sql @@ -1,6 +1,6 @@ delete from users; -insert into users (email, name, dragonProgress) value ('hannah@gmail.com', 'Hannah', '90'); -insert into users (userID, email, name, dragonProgress) value ('2', 'nigel@gmail.com', 'Nigel', '40'); +insert into users (email, name) value ('hannah@gmail.com', 'Hannah'); +insert into users (email, name) value ('nigel@gmail.com', 'Nigel'); delete from trails; insert into trails ( Name) value ( 'Caerphilly Coffee Trail'); @@ -33,20 +33,9 @@ insert into locations ( locationName , locationEmail,locationDescription,locatio insert into locations (locationID, locationName , locationEmail,locationDescription,locationPlace, locationTrailID) value (19, 'The Esplanade','','Location description here','Penarth',0301); insert into locations (locationID, locationName , locationEmail,locationDescription,locationPlace, locationTrailID) value (20, 'The Old Swimming Baths','','Location description here','Penarth',0301); -delete from badges; -insert into badges (name, description, difficulty) value ('TownConnoisseur', 'You know the town very well!', '2'); -insert into badges (name, description, difficulty) value ('TownRegular', 'You visited the town 3 days in a row!', '1'); -insert into badges (name, description, difficulty) value ('TownMaster', 'You visited the town 7 days in a row!', '1'); -insert into badges (name, description, difficulty) value ('TownRegular', 'You visited the town 3 days in a row!', '1'); -insert into badges (name, description, difficulty) value ('TownRegular', 'You visited the town 3 days in a row!', '1'); - -delete from badgeprogress; -insert into badgeprogress (userID, badgeID, progress) value ('1', '1', '40'); -insert into badgeprogress (userID, badgeID, progress) value ('1', '2', '70'); -insert into badgeprogress (userID, badgeID, progress) value ('2', '2', '70'); delete from packs; -insert into packs (name, description) value ('Pack One Has a Kind of Long Name', 'This is pack 1'); +insert into packs (name, description) value ('Wales National Team', 'Pack of Welsh Football Players in the National Team'); insert into packs (name, description) value ('Pack2', 'This is pack 2'); insert into packs (name, description) value ('Pack3', 'This is pack 2'); insert into packs (name, description) value ('Pack3', 'This is pack 2'); @@ -57,25 +46,17 @@ insert into packs (name, description) value ('Pack3', 'This is pack 2'); delete from stickers; -insert into stickers (name, description, rarity, packID) value ('TownConnoisseur', 'You know the town very well!', '2', 1); -insert into stickers (name, description, rarity, packID) value ('TownRegular', 'You visited the town 3 days in a row!', '1', 1); -insert into stickers (name, description, rarity, packID) value ('TownMaster', 'You visited the town 7 days in a row!', '1', 1); -insert into stickers (name, description, rarity, packID) value ('TownMaster', 'You visited the town 7 days in a row!', '1', 1); -insert into stickers (name, description, rarity, packID) value ('TownMaster', 'You visited the town 7 days in a row!', '1', 1); -insert into stickers (name, description, rarity, packID) value ('TownMaster', 'You visited the town 7 days in a row!', '1', 1); -insert into stickers (name, description, rarity, packID) value ('TownMaster', 'You visited the town 7 days in a row!', '1', 1); -insert into stickers (name, description, rarity, packID) value ('TownMaster', 'You visited the town 7 days in a row!', '1', 1); -insert into stickers (name, description, rarity, packID) value ('TownMaster', 'You visited the town 7 days in a row!', '1', 1); -insert into stickers (name, description, rarity, packID) value ('TownMaster', 'You visited the town 7 days in a row!', '1', 1); +insert into stickers (name, description, rarity, packID) value ('wayne_hennessey', 'Wales Football Team Player', '2', 1); +insert into stickers (name, description, rarity, packID) value ('neco_williams', 'Wales Football Team Player', '2', 1); +insert into stickers (name, description, rarity, packID) value ('joe_morrell', 'Wales Football Team Player', '2', 1); +insert into stickers (name, description, rarity, packID) value ('ethan_ampadu', 'Wales Football Team Player', '2', 1); +insert into stickers (name, description, rarity, packID) value ('connor_roberts', 'Wales Football Team Player', '2', 1); insert into stickers (name, description, rarity, packID) value ('TownRegular', 'You visited the town 3 days in a row!', '1', 2); insert into stickers (name, description, rarity, packID) value ('TownRegular', 'You visited the town 3 days in a row!', '1', 2); delete from stickerprogress; insert into stickerprogress (userID, stickerID, hasSticker) value ('1', '1', true); +insert into stickerprogress (userID, stickerID, hasSticker) value ('1', '2', true); insert into stickerprogress (userID, stickerID, hasSticker) value ('1', '3', true); -insert into stickerprogress (userID, stickerID, hasSticker) value ('2', '2', true); - -delete from stickerprogress; -insert into stickerprogress (userID, stickerID, hasSticker) value ('1', '1', true); -insert into stickerprogress (userID, stickerID, hasSticker) value ('1', '3', true); +insert into stickerprogress (userID, stickerID, hasSticker) value ('1', '5', true); insert into stickerprogress (userID, stickerID, hasSticker) value ('2', '2', true); \ No newline at end of file diff --git a/src/main/resources/schema.sql b/src/main/resources/schema.sql index c57864fc188f24a2c5f52631b2854be64f695f07..77da33fcedcf677f6bab7bbd57d3ca1a37849cc2 100644 --- a/src/main/resources/schema.sql +++ b/src/main/resources/schema.sql @@ -17,54 +17,39 @@ create table if not exists locations locationTrailID varchar(128) ) engine=InnoDB; + drop table if exists users; +drop table if exists stickers; +drop table if exists packs; +drop table if exists stickerProgress; + create table if not exists users ( - userID bigint auto_increment primary key, + id bigint auto_increment primary key, email varchar(128), - name varchar(128), - dragonProgress int + name varchar(30) ) engine=InnoDB; -drop table if exists badges; -create table if not exists badges -( - badgeID bigint auto_increment primary key, - name varchar(128), - description varchar(128), - difficulty bigint -) engine=InnoDB; -drop table if exists stickers; -drop table if exists packs; create table if not exists packs ( id bigint auto_increment primary key, - name varchar(128), - description varchar(128) - + name varchar(20), + description text ) engine=InnoDB; create table if not exists stickers ( - stickerID bigint auto_increment primary key, - name varchar(128), - description varchar(128), - rarity bigint, + id bigint auto_increment primary key, + name varchar(30), + description text, + rarity tinyint, packID bigint, FOREIGN KEY (packID) REFERENCES packs(id) ON DELETE CASCADE ON UPDATE RESTRICT ) engine=InnoDB; -drop table if exists badgeProgress; -create table if not exists badgeProgress -( - userID bigint, - badgeID bigint, - progress int /*0-100*/ -) engine=InnoDB; - create table if not exists stickerProgress ( userID bigint, diff --git a/src/main/resources/static/css/userProfile2.css b/src/main/resources/static/css/userProfile2.css index e6c3528e238d2f7bf83bb8dbdf9f44b22820373b..1f388ce4321cac226e53c602f574018c5c3ed126 100644 --- a/src/main/resources/static/css/userProfile2.css +++ b/src/main/resources/static/css/userProfile2.css @@ -62,9 +62,12 @@ body { height: 100svh; } -.grayedOut { +.grayedSticker { filter: grayscale(1); } +.gotSticker { + filter: drop-shadow(0 0 10px yellow); +} html { @@ -173,7 +176,7 @@ main { .progressionContainer { display: flex; flex-direction: column; - height: 14svh; + height: 18svh; & h1 { font-size: 4em; width: 100%; @@ -186,7 +189,7 @@ main { position: relative; margin-inline: auto; & .progImg { - height: 10svh; + height: 14svh; width: 16svh; } & .progImgFill { @@ -194,22 +197,20 @@ main { overflow: hidden; width: 50%; } - & .progImgOut { - position: absolute; - overflow: hidden; + & .progImgOutline { + opacity: 0.1; + filter: grayscale(1); } & .progText { - opacity: 0.5; + color: rgba(255, 255, 255, 0.5); + text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000; position: absolute; - display: flex; text-align: center; - align-items: center; - justify-content: center; - height: 10svh; + /*height: 14svh;*/ width: 16svh; - + left:50%; + transform: translate(-50%, 100%); font-size: 3em; - translate: 0 5%; } } @@ -294,4 +295,7 @@ and (min-device-width: 1000px) { display: none; } } + .progressionContainer { + height: 20svh; + } } \ No newline at end of file diff --git a/src/main/resources/static/images/rewards/stickers/1.png b/src/main/resources/static/images/rewards/stickers/1.png new file mode 100644 index 0000000000000000000000000000000000000000..82eda396931e573eb4885e99348a6da6af12dd3d Binary files /dev/null and b/src/main/resources/static/images/rewards/stickers/1.png differ diff --git a/src/main/resources/static/images/rewards/stickers/2.png b/src/main/resources/static/images/rewards/stickers/2.png new file mode 100644 index 0000000000000000000000000000000000000000..c3a83c4dc354c66e76318159bf406a82720c1a83 Binary files /dev/null and b/src/main/resources/static/images/rewards/stickers/2.png differ diff --git a/src/main/resources/static/images/rewards/stickers/3.png b/src/main/resources/static/images/rewards/stickers/3.png new file mode 100644 index 0000000000000000000000000000000000000000..197da770196d927d3321f17c6fa2b05846a3e589 Binary files /dev/null and b/src/main/resources/static/images/rewards/stickers/3.png differ diff --git a/src/main/resources/static/images/rewards/stickers/4.png b/src/main/resources/static/images/rewards/stickers/4.png new file mode 100644 index 0000000000000000000000000000000000000000..824de21bcd8a979419585b88f68b892337905285 Binary files /dev/null and b/src/main/resources/static/images/rewards/stickers/4.png differ diff --git a/src/main/resources/static/images/rewards/stickers/5.png b/src/main/resources/static/images/rewards/stickers/5.png new file mode 100644 index 0000000000000000000000000000000000000000..ea442315db144974ad10319936a3f66976b7fc7f Binary files /dev/null and b/src/main/resources/static/images/rewards/stickers/5.png differ diff --git a/src/main/resources/templates/users/userFrags.html b/src/main/resources/templates/users/userFrags.html index bd2a005aef4ad13ff88e9ff409a8876d46bfad69..dbeb8ee3334077ad47fe99b227b8a58205c18060 100644 --- a/src/main/resources/templates/users/userFrags.html +++ b/src/main/resources/templates/users/userFrags.html @@ -6,14 +6,14 @@ <h1 th:text="${selectedPack.getName()}"></h1> <div class="progImgContainer"> <div class="progImgFill" th:style="'width:'+ ${progress} + '%;'"> - <img th:src="@{/images/rewards/dragonFilled.png}" + <img th:src="@{'../' + ${selectedPack.getDisplayImg()}}" alt="Filled Dragon" id="FilledDragon" class="progImg"> </div> <div class="progText"> <p th:text="${progress} + '%'"></p> </div> <div class="progImgOutline"> - <img th:src="@{/images/rewards/dragonOutline.png}" + <img th:src="@{'../' + ${selectedPack.getDisplayImg()}}" alt="Outline Dragon" id="OutlineDragon" class="progImg"> </div> </div>