Skip to content

Commit

Permalink
Merge branch 'master' into yuzher-add-unlink
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/main/java/seedu/address/commons/core/Messages.java
#	src/main/java/seedu/address/logic/commands/CommandType.java
#	src/main/java/seedu/address/logic/parser/AddressBookParser.java
#	src/main/java/seedu/address/model/friend/Friend.java
#	src/test/java/seedu/address/logic/commands/friends/AddFriendCommandTest.java
#	src/test/java/seedu/address/logic/commands/games/AddGameCommandTest.java
  • Loading branch information
LZher385 committed Oct 22, 2021
2 parents 4dc432b + bc695e3 commit a74cb4f
Show file tree
Hide file tree
Showing 64 changed files with 1,696 additions and 1,070 deletions.
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ test {
finalizedBy jacocoTestReport
}

run {
enableAssertions = true
}

task coverage(type: JacocoReport) {
sourceDirectories.from files(sourceSets.main.allSource.srcDirs)
classDirectories.from files(sourceSets.main.output)
Expand Down
236 changes: 204 additions & 32 deletions docs/DeveloperGuide.md

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions docs/diagrams/ArchitectureSequenceDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ Participant ":Logic" as logic LOGIC_COLOR
Participant ":Model" as model MODEL_COLOR
Participant ":Storage" as storage STORAGE_COLOR

user -[USER_COLOR]> ui : "delete 1"
user -[USER_COLOR]> ui : "friend --delete Draco"
activate ui UI_COLOR

ui -[UI_COLOR]> logic : execute("delete 1")
ui -[UI_COLOR]> logic : execute("friend --delete Draco")
activate logic LOGIC_COLOR

logic -[LOGIC_COLOR]> model : deletePerson(p)
logic -[LOGIC_COLOR]> model : deleteFriend(friendToDeleteId)
activate model MODEL_COLOR

model -[MODEL_COLOR]-> logic
deactivate model

logic -[LOGIC_COLOR]> storage : saveAddressBook(addressBook)
logic -[LOGIC_COLOR]> storage : saveFriendsList(friendsList)
activate storage STORAGE_COLOR

storage -[STORAGE_COLOR]> storage : Save to file
Expand Down
44 changes: 29 additions & 15 deletions docs/diagrams/StorageClassDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,21 @@ skinparam classBackgroundColor STORAGE_COLOR

package Storage{

package "GamesList Storage" #F4F6F6 {
Interface GamesListStorage <<Interface>>
Class JsonGamesListStorage
Class JsonSerializableGamesList
Class JsonAdaptedGame
}

package "FriendsList Storage" #F4F6F6{
Interface FriendsListStorage <<Interface>>
Class JsonFriendsListStorage
Class JsonSerializableFriendsList
Class JsonAdaptedFriend
Class JsonAdaptedGameFriendLink
}

package "UserPrefs Storage" #F4F6F6{
Interface UserPrefsStorage <<Interface>>
Class JsonUserPrefsStorage
Expand All @@ -14,30 +29,29 @@ Class JsonUserPrefsStorage
Interface Storage <<Interface>>
Class StorageManager

package "AddressBook Storage" #F4F6F6{
Interface AddressBookStorage <<Interface>>
Class JsonAddressBookStorage
Class JsonSerializableAddressBook
Class JsonAdaptedPerson
Class JsonAdaptedTag
}

}

Class HiddenOutside #FFFFFF
HiddenOutside ..> Storage

StorageManager .up.|> Storage
StorageManager -up-> "1" GamesListStorage
StorageManager -up-> "1" FriendsListStorage
StorageManager -up-> "1" UserPrefsStorage
StorageManager -up-> "1" AddressBookStorage

Storage -left-|> UserPrefsStorage
Storage -right-|> AddressBookStorage
Storage -left-|> FriendsListStorage
Storage -left-|> GamesListStorage
Storage -right-|> UserPrefsStorage

