Skip to content

Commit

Permalink
Merge pull request #6 from ro18/dev-rochelle
Browse files Browse the repository at this point in the history
Push player and yaml file
  • Loading branch information
ro18 authored Sep 30, 2023
2 parents 1df19a7 + 990f932 commit 8a04501
Show file tree
Hide file tree
Showing 13 changed files with 532 additions and 76 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ build/

### VS Code ###
.vscode/
spring-shell.log
17 changes: 17 additions & 0 deletions github/workflows/test.yaml
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"
141 changes: 141 additions & 0 deletions spring-shell.log
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,144 @@
1695756901434:loadmap europe
1695757749400:showmap europe
1695759123625:showmap
1695877204628:loadmap europe
1695879443437:loadMap
1695879450214:loadMap europe
1695879466532:loadmap europe
1695879586483:showmap
1695883436615:gameplayer -add rohit
1695883611942:gameplayer -add r
1695883739559:gameplayer -add p
1695883905095:gameplayer -add player
1695884337604:ssh-add --k test1
1695884376551:gameplayer -add
1695884398012:gameplayer -a
1695884477583:ssh-add k
1695884523055:ssh-add --k test1
1695884569418:gameplayer -a bee
1695884596100:loadmap
1695884602310:loadmap europe
1695884606890:showmap
1695884614227:gameplayer -a bee
1695884679707:loadmap europe
1695884682181:showmap
1695884691096:gameplayer -a bee
1695884934532:gameplayer -add test
1695884974705:loadmap
1695884979856:loadmap europe
1695884982187:showmap
1695884992784:gameplayer -a bee
1695885004865:gameplayer -remove bee
1695885071993:gameplayer -r bee
1695885135529:loadmap
1695885141148:loadmap europe
1695885143493:showmap
1695885152586:gameplayer -a bee
1695885158557:gameplayer -r bee
1695885314316:loadmap europe
1695885318702:showmap
1695885323245:gameplayer -add test
1695885370672:help
1695885383073:help gameplayer
1695885515693:loadmap europe
1695885518660:showmap
1695885523036:gameplayer -r bee
1695885534228:help gameplayer
1695885570099:loadmap europe
1695885573401:showmap
1695885575589:gameplayer -r bee
1695885581628:help gameplayer
1695885591297:gameplayer -add hell
1695885982238:help ssh
1695885991148:help my-ssh
1695886038127:gameplayer -add hell
1695886046024:help gameplayer
1695886090398:help loadmap
1695886129754:help gameplayer
1695886325876:help loadmap
1695886329168:help gameplayer
1695912346715:gameplayer -a bee
1695912367765:gameplayer -add bee
1695912382403:help
1695912395321:help gameplayer
1695912544362:gameplayer -add hello
1695912630852:gameplayer -add bee
1695912664859:help gameplayer
1695912672202:gameplayer -add bee
1695912697259:help my-ssh
1695912794054:gameplayer -add bee
1695912817497:help gameplayer
1695912857543:gameplayer -add bee
1695912871824:help gameplayer
1695912965195:gameplayer -add bee
1695913001527:help gameplayer
1695913010198:gameplayer
1695913173647:gameplayer -remove mhir
1695913332416:gameplayer -add mihir rochelle
1695913352073:gameplayer -add mihir aish --remove mihir
1695913432464:gameplayer -add mihir aish -remove mihir
1695913448255:gameplayer -remove mihir
1695938582015:gameplayer -add bee
1695938643184:loadmap europe
1695938648505:showmap
1695938656298:gameplayer -add bee
1695946243416:loadmap europe
1695946245839:showmap
1695946264622:gameplayer -add bee boo koo
1695946279239:gameplayer -add bee boo
1695946315147:help gameplayer
1695946668309:gameplayer -add bee boo
1695946719518:loadmap europe
1695946721760:showmap
1695946729119:gameplayer -add bee boo
1695946750234:gameplayer -remove bee
1695947080288:loadmap
1695947085399:loadmap filename
1695947090621:loadmap europe
1695947093410:showmap
1695947102261:gameplayer -add aish mihir
1695947126878:gameplayer -remove bee
1695948472893:loadmap europe
1695948493742:showmap
1695948517212:gameplayer -add aish mihir
1695948549929:gameplayer -remove mihir
1695954043358:loadmap europe
1695954047144:showmap
1695954059481:gameplayer -add harshita mihir
1695954074421:assigncountries
1696001985929:loadmap europe
1696001990412:showmap
1696002007412:gameplayers -add nola pink
1696002045170:gameplayer -add nola pink
1696002072983:assigncountries
1696006270100:loadmap europe
1696006277325:showmap
1696006290290:gameplayer -add mihir harshita
1696006303697:assigncountries
1696008922949:showstats
1696009741326:loadmap
1696009744866:loadmap europe
1696009747649:showmap
1696009756770:gameplayer -add my boo
1696009770912:assigncountries
1696009837160:loadmap europe
1696009840596:showmap
1696009857612:gamaplayer -add beebo peepo
1696009865632:gameplayer -add beebo peepo
1696009897283:assigncountries
1696009957006:showstats
1696010033274:loadmap europe
1696010035928:showmap
1696010048145:gameplayer -add p1 p2
1696010055098:assigncountries
1696010063959:showstats
1696010254296:loadmap europe
1696010258092:showmap
1696010265940:gameplayer -add bee boo
1696010277500:assigncountries
1696010343487:showstats
1696010483009:loadmap europe
1696010488058:showmap
1696010523822:gameplayer -add p1 p2
1696010545967:assigncountries
1696010551252:showstats
24 changes: 14 additions & 10 deletions src/main/java/project/app/warzone/Commands/MapEditorCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,24 @@
import org.springframework.shell.standard.ShellMethod;
import org.springframework.shell.standard.ShellOption;
import project.app.warzone.Features.MapFeatures;
import project.app.warzone.Model.Map;
import project.app.warzone.Features.PlayerFeatures;
import project.app.warzone.Model.GameEngine;
import project.app.warzone.Utilities.Commands;

