-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from ro18/dev-rochelle
Push player and yaml file
- Loading branch information
Showing
13 changed files
with
532 additions
and
76 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,3 +31,4 @@ build/ | |
|
||
### VS Code ### | ||
.vscode/ | ||
spring-shell.log |
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,17 @@ | ||
name: Test Action | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'dev-rochelle' | ||
pull_request: | ||
branches: | ||
- 'dev_rochelle' | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Print test | ||
run: echo "Hello World" |
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
14 changes: 14 additions & 0 deletions
14
src/main/java/project/app/warzone/Commands/OrderCommands.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,14 @@ | ||
package project.app.warzone.Commands; | ||
|
||
import org.springframework.shell.standard.ShellComponent; | ||
import org.springframework.shell.standard.ShellMethod; | ||
import org.springframework.shell.standard.ShellOption; | ||
|
||
@ShellComponent | ||
public class OrderCommands { | ||
|
||
@ShellMethod(key = "deploy", value = "This is used to deploy armies") | ||
public String deployArmies(@ShellOption int p_countryID, @ShellOption int p_armies) { | ||
return "You can deploy armies here"; | ||
} | ||
} |
83 changes: 63 additions & 20 deletions
83
src/main/java/project/app/warzone/Commands/PlayerCommands.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 |
---|---|---|
@@ -1,38 +1,81 @@ | ||
package project.app.warzone.Commands; | ||
|
||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.springframework.shell.standard.ShellComponent; | ||
import org.springframework.shell.standard.ShellMethod; | ||
import org.springframework.shell.standard.ShellOption; | ||
|
||
import project.app.warzone.Model.Player; | ||
import project.app.warzone.Model.Territory; | ||
import project.app.warzone.Features.PlayerFeatures; | ||
import project.app.warzone.Model.GameEngine; | ||
import project.app.warzone.Utilities.Commands; | ||
|
||
|
||
@ShellComponent | ||
public class PlayerCommands { | ||
|
||
@ShellMethod(key= "gameplayer", value="Player can create or remove a player") | ||
public String gamePlayer(@ShellOption String p_playername){ | ||
public GameEngine gameEngine; | ||
public PlayerFeatures playerFeatures; | ||
public String prevUserCommand; | ||
|
||
List<Territory> listOfCountries = new ArrayList<>() ; | ||
Player P = new Player(1, p_playername,listOfCountries); | ||
return "String"; | ||
public PlayerCommands(GameEngine gameEngine,PlayerFeatures playerFeatures){ | ||
this.gameEngine = gameEngine; | ||
this.playerFeatures= playerFeatures; | ||
} | ||
|
||
// @ShellMethod(key= "gameplayer", value="Player can create or remove a player") | ||
// public String gamePlayer(@ShellOption String p_filename){ | ||
|
||
|
||
// } | ||
|
||
// @ShellMethod(key= "assignCountries", value="Player can assign countries randomly") | ||
// public String gamePlayer(@ShellOption String p_filename){ | ||
@ShellMethod(key= "gameplayer", prefix = "-", value="Player can create or remove a player") | ||
public String gamePlayerAdd(@ShellOption(value="a",defaultValue=ShellOption.NULL, arity = 2) String p_playerNameOne,@ShellOption(value="r", defaultValue=ShellOption.NULL, arity=2) String p_playerNameTwo){ | ||
|
||
if(gameEngine.prevUserCommand == Commands.LOADMAP || gameEngine.prevUserCommand == Commands.ADDPLAYER || gameEngine.prevUserCommand == Commands.REMOVEPLAYER){ | ||
if(p_playerNameOne != null && p_playerNameOne != ""){ | ||
String l_players[] = p_playerNameOne.split(","); | ||
playerFeatures.addPlayers(l_players,gameEngine); | ||
|
||
playerFeatures.printAllPlayers(gameEngine); | ||
gameEngine.prevUserCommand=Commands.ADDPLAYER; | ||
return "Players added successfully"; | ||
|
||
} | ||
else{ | ||
|
||
String l_players[] = p_playerNameTwo.split(","); | ||
playerFeatures.removePlayers(l_players, gameEngine); | ||
playerFeatures.printAllPlayers(gameEngine); | ||
gameEngine.prevUserCommand=Commands.REMOVEPLAYER; | ||
return "Players removed successfully"; | ||
|
||
} | ||
|
||
} | ||
else{ | ||
return "You cannnot add players at this stage.Please enter loadmap command first"; | ||
} | ||
|
||
} | ||
|
||
|
||
// } | ||
|
||
|
||
@ShellMethod(key= "assigncountries", value="This is used to assign countries to players randomly") | ||
public String assigncountries(){ | ||
|
||
playerFeatures.assignCountries(gameEngine); | ||
System.out.println("Assigned Countries to the players are:"); | ||
playerFeatures.showAllAssignments(gameEngine.getPlayers()); | ||
//playerFeatures.initializeArmies(gameEngine.getPlayers()); | ||
return "Assignment of countries is completed. Enter showStats command to see you armies."; | ||
|
||
} | ||
|
||
@ShellMethod(key= "showstats", value="Displays players armies and other details") | ||
public String showStats(){ | ||
System.out.println("========================================"); | ||
System.out.println("STATS:"); | ||
playerFeatures.showStats(gameEngine); | ||
|
||
return "STATS COMPLETE"; | ||
|
||
} | ||
|
||
|
||
|
||
} |
Oops, something went wrong.