JsonUserPrefsStorage .up.|> UserPrefsStorage
JsonAddressBookStorage .up.|> AddressBookStorage
JsonAddressBookStorage ..> JsonSerializableAddressBook
JsonSerializableAddressBook --> "*" JsonAdaptedPerson
JsonAdaptedPerson --> "*" JsonAdaptedTag

JsonFriendsListStorage .up.|> FriendsListStorage
JsonFriendsListStorage ..> JsonSerializableFriendsList
JsonSerializableFriendsList --> "*" JsonAdaptedFriend
JsonAdaptedFriend --> "*" JsonAdaptedGameFriendLink

JsonGamesListStorage .up.|> GamesListStorage
JsonGamesListStorage ..> JsonSerializableGamesList
JsonSerializableGamesList --> "*" JsonAdaptedGame

@enduml
29 changes: 21 additions & 8 deletions docs/diagrams/UiClassDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@ Class UiManager
Class MainWindow
Class HelpWindow
Class ResultDisplay
Class PersonListPanel
Class PersonCard
Class FriendListPanel
Class FriendCard
Class StatusBarFooter
Class CommandBox
Class GameListPanel
Class GameCard
Class GameMainCard
Class FriendMainCard
}

package Model <<Rectangle>> {
Expand All @@ -32,26 +36,35 @@ UiManager .left.|> Ui
UiManager -down-> "1" MainWindow
MainWindow *-down-> "1" CommandBox
MainWindow *-down-> "1" ResultDisplay
MainWindow *-down-> "1" PersonListPanel
MainWindow *-down-> "1" FriendListPanel
MainWindow *-down-> "1" GameListPanel
MainWindow *-down-> "1" StatusBarFooter
MainWindow *-down-> "1" GameMainCard
MainWindow *-down-> "1" FriendMainCard
MainWindow --> "0..1" HelpWindow

PersonListPanel -down-> "*" PersonCard
FriendListPanel -down-> "*" FriendCard
GameListPanel -down-> "*" GameCard

MainWindow -left-|> UiPart

ResultDisplay --|> UiPart
CommandBox --|> UiPart
PersonListPanel --|> UiPart
PersonCard --|> UiPart
FriendListPanel --|> UiPart
FriendCard --|> UiPart
GameListPanel --|> UiPart
GameCard --|> UiPart
FriendMainCard --|> UiPart
GameMainCard --|> UiPart
StatusBarFooter --|> UiPart
HelpWindow --|> UiPart

PersonCard ..> Model
FriendCard ..> Model
GameCard ..> Model
UiManager -right-> Logic
MainWindow -left-> Logic

PersonListPanel -[hidden]left- HelpWindow
FriendListPanel -[hidden]left- HelpWindow
HelpWindow -[hidden]left- CommandBox
CommandBox -[hidden]left- ResultDisplay
ResultDisplay -[hidden]left- StatusBarFooter
Expand Down
Binary file modified docs/images/ArchitectureSequenceDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/StorageClassDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/UiClassDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 6 additions & 3 deletions docs/team/kevin9foong.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ Given below are my contributions to the project.
* **New Features**
1. Project-wide refactoring of codebase to adapt AB3 to gitGud's needs.
- Refactored Persons and Tags to Friends and Games classes for team usage.
2. Add Friend functionality
3. Add Game functionality
4. Implemented Storage support for Friends and Games
2. Add Friend functionality
3. Edit Friend functionality
4. Add Game functionality
5. Implemented Storage support for Friends and Games

* **Testing**
1. Wrote unit/integration tests for storage, add friend and add game commands.
2. Wrote unit/integration tests(with Model) for Edit Friend functionality

* **Code contributed**: [RepoSense link](https://nus-cs2103-ay2122s1.github.io/tp-dashboard/?search=kevin9foong&sort=groupTitle&sortWithin=title&since=2021-09-17&timeframe=commit&mergegroup=&groupSelect=groupByRepos&breakdown=false)

Expand All @@ -37,6 +39,7 @@ Given below are my contributions to the project.
* Developer Guide:
1. Added the value proposition for gitGud.
2. Added use case for `add friend`.
3. Added documentation for Storage component (e.g. UML diagram, description etc).
* README:
1. Updated Github Actions build status badge to reflect status of gitGud team repository.
2. Updated description and organised layout of README.
Expand Down
89 changes: 59 additions & 30 deletions src/main/java/seedu/address/MainApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import java.io.IOException;
import java.nio.file.Path;
import java.util.List;
import java.util.Optional;
import java.util.logging.Logger;
import java.util.stream.Collectors;

import javafx.application.Application;
import javafx.stage.Stage;
Expand All @@ -23,7 +25,10 @@
import seedu.address.model.ReadOnlyGamesList;
import seedu.address.model.ReadOnlyUserPrefs;
import seedu.address.model.UserPrefs;
import seedu.address.model.util.SampleDataUtil;
import seedu.address.model.friend.Friend;
import seedu.address.model.game.Game;
import seedu.address.model.game.GameId;
import seedu.address.model.gamefriendlink.GameFriendLink;
import seedu.address.storage.FriendsListStorage;
import seedu.address.storage.GamesListStorage;
import seedu.address.storage.JsonFriendsListStorage;
Expand Down Expand Up @@ -80,52 +85,76 @@ public void init() throws Exception {
* or an empty friends list will be used instead if errors occur when reading {@code storage}'s friends list.
*/
private Model initModelManager(Storage storage, ReadOnlyUserPrefs userPrefs) {
// TODO: refine and update this method
// necessary to use empty friends list if the games list storage faces loading errors - since
// friends may have GameFriendLinks to games that do not exist due to failure loading.
ReadOnlyGamesList initialGameData;
ReadOnlyFriendsList initialFriendData;
assert storage != null;

ReadOnlyGamesList initialGamesList = loadInitialGamesList(storage);
ReadOnlyFriendsList initialFriendsList = loadInitialFriendsList(storage);

// verify valid Games exist for all GameFriendLinks in initial friends list.
if (!checkFriendsGamesExist(initialGamesList, initialFriendsList)) {
logger.info("Games linked to friends are not found in the games list. Loading an empty friends list.");
initialFriendsList = new FriendsList();
}

return new ModelManager(initialFriendsList, initialGamesList, userPrefs);
}

private ReadOnlyGamesList loadInitialGamesList(Storage storage) {
try {
Optional<ReadOnlyGamesList> readOnlyGamesList = storage.readGamesList();
if (readOnlyGamesList.isEmpty()) {
logger.info("Game data file not found. Will be starting with a empty friends and games list.");
initialGameData = new GamesList();
initialFriendData = new FriendsList();
Optional<ReadOnlyGamesList> loadedGamesList = storage.readGamesList();
if (loadedGamesList.isEmpty()) {
logger.info("Game data file not found. Loading an empty games list.");
return new GamesList();
} else {
initialGameData = readOnlyGamesList.get();
initialFriendData = loadInitialFriendData(storage);
return loadedGamesList.get();
}
} catch (DataConversionException e) {
logger.warning("Data file not in the correct format. Will be starting with an empty friends and "
+ "games list.");
initialGameData = new GamesList();
initialFriendData = new FriendsList();
logger.warning("Game data file not in the correct format. Loading an empty games list.");
return new GamesList();
} catch (IOException e) {
logger.warning("Problem while reading from the file. Will be starting with an empty friends and "
+ "games list.");
initialGameData = new GamesList();
initialFriendData = new FriendsList();
logger.info("Problem encountered reading game data file. Loading an empty games list.");
return new GamesList();
}

return new ModelManager(initialFriendData, initialGameData, userPrefs);
}

private ReadOnlyFriendsList loadInitialFriendData(Storage storage) {
private ReadOnlyFriendsList loadInitialFriendsList(Storage storage) {
try {
Optional<ReadOnlyFriendsList> readOnlyFriendsList = storage.readFriendsList();
if (readOnlyFriendsList.isEmpty()) {
logger.info("Data file not found. Will be starting with a sample friend's list");
Optional<ReadOnlyFriendsList> loadedFriendsList = storage.readFriendsList();
if (loadedFriendsList.isEmpty()) {
logger.info("Friend data file not found. Loading empty friends list.");
return new FriendsList();
}
return readOnlyFriendsList.orElseGet(SampleDataUtil::getSampleFriendsList);

return loadedFriendsList.get();
} catch (DataConversionException e) {
logger.warning("Data file not in the correct format. Will be starting with an empty friends list.");
logger.warning("Friend data file not in the correct format. Loading an empty friends list.");
return new FriendsList();
} catch (IOException e) {
logger.warning("Problem while reading from the file. Will be starting with an empty friends list.");
logger.info("Problem encountered reading friend data file. Loading an empty friends list.");
return new FriendsList();
}
}

/**
* Checks if all games linked as {@code GameFriendLink} in Friend stored in {@code friendsList} exist in the
* {@code gamesList}.
* @param gamesList list of games which should contain all games friends link to.
* @param friendsList list of friends to check if all games linked by Friend elements are stored in the gamesList.
* @return whether all games linked to by friends in the friends list exist in the games list.
*/
private boolean checkFriendsGamesExist(ReadOnlyGamesList gamesList, ReadOnlyFriendsList friendsList) {
List<GameId> includedGameIds = gamesList.getGamesList().stream().map(Game::getGameId)
.collect(Collectors.toList());
for (Friend friend : friendsList.getFriendsList()) {
for (GameFriendLink gameFriendLink : friend.getGameFriendLinks()) {
if (!includedGameIds.contains(gameFriendLink.getGameId())) {
return false;
}
}
}
return true;
}

private void initLogging(Config config) {
LogsCenter.init(config);
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/seedu/address/commons/core/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ public class Messages {
public static final String MESSAGE_UNKNOWN_FRIEND_FLAG = "Unknown friend flag";
public static final String MESSAGE_UNKNOWN_GAME_FLAG = "Unknown game flag";
public static final String MESSAGE_INVALID_COMMAND_FORMAT = "Invalid command format! \n%1$s";
public static final String MESSAGE_INVALID_PERSON_DISPLAYED_INDEX = "The person index provided is invalid";
public static final String MESSAGE_PERSONS_LISTED_OVERVIEW = "%1$d persons listed!";
public static final String MESSAGE_NONEXISTENT_FRIEND_ID = "That friend is not found with the current list!";
public static final String MESSAGE_NONEXISTENT_GAME_ID = "That game is not found with the current list!";
public static final String MESSAGE_INVALID_FRIEND_ID = "No friend found with the FRIEND_ID - %1$s";
public static final String MESSAGE_INVALID_GAME_ID = "No game found with the GAME_ID - %1$s";
public static final String MESSAGE_GAME_NOT_ASSOCIATED = "That friend is not currently associated with the game!";
public static final String MESSAGE_FRIEND_ID_NOT_FOUND = "No friend found with the FRIEND_ID - %1$s";
public static final String MESSAGE_GAME_ID_NOT_FOUND = "No game found with the GAME_ID - %1$s";

}
4 changes: 2 additions & 2 deletions src/main/java/seedu/address/logic/commands/CommandType.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package seedu.address.logic.commands;

public enum CommandType {
FRIEND_ADD, FRIEND_DELETE, FRIEND_GET, FRIEND_LIST, FRIEND_LINK, FRIEND_UNLINK, GAME_ADD, GAME_DELETE, GAME_GET,
GAME_LIST, HELP, EXIT, CLEAR
FRIEND_ADD, FRIEND_EDIT, FRIEND_ADD_GAME_SKILL, FRIEND_DELETE, FRIEND_GET, FRIEND_LIST, GAME_ADD, GAME_DELETE,
GAME_GET, GAME_LIST, HELP, EXIT, FRIEND_LINK, FRIEND_UNLINK, CLEAR
}
Loading

0 comments on commit a74cb4f

Please sign in to comment.