@ShellComponent
public class MapEditorCommands {



private final MapFeatures mapFeatures;
public Map map;
//test
public GameEngine gameEngine;
public PlayerCommands playerCommands;
public PlayerFeatures playerFeatures;

public MapEditorCommands(MapFeatures mapFeatures, Map map){
public MapEditorCommands(MapFeatures mapFeatures, GameEngine gameEngine, PlayerFeatures playerFeatures){
this.mapFeatures = mapFeatures;
this.map = map;
this.gameEngine = gameEngine;
playerCommands = new PlayerCommands(gameEngine,playerFeatures);


}
Expand All @@ -25,10 +29,10 @@ public MapEditorCommands(MapFeatures mapFeatures, Map map){

@ShellMethod(key= "loadmap", value="Player can create or open an existing map")
public String loadMap(@ShellOption String p_filename){

if(map.fileExists(p_filename)){
gameEngine.prevUserCommand=Commands.LOADMAP;
if(gameEngine.gameMap.fileExists(p_filename)){
System.out.println("One file found.");
map.set_USER_SELECTED_FILE(p_filename);
gameEngine.gameMap.set_USER_SELECTED_FILE(p_filename);
return "Choose one of the below commands to proceed:\n 1. showmap 2.editmap";
}
else{
Expand All @@ -38,9 +42,9 @@ public String loadMap(@ShellOption String p_filename){

@ShellMethod(key= "showmap", value="Used to display map continents with terriotories and boundaries")
public void showmap(){
String p_mapLocation=map.getMapDirectory()+"\\"+map.get_USER_SELECTED_FILE()+".map";
String p_mapLocation=gameEngine.gameMap.getMapDirectory()+"\\"+gameEngine.gameMap.get_USER_SELECTED_FILE()+".map";
//System.out.println("map location:"+p_mapLocation);
map = mapFeatures.readMap(p_mapLocation);
gameEngine.gameMap = mapFeatures.readMap(p_mapLocation);

}

Expand Down
14 changes: 14 additions & 0 deletions src/main/java/project/app/warzone/Commands/OrderCommands.java
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 src/main/java/project/app/warzone/Commands/PlayerCommands.java
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";

}



}
Loading

0 comments on commit 8a04501

Please sign in to comment.