Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewhua92 authored Jan 23, 2018
1 parent b879e70 commit 971a0af
Show file tree
Hide file tree
Showing 18 changed files with 529 additions and 251 deletions.
15 changes: 7 additions & 8 deletions Course.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
public class Course
{
// Variables
private double currentMark = 100; // Curent mark in the course
private double currentMark = 0; // Curent mark in the course
protected static int gradeLevel; // Current grade level of the course
private String subject; // Name of the subject
private int numEval = 0; // Number of evaluations performed
Expand Down Expand Up @@ -231,17 +231,16 @@ public void chooseCourse()
//Calculates the current mark
public void calcAverage()
{
double avg = 0;
int counter = 0;
for (int i =0 ; i < MAX_EVAL; i++)
double avg = currentMark;
double recent = 0;
for (int i = 0; i < MAX_EVAL; i++)
{
if (list[i] != null)
{
avg+= list[i].getMark();
counter++;
}
recent = list[i].getMark();
}
}
currentMark = avg/counter;
currentMark = (currentMark*(numEval-1) + recent)/numEval;
}

// Identifies this course with a specific stat
Expand Down
570 changes: 394 additions & 176 deletions Display.java

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion EVENTS.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ Open the door and go talk to them.
They freeze in their spot and look at you as you run towards them to talk.
Don't do anything and keep staring.
They notice you creepily staring at them and come to your window.
They say, "Hey, I saw you looking at my dog, do you like dogs too?"
Them says, "Hey, I saw you looking at my dog, do you like dogs too?"
2
"Yes, I love them. They are my favourite animal."
You say, "I love dogs and taking care of them, just like how I will take care of you."
Expand Down
8 changes: 6 additions & 2 deletions Ending.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
public class Ending{
// Ending class
// Glorified 'Event'
// Works similar to an Event where it has different requirements to access it or 'win' it
// Has varying texts for different scenarios
private String title;
private int luckReq;
private int happinessReq;
Expand All @@ -8,7 +12,7 @@ public class Ending{
private int stat2Req;
private String endingText;

//Constructor
// Constructors
public Ending(String title, int lReq, int hReq, int statType1, int stat1Req, int statType2, int stat2Req, String text){
this.title = title;
luckReq = lReq;
Expand All @@ -20,7 +24,7 @@ public Ending(String title, int lReq, int hReq, int statType1, int stat1Req, int
endingText = text;
}

//Accessors and mutators
// Accessors and mutators
public int getLuckReq(){
return luckReq;
}
Expand Down
4 changes: 4 additions & 0 deletions Evaluations.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
abstract class Evaluations
{
// This class is responsible for simulating the marks for a player
// Has children who are evaluations for specific stats
// They are evaluted a little bit differently from each other and use the corresponding stat to calculate the mark
// Variables
private String name;
private int minCharisma;
private double mark;
Expand Down
14 changes: 6 additions & 8 deletions Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public Event(String id, int statType, int statReq, int changeType, int changeAmo
}
}

//Accessors and mutators
public int getStatType(){
return eStatType;
}
Expand Down Expand Up @@ -56,9 +55,9 @@ public void setMonth(int i){
}

public int getEventValue(){
/*Returns the priority of each event type when being sorted
*Larger the number, the further back in the events array in eventRunner the event is sorted
*/
/*Returns the priority of each event type when being sorted
*Larger the number, the further back in the events array in eventRunner the event is sorted
*/
if (this instanceof Routine){
return 2;
} else if (this instanceof Random){
Expand All @@ -70,9 +69,9 @@ public int getEventValue(){
}

public void play(){
/*
* Plays through a given event manages the appropriate decision making and text displaying methods of each phase in the event
*/
/*
* Plays through a given event manages the appropriate decision making and text displaying methods of each phase in the event
*/
Scanner sc = new Scanner(System.in);
int playerChoice;
boolean valid = false;
Expand Down Expand Up @@ -122,7 +121,6 @@ private boolean makeDecision(int choiceMade, int phaseNum){
ePhases[phaseNum + 1].resetPhaseText(); // resets the text of any changes so a given decision's impact on the story will make sense
}
ePhases[phaseNum + 1].appendText(ePhases[phaseNum].getChoiceChangeToStory(choiceMade)); // changes the story based off of the choice made
//ePhases[phaseNum].setChangeToStory(choiceMade, null);
return true;
}
else { // if an invalid choice was entered, indicate that a decision wasn't made
Expand Down
25 changes: 12 additions & 13 deletions EventPhase.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
public class EventPhase {
private Choice [] EpChoices;
private int numChoices;
private String phaseText;
private String baseText;
boolean proceed = false;

//Constructor
private Choice [] EpChoices; // Array to hold the current phase choices
private int numChoices; // Number of choices
private String phaseText; // Text for the current phase
private String baseText; // Original text for phase

// Constructor
public EventPhase (String phaseText, Choice [] choices){
this.phaseText = phaseText;
numChoices = choices.length;
Expand All @@ -15,7 +14,8 @@ public EventPhase (String phaseText, Choice [] choices){
}
baseText = phaseText;
}
//Displays phase text and choices

// Plays (or prints rather) the text for the current choice (or phase of the event)
public void playPhase(){
System.out.println(phaseText);
for (int i = 0; i < numChoices; i++){
Expand All @@ -24,14 +24,12 @@ public void playPhase(){
System.out.println();
}

/*public void appendText(int choiceNum){
phaseText = EpChoices[choiceNum].getChangeToStory() + phaseText;
}*/

// Accessors and mutators
public int getNumChoices(){
return EpChoices.length;
}

// Simply a function to add text to pre-existing text
public void appendText(String text){
phaseText = text + phaseText;
}
Expand All @@ -52,7 +50,8 @@ public String getBaseText(){
return baseText;
}

public void resetPhaseText(){ //added
// Changes the phase text back to its original
public void resetPhaseText(){
phaseText = baseText;
}

Expand Down
18 changes: 10 additions & 8 deletions EventRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ public class EventRunner{
* 2 - Random event (reusable)
* 3 - Predetermined event (tracks time)
*/

//Constructor

public EventRunner(Player p, String eventFile, String endingsFile){
try {
player = p;
Expand All @@ -51,7 +50,7 @@ public EventRunner(Player p, String eventFile, String endingsFile){
String flush; //gets rid of empty lines in the file

numEndings = Integer.parseInt(in2.readLine());
endings = new Ending[numEndings];
endings = new Ending[numEndings];
for(int i = 0; i < numEndings; i++){ //reads in all the endings in the text file
title = in2.readLine();
luckReq = Integer.parseInt(in2.readLine());
Expand All @@ -66,7 +65,7 @@ public EventRunner(Player p, String eventFile, String endingsFile){
}
flush = in2.readLine();
endings[i] = new Ending (title, luckReq, hapReq, stat1, req1, stat2, req2, text);
text = "";
text = "";
}

EventPhase [] phases;
Expand Down Expand Up @@ -231,6 +230,8 @@ private Event evaluateStatsForEvents(int eventType, int month){
pE = events[i];
}
break;
default:
break;
}

if (eventType == 1) {
Expand All @@ -239,9 +240,9 @@ private Event evaluateStatsForEvents(int eventType, int month){
return pE;
}
} else if (eventType == 2){
if (pE instanceof Random) {
return pE;
}
if (pE instanceof Random) {
return pE;
}
} else if (eventType == 3){
if (pE instanceof Predetermined && !pE.getOccured()){
if (pE.getMonthReq() == month){
Expand All @@ -259,7 +260,6 @@ private Event evaluateStatsForEvents(int eventType, int month){
}

public void rollEvent(int month){
//updatePlayer(p); //updates player stats for any possible adjustments since last playing period
Event e;
e = evaluateStatsForEvents((int)(Math.random()*3) + 1, month);
e.play();
Expand Down Expand Up @@ -300,6 +300,8 @@ public int getAStat(int statType){ // general accessor for a player's stat, imp
return player.getStats().getHappiness();
case 8:
return player.getStats().getStrength();
default:
break;
}
return -1;
}
Expand Down
1 change: 0 additions & 1 deletion ExpressionCharismaEval.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
public class ExpressionCharismaEval extends Evaluations
{
//Contructor
public ExpressionCharismaEval(String name, Player plyr)
{
super(name,plyr);
Expand Down
16 changes: 14 additions & 2 deletions GameRunner.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
public class GameRunner
{
//Runs the game
public static void main (String[] args)
{
// Where the magic happens and the game is started to play
// If you are seeing this, that means you've successfully opened the correct Java files to play
// First, you should compile all 22 of the different Java files and ensure that there are no Compile Message errors
// If there are errors, usually they include which files should be compiled before that specific one can be compiled first
// Also ensure that the textfiles of EVENTS.txt & ENDINGS.txt are not Compressed
// This can be fixed by first copying the files into another folder
// Then deleting the original ones in this very folder (ICS-PROJECT-master)
// Move the copiedtext files over again back into this very folder (ICS-PROJECT-master)
// If the game can run without any crashing, then you are welcome to close all of the Java windows besides GameRunner.java
// and move up the screen so you can fully see what the game has to say!
// You can decide to end the current simulation by pressing 'End' and the game will save (assuming you've reached the checkpoint)
// With that, you can decide to return to your previous game or start a new game!
// Enjoy the AYJ Simulator!
Display d = new Display();
d.startGame();
}
}
}
1 change: 0 additions & 1 deletion LinguisticIntelligenceEval.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
public class LinguisticIntelligenceEval extends Evaluations
{
//Contructor
public LinguisticIntelligenceEval(String name, Player plyr)
{
super(name,plyr);
Expand Down
1 change: 0 additions & 1 deletion LogicalIntelligenceEval.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
public class LogicalIntelligenceEval extends Evaluations
{
//Constructor
public LogicalIntelligenceEval(String name, Player plyr)
{
super(name,plyr);
Expand Down
8 changes: 5 additions & 3 deletions Predetermined.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
public class Predetermined extends Event{

// Child of Event
// Only type of event which makes it so it can occur only on a specific date (e.g. prom)
private int month;
//Contructor
public Predetermined(String id, int statType, int statReq, int changeType, int changeAmount, int month, EventPhase[] phases){
super(id, statType, statReq, changeType, changeAmount, phases);
this.month = month;
}
//accessor

public int getMonthReq(){
return month;
}
}
}
6 changes: 4 additions & 2 deletions Random.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
public class Random extends Event{
//Constructor

// Child of Event
// Random events are recycable and can occur repeatedly
public Random(String id, int statType, int statReq, int changeType, int changeAmount, EventPhase[] phases){
super(id, statType, statReq, changeType, changeAmount, phases);
}
}
}
4 changes: 3 additions & 1 deletion Routine.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
public class Routine extends Event{
//Constructor

// Child of Event
// Routine events are similar to Random, however they cannot occur multiple times
public Routine(String id, int statType, int statReq, int changeType, int changeAmount, EventPhase[] phases){
super(id, statType, statReq, changeType, changeAmount, phases);
}
Expand Down
1 change: 1 addition & 0 deletions Stats.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

public class Stats {
// Object which stores all of the individual stats of a player
private int linguisticIntelligence;
private int spatialIntelligence;
private int logicalIntelligence;
Expand Down
Loading

0 comments on commit 971a0af

Please sign in to comment.