Skip to content
Open

#7 #2

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Projet/bin/Resources/BeginningConversation.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Welcome to gameName created by Marc L�ger, Camille Paquet, Micha�l Parmentier, Mathieu Pereira.
You must travel across the France to discover a treasure. You can go in 17 cities like Paris, Bordeaux or Poitiers.
To know where you can find the treasure you need to find 5 parchments in differents places which will give you the path to follow.
So I don't even know your name. Could you give me your name dear stranger.
Fine ! Nice to meet you <NAME> ! I give you a bag to carry your items and parchments. But you need some money to travel because the train or the airplane isn't free.
So I give you the incredible sum of 100 Donuts. It's forbidden to eat them !
And today I'm sweet so I give you one ticket to take the train or the airplane.
Now leave me alone ! We are arrived to the City Hall of <CITYNAME>.
8 changes: 7 additions & 1 deletion Projet/bin/Resources/Conversation
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
Welcome
Congrats ! You find 1 of 5 fragments parchments.
Congrats ! You find 2 of 5 fragments parchments.
Congrats ! You find 3 of 5 fragments parchments.
Congrats ! You find 4 of 5 fragments parchments.
CONGRATULATION ! You find all of the 5 fragments parchments. So now you have everything to take a treasure which gonna change your life !

You've discovered the treasure ! It was so simple this time ! Try one more time maybe it will be simpler !
Binary file added Projet/bin/projet/Bag.class
Binary file not shown.
Binary file added Projet/bin/projet/City.class
Binary file not shown.
Binary file added Projet/bin/projet/Command.class
Binary file not shown.
Binary file added Projet/bin/projet/Game.class
Binary file not shown.
Binary file added Projet/bin/projet/Hero.class
Binary file not shown.
Binary file added Projet/bin/projet/Item.class
Binary file not shown.
Binary file added Projet/bin/projet/ItemMoney.class
Binary file not shown.
Binary file added Projet/bin/projet/ItemTicket.class
Binary file not shown.
Binary file added Projet/bin/projet/Main.class
Binary file not shown.
Binary file added Projet/bin/projet/NPC.class
Binary file not shown.
Binary file added Projet/bin/projet/Parchment.class
Binary file not shown.
Binary file added Projet/bin/projet/Place.class
Binary file not shown.
8 changes: 8 additions & 0 deletions Projet/src/Resources/BeginningConversation.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Welcome to gameName created by Marc L�ger, Camille Paquet, Micha�l Parmentier, Mathieu Pereira.
You must travel across the France to discover a treasure. You can go in 17 cities like Paris, Bordeaux or Poitiers.
To know where you can find the treasure you need to find 5 parchments in differents places which will give you the path to follow.
So I don't even know your name. Could you give me your name dear stranger.
Fine ! Nice to meet you <NAME> ! I give you a bag to carry your items and parchments. But you need some money to travel because the train or the airplane isn't free.
So I give you the incredible sum of 100 Donuts. It's forbidden to eat them !
And today I'm sweet so I give you one ticket to take the train or the airplane.
Now leave me alone ! We are arrived to the City Hall of <CITYNAME>.
12 changes: 1 addition & 11 deletions Projet/src/Resources/Conversation
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
Welcome to gameName created by Marc Léger, Camille Paquet, Michaël Parmentier, Mathieu Pereira.
You must travel across the France to discover a treasure. You can go in 17 cities like Paris, Bordeaux or Poitiers.
To know where you can find the treasure you need to find 5 parchments in differents places which will give you the path to follow.
So I don't even know your name. Could you give your name dear stranger. <!NAME>
Fine ! Nice to meet you <NAME> ! I give you a bag to carry your items and parchments. But you need some money to travel because the train or the airplane isn't free.
So I give you the incredible sum of 100 Donuts. It's forbidden to eat them !
And today I'm sweet so I give you one ticket to take the train or the airplane.
Now leave me alone ! We are arrived to the City Hall of <CITYNAME>.
<DESCRIPTION LIEU>

