Skip to content

Commit

Permalink
Merge pull request #81 from Isabella-L/DG-update
Browse files Browse the repository at this point in the history
UG update by Sicheng
  • Loading branch information
Isabella-L authored Oct 28, 2021
2 parents ba05501 + c4fc1fc commit 9ec35e7
Show file tree
Hide file tree
Showing 10 changed files with 110 additions and 76 deletions.
3 changes: 3 additions & 0 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@

# Developer Guide
* [Acknowledgements](#acknowledgements)
* [Design & Implementation](#design-&-implementation)

* [Acknoledgements](#acknowledgements)

Expand Down
58 changes: 43 additions & 15 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
# User Guide
* [Introduction](#introduction)
* [Quick Start](#quick-start)
* [Features](#features)
* [FAQ](#faq)
* [Command Summary](#command-summary)

## Introduction
## Introduction

{Give a product intro}
Typist is a CLI typing game.

## Quick Start

{Give steps to get started quickly}

1. Ensure that you have Java 11 or above installed.
1. Down the latest version of `Duke` from [here](http://link.to/duke).
1. Ensure that you have Java 11 or above installed.
2. Down the latest version of `Typist` from [here](http://link.to/duke).
3. Navigate to the folder containing the jar file and run `java -jar tp.jar`

## Features

Expand Down Expand Up @@ -43,6 +49,23 @@ Examples
* command example 2
<!-- -->

### Open Game: `game`
Start a typing game.
Format: `game GAME_MODE [-c]`
* SET_CONTENT `-c` is optional, it allows user to set input content before game starts.
* GAME_MODE
* `-w` for game in Word Limit Mode
* `-t` for game in Time Limit Mode
* For Time Limit Game:
* Format: `game -t TIME_LIMIT [-sn] [-c]`
* START_NOW `-sn` allows user to start the game immediately without the "ready to start?" prompt.
<!-- -->
Examples
* `game -t 30 -sn`
* `game -w -c`
<!-- -->


### View past records: `history`
View past game records.
Format: `history -g GAME_MODE [-n NUMBER_OF_RECORDS] [-h]`
Expand Down Expand Up @@ -99,18 +122,21 @@ Statistics of game is shown automatically after a game is finished.

## Example of usage:

>`new`
```
| Enter how many words you want the game to run:
```
>`12`
```
game -w
| Enter how many words you want the game to run:
5
| lorem ipsum is simply dummy
lorem ipsum is simply dummy
| Your progress:5/5
```
>`lorem ipsum is simply dummy`
```
Your progress:5/12
text of the printing and
game -t 30 -sn
| lorem ipsum is simply dummy text of the printing and
lorem ipsum is simply dummy text of the printing and
| typesetting imply dummy text of the printing and typesetting industry
typesetting imply dummy text of the printing and typesetting industry
| Timer's UP!
```
## FAQ

Expand All @@ -120,6 +146,8 @@ text of the printing and

## Command Summary

{Give a 'cheat sheet' of commands here}

* Add todo `todo n/TODO_NAME d/DEADLINE`
| Feature | Command |
| ------------- | ------------- |
| Start Word Limit Game| `game -w [-c]` |
| Start Time Limit Game | `game -t TIME_LIMIT [-sn] [-c]`
| Get History | `history -h`|
2 changes: 1 addition & 1 deletion seedu.typists.ui.TextUi.log
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Oct 28, 2021 1:00:57 AM seedu.typists.ui.SummaryUi setUpLog
Oct 28, 2021 3:08:47 AM seedu.typists.ui.SummaryUi setUpLog
INFO: Set up log in SummaryUi
2 changes: 1 addition & 1 deletion seedu.typists.ui.TextUi.log.1
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Oct 28, 2021 12:59:28 AM seedu.typists.ui.SummaryUi setUpLog
Oct 28, 2021 2:42:10 AM seedu.typists.ui.SummaryUi setUpLog
INFO: Set up log in SummaryUi
6 changes: 2 additions & 4 deletions src/main/java/seedu/typists/command/CommandFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ public class CommandFactory {

public Command getCommand(String commandType) {
switch (commandType) {
case "time":
return new TimeGameCommand();
case "word":
return new WordGameCommand();
case "game":
return new GameCommand();
case "content":
return new ContentCommand();
case "error":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,88 @@

import seedu.typists.exception.IncompleteCommandException;
import seedu.typists.exception.InvalidCommandException;
import seedu.typists.game.Game;
import seedu.typists.game.TimeModeGame;
import seedu.typists.game.WordLimitGame;

import java.util.ArrayList;

import static seedu.typists.Main.content;
import static seedu.typists.Main.uiBot;
import static seedu.typists.Main.LINE_LENGTH;


public class TimeGameCommand implements Command {
public class GameCommand implements Command {
private static final String TIME_SIGNIFIER = "-t";
private static final String WORD_SIGNIFIER = "-w";
private static final String START_SIGNIFIER = "-sn";
private static final String CONTENT_SIGNIFIER = "-c";

@Override
public void run(ArrayList<String> args) {
boolean startNow = getBoolean(args, START_SIGNIFIER);
boolean setContent = getBoolean(args, CONTENT_SIGNIFIER);

try {
int timeInSeconds = getTime(args, TIME_SIGNIFIER);
TimeModeGame game = createGame(timeInSeconds, startNow, setContent);
Game game = createGame(args, startNow, setContent);
game.runGame();
game.gameSummary();
} catch (IncompleteCommandException e) {
System.out.println("Please specify game type.");
} catch (NullPointerException e) {
//exit
}
}

public Game createGame(ArrayList<String> args, boolean startNow, boolean setContent)
throws IncompleteCommandException {
if (getBoolean(args, TIME_SIGNIFIER)) {
return createTimeLimitGame(args,startNow, setContent);
} else if (getBoolean(args, WORD_SIGNIFIER)) {
return createWordLimitGame(setContent);
} else {
throw new IncompleteCommandException();
}
}

public WordLimitGame createWordLimitGame(boolean setContent) {
uiBot.printKeyboard();
if (setContent) {
content.setContent();
}
return new WordLimitGame(content.getContent(), 5);
}

public TimeModeGame createTimeLimitGame(ArrayList<String> args, boolean isReady, boolean setContent) {
try {
int timeInSeconds = getTime(args, TIME_SIGNIFIER);
if (setContent) {
content.setContent();
}
return new TimeModeGame(timeInSeconds,content.getContent(), LINE_LENGTH, isReady);
} catch (InvalidCommandException e) {
System.out.println(
"Please enter time in multiple of 30 seconds.\n"
+ "e.g. time -t 30 "
+ "e.g. time -t 30 "
);
} catch (IncompleteCommandException | IndexOutOfBoundsException e) {
System.out.println(
"Please specify duration of the game using "
+ TIME_SIGNIFIER + "\n"
+ "e.g. time -t 60 "
+ TIME_SIGNIFIER + "\n"
+ "e.g. time -t 60 "
);
} catch (NumberFormatException e) {
System.out.println("Duration should be a number");
}
return null;
}

/** Determine whether the user command has the signifier. **/
public boolean getBoolean(ArrayList<String> args, String key) {
return args.contains(key);
}

public int getTime(ArrayList<String> args, String key) throws InvalidCommandException, IncompleteCommandException {
public int getTime(ArrayList<String> args, String key)
throws InvalidCommandException, IncompleteCommandException {
if (!args.contains(key)) {
throw new IncompleteCommandException();
}
Expand All @@ -56,11 +94,4 @@ public int getTime(ArrayList<String> args, String key) throws InvalidCommandExce
}
return time;
}

public TimeModeGame createGame(int timeInSeconds, boolean isReady, boolean setContent) {
if (setContent) {
content.setContent();
}
return new TimeModeGame(timeInSeconds,content.getContent(), LINE_LENGTH, isReady);
}
}
26 changes: 0 additions & 26 deletions src/main/java/seedu/typists/command/WordGameCommand.java

This file was deleted.

7 changes: 3 additions & 4 deletions src/main/java/seedu/typists/common/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,8 @@ public class Messages {
public static final String MESSAGE_WELCOME = "Welcome to Typist -- the ultimate cli typing game.";
public static final String MESSAGE_ACKNOWLEDGE = "Brought to you by -- AY2122S1-CS2113-T13-4.";
public static final String MESSAGE_HELP = "Manual:\n"
+ "content: set the content (or <-c> with game command)\n"
+ "word: start a new word game\n"
+ "time: start a new timer game <-t> to specify time <-sn> to start immediately\n"
+ "content: set the content\n"
+ "game: start a new game\n"
+ "history: view past game records\n"
+ "clear: clear all game records\n"
+ "bye: exit typist";
Expand All @@ -80,7 +79,7 @@ public class Messages {

//This sample text is gotten from https://www.lipsum.com/
public static final String SAMPLE_TEXT = "lorem ipsum is simply dummy text of the printing and typesetting "
+ "imply dummy text of the printing and typesetting industry ipsum is simply dummy "
+ "imply dummy text of the printing and typesetting industry ipum is simply dummy "
+ "dummy dummy dummy dummy dummy dummy dummy dummy dummy dummy dummy dummy dummy dummy dummy dummy "
+ "dummy dummy dummy dummy dummy dummy dummy dummy dummy dummy dummy dummy dummy dummy dummy dummy "
+ "industry industry industry industry industry industry industry industry industry industry industry "
Expand Down
5 changes: 2 additions & 3 deletions text-ui-test/EXPECTED.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@
| Welcome to Typist -- the ultimate cli typing game.
| Brought to you by -- AY2122S1-CS2113-T13-4.
| Manual:
| content: set the content (or <-c> with game command)
| word: start a new word game
| time: start a new timer game <-t> to specify time <-sn> to start immediately
| content: set the content
| game: start a new game
| history: view past game records
| clear: clear all game records
| bye: exit typist
Expand Down
16 changes: 9 additions & 7 deletions time-limited_records.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
Word-limited|8.082|1|9|10|10.0|90.0|66.81514476614699|[dummy]
Word-limited|10.075|0|10|10|0.0|100.0|59.55334987593052|[]
Word-limited|11.066|1|9|10|10.0|90.0|48.79812036869691|[dummy]
Word-limited|10.052|2|8|10|20.0|80.0|47.751691205730204|[dummy, printing]
Time-limited|31.138|3|27|30|10.0|90.0|52.02646284282869|[typesetting, typesetting, industry]
Time-limited|43.279|3|27|30|10.0|90.0|37.43154878809584|[salutation, language., salutation]
Time-limited|32.197|70|0|70|100.0|0.0|0.0|[IuFcUUkKAd, caTzefb, KEQZczuUePDrP, jRNdf, KIzMp, xWRJHeCfXFyqcD, dRlhRklAoYEVDH, PmXegHtA, BufKD, JrUUsV, JNBCFmK, SkaqR, wprOgJPRupQcQk, fCPjET, LBioiTKLO, UrUOrpZlyw, DioaqLva, nJcBVYrWf, EJfVzPipYIZLX, djiaicC, IuFcUUkKAd, caTzefb, KEQZczuUePDrP, jRNdf, KIzMp, xWRJHeCfXFyqcD, dRlhRklAoYEVDH, PmXegHtA, BufKD, JrUUsV, JNBCFmK, SkaqR, wprOgJPRupQcQk, fCPjET, LBioiTKLO, UrUOrpZlyw, DioaqLva, nJcBVYrWf, EJfVzPipYIZLX, djiaicC, IuFcUUkKAd, caTzefb, KEQZczuUePDrP, jRNdf, KIzMp, xWRJHeCfXFyqcD, dRlhRklAoYEVDH, PmXegHtA, BufKD, JrUUsV, JNBCFmK, SkaqR, wprOgJPRupQcQk, fCPjET, LBioiTKLO, UrUOrpZlyw, DioaqLva, nJcBVYrWf, EJfVzPipYIZLX, djiaicC, IuFcUUkKAd, caTzefb, KEQZczuUePDrP, jRNdf, KIzMp, xWRJHeCfXFyqcD, dRlhRklAoYEVDH, PmXegHtA, BufKD, JrUUsV]
Time-limited|30.176|20|20|40|50.0|50.0|39.76670201484624|[simply, printing, typesetting, typesetting, industry, dummy, dummy, dummy, dummy, dummy, dummy, dummy, dummy, dummy, dummy, dummy, dummy, dummy, dummy, dummy]
Time-limited|37.245|3|27|30|10.0|90.0|43.49577124446235|[uncut, hair, grew]
Time-limited|30.143|2|28|30|6.666666666666667|93.33333333333333|55.734333012639745|[balloon, grew]
Word-limited|10.052|2|8|10|20.0|80.0|47.751691205730204|[dummy, printing]
Time-limited|31.138|3|27|30|10.0|90.0|52.02646284282869|[typesetting, typesetting, industry]
Time-limited|43.279|3|27|30|10.0|90.0|37.43154878809584|[salutation, language., salutation]
Time-limited|32.197|70|0|70|100.0|0.0|0.0|[IuFcUUkKAd, caTzefb, KEQZczuUePDrP, jRNdf, KIzMp, xWRJHeCfXFyqcD, dRlhRklAoYEVDH, PmXegHtA, BufKD, JrUUsV, JNBCFmK, SkaqR, wprOgJPRupQcQk, fCPjET, LBioiTKLO, UrUOrpZlyw, DioaqLva, nJcBVYrWf, EJfVzPipYIZLX, djiaicC, IuFcUUkKAd, caTzefb, KEQZczuUePDrP, jRNdf, KIzMp, xWRJHeCfXFyqcD, dRlhRklAoYEVDH, PmXegHtA, BufKD, JrUUsV, JNBCFmK, SkaqR, wprOgJPRupQcQk, fCPjET, LBioiTKLO, UrUOrpZlyw, DioaqLva, nJcBVYrWf, EJfVzPipYIZLX, djiaicC, IuFcUUkKAd, caTzefb, KEQZczuUePDrP, jRNdf, KIzMp, xWRJHeCfXFyqcD, dRlhRklAoYEVDH, PmXegHtA, BufKD, JrUUsV, JNBCFmK, SkaqR, wprOgJPRupQcQk, fCPjET, LBioiTKLO, UrUOrpZlyw, DioaqLva, nJcBVYrWf, EJfVzPipYIZLX, djiaicC, IuFcUUkKAd, caTzefb, KEQZczuUePDrP, jRNdf, KIzMp, xWRJHeCfXFyqcD, dRlhRklAoYEVDH, PmXegHtA, BufKD, JrUUsV]
Time-limited|30.176|20|20|40|50.0|50.0|39.76670201484624|[simply, printing, typesetting, typesetting, industry, dummy, dummy, dummy, dummy, dummy, dummy, dummy, dummy, dummy, dummy, dummy, dummy, dummy, dummy, dummy]
Time-limited|37.245|3|27|30|10.0|90.0|43.49577124446235|[uncut, hair, grew]
Time-limited|30.143|2|28|30|6.666666666666667|93.33333333333333|55.734333012639745|[balloon, grew]
Time-limited|30.2|8|22|30|26.666666666666668|73.33333333333333|43.70860927152318|[fleshy, balloon, of, hair, and, the, that, grew]
Time-limited|36.219|7|23|30|23.333333333333332|76.66666666666667|38.10154891079268|[ipum, dummy, dummy, dummy, dummy, dummy, dummy]

0 comments on commit 9ec35e7

Please sign in to comment.