Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

final demo changes #45

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
195 changes: 195 additions & 0 deletions spring-shell.log
Original file line number Diff line number Diff line change
Expand Up @@ -2746,3 +2746,198 @@
1701376388859:savegame temp
1701376456665:loadgame temp
1701376464323:showstats
1701378923765:loadmap europe
1701378925860:showmap
1701378933019:gameplayer -add p1 -add p2
1701378934815:N
1701378941167:assigncountries
1701379061225:loadmap europe
1701379063575:showmap
1701379078186:gameplayer -add p1 -add p2 -add p3 -add p4
1701379079724:N
1701379088826:assigncountries
1701379176570:loadmap europe
1701379178143:showmap
1701379184566:gameplayer -add p1 -add p2 -add p3
1701379186148:N
1701379197371:assigncountries
1701379206085:deploy 1 3
1701379222727:deploy 8 3
1701379224485:N
1701379237325:savegame roch1
1701379285159:savegame
1701379288798:savegame roch1
1701379325435:loadgame roch1
1701379465477:loadmap europe
1701379467984:showmap
1701379476006:gameplayer -add p1 -add p2 -add p3
1701379477621:N
1701379484695:assigncountries
1701379612095:loadmap europe
1701379613587:showmap
1701379618993:gameplayer -add p1 -add p2
1701379620646:N
1701379624129:4
1701379629225:assigncountries
1701379647892:loadmap europe
1701379650322:showmap
1701379657137:gameplayer -add p1 -add p2 -add p3
1701379658648:N
1701379665049:assigncountries
1701379748820:loadmap europe
1701379750590:showmap
1701379761920:gameplayer -add p1 -add p2 -add p3 -add p4
1701379763409:N
1701379770843:assigncountries
1701380018181:loadmap europe
1701380019580:showmap
1701380028012:gameplayer -add p1 -add p2 -add p3 -add p4
1701380029601:N
1701380037953:assigncountries
1701380213563:tournament -M europe Montreal -P 2 3 4 -G 2 -D 5
1701380717334:tournament -M europe,Montreal -P 2 5 -G 2 -D 10
1701380859773:loadmap europe
1701380861377:showmap
1701380866532:gameplayer -add p1 -add p2
1701380868301:N
1701380874527:assigncountries
1701380881489:deploy 1 3
1701380889271:N
1701380895336:showstats
1701380962766:loadmap europe
1701380964521:showmap
1701380969346:gameplayer -add p1 -add p2
1701380970948:N
1701380976400:assigncountries
1701380982192:deploy 1 3
1701380983710:N
1701381076977:loadmap europe
1701381078407:showmap
1701381083799:gameplayer -add p1 -add p2
1701381085964:N
1701381092188:assigncountries
1701381095881:deploy 1 3
1701381097229:N
1701381191272:loadmap europe
1701381192669:showmap
1701381197877:gameplayer -add p1 -add p2
1701381199197:N
1701381205106:assigncountries
1701381209546:deploy 1 3
1701381248033:loadmap europe
1701381249520:showmap
1701381256900:gameplayer -add p1 -add p2
1701381258354:N
1701381263420:assigncountries
1701381270734:deploy 1 3
1701381327386:N
1701381404489:tournament -M europe Montreal -P 2 4 -G 2 -D 15
1701381457855:stacktrace
1701381666785:tournament -M europe,Montreal -P 2 4 -G 2 -D 20
1701381775332:tournament -M europe Montreal -P 4 5 -G 3 -D 15
1701381915771:tournament -M europe Montreal -P 2 4 -G 1 -D 30
1701382075865:loadmap europe
1701382077734:showmap
1701382098416:gameplayer -add p1 -add p2 -add p3
1701382099843:N
1701382109969:assigncountries
1701382224449:loadmap europe
1701382226121:showmap
1701382235602:gameplayer -add p1 -add p2 -add p3
1701382237097:N
1701382245074:assigncountries
1701382379901:loadmap europe
1701382381673:showmap
1701382397999:gameplayer -add p1 -add p2 -add p3
1701382399425:N
1701382406232:assigncountries
1701382432032:savegame roch2
1701382452604:loadgame roch2
1701382516661:loadmap Montreal
1701382520271:showmap
1701382529062:gameplayer -add p1 -add p2 -add p3 -add p4
1701382533642:N
1701382571908:assigncountries
1701382586021:stacktrace
1701382700709:loadmap Montreal
1701382704174:showmap
1701382717731:gameplayer -add p1 -add p2 -add p3 -add p4
1701382719286:N
1701382730239:assigncountries
1701382784268:loadmap europe
1701382786284:showmap
1701382794439:gameplayer -add p1 -add p2
1701382796708:N
1701382804833:4
1701382810451:savegame roch3
1701382820295:loadgame roch3
1701382893746:loadmap europe
1701382901210:showmap
1701382908254:gameplayer -add p1 -add p2 -add p3
1701382909708:N
1701382917893:4
1701382921364:assigncountries
1701382926781:savegame roch4
1701382969100:loadgame roch4
1701383459706:loadmap euroep
1701383466397:loadmap europe
1701383467667:showmap
1701383485016:gameplayer -add p1 -add p2 -add p3
1701383499568:N
1701383505486:4
1701383515051:savegame rochNew
1701383539356:loadgame rochNew
1701383578647:loadmap europe
1701383585457:showmap
1701383594453:gameplayer -add p1 -add p2 -add p3 -add p4
1701383596727:N
1701383605288:assigncountries
1701383611597:savegame
1701383618069:savegame rocht
1701383642770:loadgame rocht
1701383697535:loadmap euroep
1701383700843:loadmap europe
1701383705288:showmap
1701383837977:gameplayer -add p1 -add p2 -add p3 -add p4
1701383839530:N
1701383947197:assigncountries
1701384149892:tournament -M europe Montreal -P 2 4 -G 2 -D 20
1701384163086:stacktrace
1701384281996:tournament -M europe Montreal -P 2 4 -G 2 -D 20
1701384390756:tournament -M europe Montreal -P 2 3 4 -G 2 -D 20
1701384434229:loadmap europe
1701384437318:showmap
1701384449406:gameplayer -add p1 -add p2 -add p3
1701384450849:N
1701384463576:assigncountries
1701384470292:deploy 1 3
1701384481780:N
1701384488173:showstats
1701384500686:deploy 1 6
1701384617744:N
1701385872822:tournament - M europe Montreal -P 2 4 -G 2 -D 20
1701385885151:tournament -M europe Montreal -P 2 4 -G 2 -D 20
1701386320896:loadmap Montreal
1701386323794:showmap
1701386356759:loadmap europe
1701386358866:showmap
1701386386824:gameplayer -add p1 -add p2 -add p3
1701386390377:N
1701386418496:assigncountries
1701386484901:loadmap europe
1701386486062:showmap
1701386495019:gameplayer -add p1 -add p2
1701386496756:N
1701386509662:assigncountries
1701386528644:savegame
1701386534672:savegame rochdemo
1701386578692:loadgame rochdemo
1701386598763:deploy 1 3
1701386610897:N
1701386615435:showstats
1701386630520:deploy 1 6
1701386640813:Y
1701386651234:advance 1 6 3
1701386654323:N
1701386657040:showstats
1701386734121:tournament -M europe Montreal -P 2 4 -G 2 -D 20
30 changes: 26 additions & 4 deletions src/main/java/project/app/warzone/Commands/PlayerCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import project.app.warzone.Features.PlayerFeatures;
import project.app.warzone.Model.Attack;
import project.app.warzone.Model.Cards;
import project.app.warzone.Model.Country;
import project.app.warzone.Model.GameEngine;
import project.app.warzone.Model.LogEntryBuffer;
import project.app.warzone.Model.Map;
Expand Down Expand Up @@ -118,11 +119,20 @@ public String gamePlayerAdd(
@ShellMethod(key = "assigncountries", value = "This is used to assign countries to players randomly")
public void assigncountries() {
// d_gameEngine.getGamePhase().assignCountries();
d_gameEngine.getGamePhase().assignCountriesForDemo(); // Added to demonstrate different attacks during presentation
if(d_gameEngine.getPlayers().size() >1){
//d_gameEngine.getGamePhase().assignCountriesForDemo(); // Added to demonstrate different attacks during presentation
d_gameEngine.getGamePhase().assignCountriesForDemo();
showStats();

showStats();
d_gameEngine.checkPlayersReinforcements();

d_gameEngine.checkPlayersReinforcements();

}


else{
System.out.println("You need atleast 2 players to play the game. Please add more players");
}
}

/**
Expand Down Expand Up @@ -351,6 +361,18 @@ public void saveGame(@ShellOption String p_fileName) {
l_line = l_reader.readLine();
}
l_writer.append("\n\n-------------------Game Over-----------------\n");
List<Player> l_listOfPlayers = d_gameEngine.getPlayers();
for (Player l_p : l_listOfPlayers) {
l_writer.append("Player Name:" + l_p.d_playername + "\nPlayerId:" + l_p.d_playerid +"\nPlayer Strategy:" + l_p.getStrategy().getClass().getSimpleName()).append("\n");
l_writer.append("Total Armies available per round: " + l_p.getReinforcementArmies()).append("\n");
l_writer.append("CountryID - Countries Owned - Armies").append("\n");

for (Country t : l_p.getListOfTerritories()) {
l_writer.append(t.getCountryId() + " - " + t.getCountryName() + " - " + t.getNumberOfArmies()).append("\n");
}

l_writer.append("-------------------------------");
}
l_writer.append("Results:\n");
if(d_gameEngine.getPlayers().size() == 1){
l_writer.append("Winner: " + d_gameEngine.getPlayers().get(0).getL_playername());
Expand Down Expand Up @@ -558,7 +580,7 @@ public void tournament(@ShellOption(value = "M", defaultValue = ShellOption.NULL
for(int k = 0; k < (p_playerStrategies.split(",").length); k++){
UserCommands.pushCommand(p_playerStrategies.split(",")[k], "strategy");
if(k != 0) {
if(k <= p_playerStrategies.split(",").length - 1){
if(k == p_playerStrategies.split(",").length - 1){
UserCommands.pushCommand("N", "playerAdd");
} else {
UserCommands.pushCommand("Y", "playerAdd");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void assignCountries(GameEngine p_gameEngine) {

for (Player l_player : p_gameEngine.getPlayers()) { // logic to have players -1 country

int randomCountry = l_random.nextInt(p_gameEngine.gameMap.getNodes().size());
int randomCountry = l_random.nextInt(p_gameEngine.gameMap.getNodes().size()-1);

// int randomId = l_random.nextInt(p_gameEngine.getPlayers().size()+1);

Expand All @@ -101,6 +101,8 @@ public void assignCountriesForDemo(GameEngine p_gameEngine) {
add(7);
add(20);
add(9);
add(13);
add(16);
}
};

Expand Down Expand Up @@ -146,7 +148,7 @@ public void setPlayerStrategy(GameEngine p_gameEngine){

System.out.println("Current Player: "+l_p.d_playername);
String input ="";
System.out.println("Strategy: "+ UserCommands.checkSize("strategy"));
// System.out.println("Strategy: "+ UserCommands.checkSize("strategy"));
if(UserCommands.checkSize("strategy")>0){
input = UserCommands.popCommand("strategy");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public List<OrderInterface> createOrder(){

int l_countryToOwner = countryToAttack.getOwnerId();

Player player2 = d_gameEngine.getPlayers().get(l_countryToOwner-1);
Player player2 = d_gameEngine.getPlayerFromID(l_countryToOwner);

int armiesToAttack = attackers;

Expand Down
15 changes: 11 additions & 4 deletions src/main/java/project/app/warzone/Model/BenevolentStrategy.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ public List<OrderInterface> createOrder(){

List<OrderInterface> listOfOrders = new ArrayList<>();

Country targetCountry = toDefend().get(0);
if(toDefend().size()>0){

while(d_player.getReinforcementArmies() > 0){
Country targetCountry = toDefend().get(0);

while(d_player.getReinforcementArmies() > 0){

int armiesToDeploy = d_player.getReinforcementArmies();

Expand All @@ -71,7 +73,7 @@ public List<OrderInterface> createOrder(){
int movers = toDefend().get(toDefend().size()-1).getNumberOfArmies() ;


while(movers > 0 && toDefend()!= null && toDefend().size() > 0 ){
while(movers > 0 && toDefend()!= null && toDefend().size() > 0 && toDefend().size()>1){



Expand All @@ -92,7 +94,7 @@ public List<OrderInterface> createOrder(){

listOfOrders.add(newAdvanceOrdr);

System.out.println("Added Attack Order for player:"+d_player.getL_playername()+" with strategy:"+d_player.getStrategy().getClass().getSimpleName());
System.out.println("Move Order for player:"+d_player.getL_playername()+" with strategy:"+d_player.getStrategy().getClass().getSimpleName());

System.out.println("Armies:"+numberofArmies+" FromCountry:"+targetCountry.getCountryName()+" ToCountry:"+l_countryToAdvance.getCountryName() );

Expand All @@ -106,6 +108,11 @@ public List<OrderInterface> createOrder(){

d_player.pendingOrder=false;
return listOfOrders;

}

return null;


}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public List<OrderInterface> createOrder(){

int l_countryToOwner = c.getOwnerId();

Player player2 = d_gameEngine.getPlayers().get(l_countryToOwner-1);
Player player2 = d_gameEngine.getPlayerFromID(l_countryToOwner);

player2.removeTerritory(c);

Expand Down
Loading
Loading