Congrats ! You find 1 of 5 fragments parchments.
Congrats ! You find 2 of 5 fragments parchments.
Congrats ! You find 3 of 5 fragments parchments.
Congrats ! You find 4 of 5 fragments parchments.
CONGRATULATION ! You find all of the 5 fragments parchments. So now you have everything to take a treasure which gonna change your life !

You've discovered the treasure ! It was so simple this time ! Try one more time maybe it will be simpler !
You've discovered the treasure ! It was so simple this time ! Try one more time maybe it will be simpler !
35 changes: 35 additions & 0 deletions Projet/src/projet/Bag.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package projet;
import java.util.ArrayList;

public class Bag {

private final ArrayList <Item> bagItem;
private final ArrayList <Parchment> bagParchment;
private final static int NBR_TOTAL_PARCHMENT = 5;

public Bag() {
this.bagItem = new ArrayList<Item>();
this.bagParchment = new ArrayList<Parchment>();
}

public void addItem(Item item) {
this.bagItem.add(item);
}

public void removeItem(Item item) {
this.bagItem.remove(item);
}

public void addParchment(Parchment parchment) {
this.bagParchment.add(parchment);
}

public boolean hasAllParchment() {
if(this.bagParchment.size() == Bag.NBR_TOTAL_PARCHMENT) {
return true;
}
else {
return false;
}
}
}
124 changes: 124 additions & 0 deletions Projet/src/projet/City.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
package projet;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.NoSuchElementException;
import java.util.Scanner;

public class City {

private final String name;
private final boolean hasAnAirport;
private ArrayList <String> destination;
private ArrayList <String> readDestination;
private final ArrayList <Place> placeList;

private String cityName;
private String cityDestination1, cityDestination2, cityDestination3;
private String destinationString;

public City(String name, boolean hasAnAirport, int idIndex) {
this.name = name;
this.hasAnAirport = hasAnAirport;
this.destination = this.readDestination(idIndex);
placeList = new ArrayList<Place>();
}

public String getName() {
return this.name;
}

public boolean hasAnAirport() {
return this.hasAnAirport;
}

public ArrayList<String> getDestination() {
return this.destination;
}

public String getDescription() {
for(String e : destination) {
this.destinationString += " | " + e;
}
if(this.hasAnAirport) {
return "You are in " + this.name + " !" + "\n" + "There is an airport and a train station in this city \n" + "You can go to : " + this.destinationString;
}
else {
return "You are in " + this.name + " !" + "\n" + "There is no airport but a train station in this city \n" + "You can go to : " + this.destinationString;
}

}

public City getCity() {
return this;
}

public Place getPlace(String placeName) {
for(Place place : this.placeList) {
if(place.getPlaceName() == placeName)
{
return place;
}
}
return placeList.get(0);
}

public void createPlace() {
placeList.add(new Place("City-Hall", null));
placeList.add(new Place("Park", null));
placeList.add(new Place("Mall", null));
placeList.add(new Place("Museum", null));
placeList.add(new Place("Train-station", null));
placeList.add(new Place("Airport", null));
placeList.add(new Place("Parking", null));
}

public ArrayList<String> readDestination(int idIndex) {

readDestination = new ArrayList<String>();

try {
File f = new File("src/Resources/CityDestination.txt");
Scanner scanner = new Scanner(f);

try {
for(int i = 0; i < idIndex; i++) {
scanner.nextLine();
}

this.cityName = scanner.next();
//3 Cities
if(this.cityName.equals("Paris")) {
this.cityDestination1 = scanner.next();
this.cityDestination2 = scanner.next();
this.cityDestination3 = scanner.next();
}
//1 City
else if(this.cityName.equals("Nice") || this.cityName.equals("Brest")) {
this.cityDestination1 = scanner.next();
this.cityDestination2 = "";
this.cityDestination3 = "";
}
//2 Cities
else
{
this.cityDestination1 = scanner.next();
this.cityDestination2 = scanner.next();
this.cityDestination3 = "";
}
this.readDestination.add(this.cityDestination1);
this.readDestination.add(this.cityDestination2);
this.readDestination.add(this.cityDestination3);

scanner.close();
}
catch(NoSuchElementException e) {

}
}
catch (FileNotFoundException e) {
System.out.println("Fichier introuvable");
}
return this.readDestination;
}
}
8 changes: 8 additions & 0 deletions Projet/src/projet/Command.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package projet;

