Skip to content

Commit

Permalink
Merge pull request #13 from gal11002/William-C
Browse files Browse the repository at this point in the history
William c
  • Loading branch information
gal11002 committed Mar 1, 2015
2 parents e53a0fb + 37a7b6f commit f9e3ffb
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 2 deletions.
50 changes: 48 additions & 2 deletions MerchantRPGCSE2102/src/controller/RPGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,52 @@ public class RPGame {
private Merchant _merchant2;
private Merchant _merchant3;
private boolean _movement;

private int _currentDay;
private int _transactionLimit;


public RPGame() {
//constructor
_currentDay = 1;
_transactionLimit = 3;
}

/**
* Will refresh number of transactions the Player has available
*
*/
private void refreshTransactionLimit(){
_transactionLimit = 3;
}

/**
* This method will advance the game to the next day, therefore refreshing Merchant cash,
* incrementing the Merchant's max cash every 3 days, refreshing the player's _transactionLimit,
* Will call setDailyRandomPercentage, scaleAllAdjustedPrices, refreshCash, incrementBaseCash
*
*/
private void advanceDailyCycle(){
_merchant1.setDailyRandomPercentage(50,200);
_merchant2.setDailyRandomPercentage(80,500);
_merchant3.setDailyRandomPercentage(10,1000);
_merchant1.scaleAllAdjustedPrices();
_merchant2.scaleAllAdjustedPrices();
_merchant3.scaleAllAdjustedPrices();
if( (_currentDay % 3) == 0){
_merchant1.addCash(100);
_merchant1.refreshCash();
_merchant2.addCash(100);
_merchant2.refreshCash();
_merchant3.addCash(100);
_merchant3.refreshCash();
}else{
_merchant1.refreshCash();
_merchant2.refreshCash();
_merchant3.refreshCash();
}
refreshTransactionLimit();
_currentDay++;
}

/**
* This method scans the inventory.txt file located in src\config. It will read lines of the format <stringname> <price> and store them in the inventory list member variables
*
Expand Down Expand Up @@ -119,9 +160,14 @@ public ArrayList<String> getPlayerInventoryList() {
*/
public void createTransaction(Player player, Merchant targetMerchant)
{
if(_transactionLimit > 0){
toggleMovement("OFF");
Transaction newTransaction = new Transaction(player, targetMerchant);
toggleMovement("ON");
_transactionLimit -= 1;
}else{
System.out.println("The shops are closed.");
}
}

/**
Expand Down
7 changes: 7 additions & 0 deletions MerchantRPGCSE2102/src/tests/TestTransaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ public void setup()
public void testActionSell()
{
setup();
System.out.println("Transaction 1:");
_rpg.createTransaction(_rpg.getPlayer(), _rpg.getMerchant(1));
System.out.println("Transaction 2:");
_rpg.createTransaction(_rpg.getPlayer(), _rpg.getMerchant(1));
System.out.println("Transaction 3:");
_rpg.createTransaction(_rpg.getPlayer(), _rpg.getMerchant(1));
System.out.println("Transaction 4:");
_rpg.createTransaction(_rpg.getPlayer(), _rpg.getMerchant(1));
}
}
5 changes: 5 additions & 0 deletions MerchantRPGCSE2102/src/view/MainMenuUI.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package view;

public class MainMenuUI {

}

0 comments on commit f9e3ffb

Please sign in to comment.