forked from nus-cs2113-AY2021S1/tp
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
072d00d
commit f3975ad
Showing
15 changed files
with
531 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/main/java/seedu/ecardnomics/command/game/DoneGameCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package seedu.ecardnomics.command.game; | ||
|
||
import seedu.ecardnomics.command.Command; | ||
import seedu.ecardnomics.deck.Deck; | ||
|
||
public class DoneGameCommand extends GameCommand { | ||
/** Constructor. */ | ||
public DoneGameCommand(Deck deck) { | ||
super(deck); | ||
} | ||
|
||
@Override | ||
public void execute() { | ||
} | ||
|
||
/** Returns if command given is an instance of <code>DoneEditCommand</code>. */ | ||
public static boolean isDoneGame(Command command) { | ||
return command instanceof DoneGameCommand; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/seedu/ecardnomics/command/game/GameCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package seedu.ecardnomics.command.game; | ||
|
||
import seedu.ecardnomics.command.Command; | ||
import seedu.ecardnomics.deck.Deck; | ||
|
||
public abstract class GameCommand extends Command { | ||
protected Deck currentDeck; | ||
|
||
public GameCommand() { | ||
currentDeck = null; | ||
} | ||
|
||
public GameCommand(Deck currentDeck) { | ||
assert currentDeck != null : "Command must operate on a deck."; | ||
this.currentDeck = currentDeck; | ||
} | ||
|
||
public abstract void execute(); | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/seedu/ecardnomics/command/game/GameResponseCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package seedu.ecardnomics.command.game; | ||
|
||
public class GameResponseCommand extends GameCommand { | ||
String attempt; | ||
|
||
public GameResponseCommand(String userInput) { | ||
super(); | ||
attempt = userInput; | ||
} | ||
|
||
@Override | ||
public void execute() { | ||
// | ||
} | ||
|
||
public String getAttempt() { | ||
return attempt; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/seedu/ecardnomics/command/game/GameStartCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package seedu.ecardnomics.command.game; | ||
|
||
import seedu.ecardnomics.deck.Deck; | ||
import seedu.ecardnomics.game.Game; | ||
|
||
public class GameStartCommand extends GameCommand { | ||
Game game; | ||
|
||
/** Constructor. */ | ||
public GameStartCommand(Deck deck) { | ||
super(deck); | ||
} | ||
|
||
@Override | ||
public void execute() { | ||
game = new Game(currentDeck); | ||
} | ||
|
||
public Game getGameInstance() { | ||
return game; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/main/java/seedu/ecardnomics/command/normal/StartCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package seedu.ecardnomics.command.normal; | ||
|
||
import seedu.ecardnomics.Ui; | ||
import seedu.ecardnomics.command.Command; | ||
import seedu.ecardnomics.command.game.GameStartCommand; | ||
import seedu.ecardnomics.deck.Deck; | ||
import seedu.ecardnomics.deck.DeckList; | ||
|
||
public class StartCommand extends NormalCommand { | ||
Deck deck; | ||
|
||
/** Constructor. */ | ||
public StartCommand(DeckList deckList, Deck deck) { | ||
super(deckList); | ||
assert deck != null : "Do not operate on a null reference."; | ||
this.deck = deck; | ||
} | ||
|
||
@Override | ||
public void execute() { | ||
Ui.printGameWelcome(deckList.getIndexOf(deck) + 1, deck); | ||
new GameStartCommand(deck); | ||
} | ||
|
||
/** Returns Deck whose Game Mode is in progress. */ | ||
public Deck getDeck() { | ||
return deck; | ||
} | ||
|
||
/** Returns if command given is an instance of <code>StartCommand</code>. */ | ||
public static boolean isStart(Command command) { | ||
return command instanceof StartCommand; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package seedu.ecardnomics.game; | ||
|
||
import seedu.ecardnomics.command.Command; | ||
import seedu.ecardnomics.deck.Deck; | ||
|
||
public class Game { | ||
GameStorage storage; | ||
GameEngine engine; | ||
|
||
public Game(Deck deck) { | ||
storage = new GameStorage(deck); | ||
engine = new GameEngine(storage); | ||
} | ||
|
||
public Command run() { | ||
return engine.runGameLoop(); | ||
} | ||
} |
Oops, something went wrong.