Skip to content

Commit

Permalink
added fail state detection to user. added day counting to gamecontrol…
Browse files Browse the repository at this point in the history
…ler for scoring purposes. added illegal action rolling method to eventroller.
  • Loading branch information
aelnourSLU committed Dec 8, 2023
1 parent 788715e commit 0b927d0
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
9 changes: 9 additions & 0 deletions app/src/main/java/stock/controller/EventRoller.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,13 @@ public String get_description_for(String event_name) {
}
return desc;
}

public ArrayList<String> roll_illegal_actions(int presses) {
ArrayList<String> illegal_events = new ArrayList<>();
for (int i = 0; i < presses; i++) {
int rand_int = rand.nextInt(0, this.events.get("Illegal").size());
illegal_events.add(this.events.get("Illegal").get(rand_int).name);
}
return illegal_events;
}
}
7 changes: 6 additions & 1 deletion app/src/main/java/stock/controller/GameController.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@ public class GameController implements ControllerInterface {
User user;
Market market;
EventRoller roller;
int day;


public GameController() {
this.start = new startUI(this);
this.gm = new GameManager();
this.roller = new EventRoller();

this.day = 1;

}

Expand Down Expand Up @@ -75,6 +76,10 @@ public void nextday() {
user.process_event(currentEvents.get(1));
game.update();

// can use this to show how far the player lasted
this.day += 1;
// check to see if game should end
boolean game_should_end = user.reached_fail_state();

}

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/stock/model/Market.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void change_stocks(float modify) {
}
}

private void stock_changer(float modify, Stock stock){
private void stock_changer(float modify, Stock stock) {
double rand_double = rand.nextDouble(1);
float current_price = stock.get_price();
int current_stability = stock.get_stability();
Expand Down
11 changes: 11 additions & 0 deletions app/src/main/java/stock/model/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -177,4 +177,15 @@ public boolean buyStock(String ticker, float price, int quantity) {
public HashMap<String, Integer> get_user_stocks() {
return this.stocks;
}

public boolean reached_fail_state() {
if (
this.stress > 100 ||
this.capital < 0 ||
this.suspicionOfSEC > 100
) {
return true;
}
return false;
}
}

0 comments on commit 0b927d0

Please sign in to comment.