Skip to content

Commit

Permalink
Merge pull request #64 from RancyKaur/ronakbranch
Browse files Browse the repository at this point in the history
Changed the indexes in program fixed the bugs of the cards
  • Loading branch information
RancyKaur authored Nov 10, 2023
2 parents ed0adb5 + a4ecd8f commit b9e62c1
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 12 deletions.
23 changes: 13 additions & 10 deletions src/main/java/Controller/GameEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -558,18 +558,19 @@ public GamePhase parseCommand(Player p_player, String p_givenCommand) {
// Get the target player from your game logic; replace "fetchTargetPlayer" with the appropriate method
Player targetPlayer = fetchTargetPlayer(p_player);

boolean sourceCountryOwned = p_player.getOwnedCountries().containsKey(countryId.toLowerCase());
boolean targetCountryOwned = targetPlayer.getOwnedCountries().containsKey(countryId.toLowerCase());
boolean checkCard = p_player.checkCardExists("Bomb");

if (sourceCountryOwned && checkCard) {
if (targetCountryOwned && checkCard) {
// Create a Bomb order
Bomb bombOrder = new Bomb(p_player, targetPlayer, countryId);

// Add the Bomb order to the current player's order list
p_player.addOrder(bombOrder);

// Issue the order (p_player.issue_order() or d_Phase.issue_order(p_player))
// ...
// Issue the order (p_player.issue_order() or
d_Phase.issue_order(p_player);


System.out.println("For player " + p_player.getPlayerName()
+ " Bomb order added to Players OrdersList: " + l_param[0] + " "
Expand Down Expand Up @@ -605,11 +606,11 @@ public GamePhase parseCommand(Player p_player, String p_givenCommand) {
System.out.println(l_commandName + " command entered");
try {
if (!(l_param[1] == null) && !(l_param[2] == null) && !(l_param[3] == null)) {
if (this.isAlphabetic(l_param[1]) && this.isNumeric(l_param[2]) && this.isAlphabetic(l_param[3])) {
if (this.isAlphabetic(l_param[1]) && this.isNumeric(l_param[3]) && this.isAlphabetic(l_param[2])) {
setPhase(new IssueOrderPhase(this));
String sourceCountryId = l_param[1];
int numArmiesToAirlift = Integer.parseInt(l_param[2]);
String targetCountryId = l_param[3];
int numArmiesToAirlift = Integer.parseInt(l_param[3]);
String targetCountryId = l_param[2];

boolean sourceCountryOwned = p_player.getOwnedCountries()
.containsKey(sourceCountryId.toLowerCase());
Expand Down Expand Up @@ -708,13 +709,15 @@ public GamePhase parseCommand(Player p_player, String p_givenCommand) {
try {
if (!(l_data[1] == null)){
if (this.isAlphabetic(l_data[1])) {
setPhase(new IssueOrderPhase(this));
Player l_NegPlayer = fetchPlayerByName(l_data[1]);
boolean checkCard = p_player.checkCardExists("Diplomacy");
if(checkCard){
p_player.addOrder(new Negotiate(p_player, l_NegPlayer));
p_player.issue_order();
System.out.println("For player " + p_player.getPlayerName()+" Diplomacy order added to Players OrdersList: "+l_data[0]+" "+l_data[1]+" "+l_data[2]+" "+l_data[3]);
d_LogEntry.setMessage("For player " + p_player.getPlayerName()+" Diplomacy order added to Players OrdersList: "+l_data[0]+" "+l_data[1]+" "+l_data[2]+" "+l_data[3]);
//p_player.issue_order();
d_Phase.issue_order(p_player);
System.out.println("For player " + p_player.getPlayerName()+" Diplomacy order added to Players OrdersList: "+l_data[0]+" "+l_data[1]);
d_LogEntry.setMessage("For player " + p_player.getPlayerName()+" Diplomacy order added to Players OrdersList: "+l_data[0]+" "+l_data[1]);
p_player.removeCard("Diplomacy");
d_LogEntry.setMessage("Diplomacy card used hence it is now removed from Player's cardList ");
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/Model/GameCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public String generateRandomCard()
*/
public void createGameCard()
{
//d_CardName = generateRandomCard();
d_CardName="Blockade";
d_CardName = generateRandomCard();
//d_CardName="Diplomacy";
}

/**
Expand Down
21 changes: 21 additions & 0 deletions src/main/resources/maps/demo.map
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
map:demo.map

[Continents]
1 Asia 201
2 Europe 202

[Countries]
2 China 1
3 Russia 1
4 Germany 2
6 France 2
1 India 1
5 Italy 2

[Borders]
2 3 1
3 2 6
4 5
6 3 5
1 2 5
5 4 6 1

0 comments on commit b9e62c1

Please sign in to comment.