Skip to content

Commit

Permalink
Updated ToggleMovement methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Gavin Li committed Apr 11, 2015
1 parent a428dba commit e6b18ae
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions MerchantRPGCSE2102/src/controller/RPGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ public void createTransaction(Player player, Merchant targetMerchant)
if(_transactionLimit > 0)
{
toggleMovement("OFF");
Transaction newTransaction = new Transaction(player, targetMerchant);
toggleMovement("ON");
System.out.println("Transaction Begining");
Transaction newTransaction = new Transaction(player, targetMerchant, this);
_transactionLimit -= 1;
}
else
Expand Down
22 changes: 11 additions & 11 deletions MerchantRPGCSE2102/src/controller/Transaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ public class Transaction
private Player _player;
private Merchant _targetMerchant;
private TransactionUI _window;
private RPGame _game;

public Transaction(Player player, Merchant targetMerchant)
public Transaction(Player player, Merchant targetMerchant, RPGame game)
{
_player = player;
_targetMerchant = targetMerchant;
_game = game;
_window = new TransactionUI(this);
_window.setVisible(true);
}
Expand Down Expand Up @@ -61,16 +63,6 @@ public boolean actionSell(String itemName, int amount) throws NotInInventoryExce
return false;
}

/**
* This method will push a true up to the class calling it
* incomplete method
* @return returns true
*/
public boolean actionCancel()
{
return true;
}

/**
* Searches the player inventory for the item matching the item name
* @param itemName name of the item
Expand All @@ -91,6 +83,14 @@ public Item searchMerchantInventory(String itemName)
return _targetMerchant.getItem(itemName);
}

/**
* Toggles the RPGame movement back on
*/
public void endTransaction()
{
_game.toggleMovement("ON");
}

/**
* Returns the player in transaction
* @return returns the player
Expand Down
2 changes: 1 addition & 1 deletion MerchantRPGCSE2102/src/view/TransactionUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void mouseReleased(MouseEvent e) {
public void mouseReleased(MouseEvent e) {
System.out.println("Cancel"); //temporary test code

MASTER.actionCancel();
MASTER.endTransaction();
exitWindow(); //Will end the transaction main screen but only if player does not have another transaction screen open
}
});
Expand Down

0 comments on commit e6b18ae

Please sign in to comment.