public class Command {

public Command() {

}
}
85 changes: 85 additions & 0 deletions Projet/src/projet/Game.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package projet;
import java.io.File;
import java.util.ArrayList;
import java.util.Scanner;

public class Game {

private ArrayList <City> listCity;
private Hero hero;
private String beginningText = "";

public Game() {
//Create ArrayList of City
this.createCity();

//Starting dialogue
this.startGame();

System.out.println(this.hero.getActualCity().getDescription());
}

public void startGame() {
try {
File f = new File("src/Resources/BeginningConversation.txt");
Scanner scanner = new Scanner(f);
Scanner scannerIN = new Scanner(System.in);

try {
for(int i = 0; i < 4; i++) {
this.beginningText += scanner.nextLine() + "\n";
}
System.out.println(this.beginningText);

//Initialization of the HERO
hero = new Hero(scannerIN.nextLine());

this.beginningText = "";

for(int i = 0; i < 4; i++) {
this.beginningText += scanner.nextLine() + "\n";
}
}
catch (Exception e) {
System.out.println(e);
scanner.close();
}
}
catch (Exception e) {
System.out.println(e);
}

this.beginningText = this.beginningText.replace("<NAME>", this.hero.getName());
this.beginningText = this.beginningText.replace("<CITYNAME>", this.getDepartureCity().getName());
System.out.println(this.beginningText);
}

public void createCity() {
listCity = new ArrayList<City>();
listCity.add(new City("Paris", true, 0));
listCity.add(new City("Marseille", true, 1));
listCity.add(new City("Lyon", true, 2));
listCity.add(new City("Bordeaux", true, 3));
listCity.add(new City("Lille", false, 4));
listCity.add(new City("Le Havre", false, 5));
listCity.add(new City("Rennes", false, 6));
listCity.add(new City("Strasbourg", false, 7));
listCity.add(new City("La Rochelle", false, 8));
listCity.add(new City("Nantes", false, 9));
listCity.add(new City("Toulouse", false, 10));
listCity.add(new City("Montpellier", false, 11));
listCity.add(new City("Nice", false, 12));
listCity.add(new City("Brest", false, 13));
listCity.add(new City("Dijon", false, 14));
listCity.add(new City("Poitiers", false, 15));
listCity.add(new City("Reims", false, 16));
}

public City getDepartureCity() {
double randIndex;
randIndex = Math.random() * this.listCity.size();
this.hero.setActualCity(this.listCity.get((int) randIndex));
this.hero.setPlace("City-Hall");
return this.listCity.get((int) randIndex);
}
}
55 changes: 55 additions & 0 deletions Projet/src/projet/Hero.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package projet;
import java.util.ArrayList;

public class Hero {

private final String name;
private int money;
private final static int MoneyDEF = 100;
private ArrayList <City> alreadyVisitCity;
private City actualCity;
private Place actualPlace;
private Bag bag;

public Hero(String name) {
this.name = name;
this.money = Hero.MoneyDEF;
bag = new Bag();
}

public int getMoney() {
return this.money;
}

public void addMoney(int money) {
this.money += money;
}

public String getName() {
return this.name;
}

public Place getActualPlace() {
return this.actualPlace;
}

public void setPlace(Place actualPlace) {
this.actualPlace = actualPlace;
}

public void setPlace(String placeName) {
//this.actualPlace =
}

public City getActualCity() {
return this.actualCity;
}

public void setActualCity(City actualCity) {
this.actualCity = actualCity;
}

public Bag getBag() {
return this.bag;
}
}
28 changes: 28 additions & 0 deletions Projet/src/projet/Item.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package projet;

public class Item {
private final String name;
private final int quantity;
private boolean isActive;

public Item(String name, int quantity) {
this.name = name;
this.quantity = quantity;
this.isActive = true;
}

public String getDescription() {
return "Ceci est l'item : " + this.name;
}

public int getQuantity() {
return this.quantity;
}

public void isActive(boolean active) {
this.isActive = active;
}
public boolean isActive() {
return this.isActive;
}
}
Loading