diff --git a/Projet/bin/Resources/BeginningConversation.txt b/Projet/bin/Resources/BeginningConversation.txt new file mode 100644 index 0000000..4817cf6 --- /dev/null +++ b/Projet/bin/Resources/BeginningConversation.txt @@ -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 ! 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 . \ No newline at end of file diff --git a/Projet/bin/Resources/Conversation b/Projet/bin/Resources/Conversation index ad61aee..a6e673b 100644 --- a/Projet/bin/Resources/Conversation +++ b/Projet/bin/Resources/Conversation @@ -1 +1,7 @@ -Welcome \ No newline at end of file +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 ! \ No newline at end of file diff --git a/Projet/bin/projet/Bag.class b/Projet/bin/projet/Bag.class new file mode 100644 index 0000000..4db6dde Binary files /dev/null and b/Projet/bin/projet/Bag.class differ diff --git a/Projet/bin/projet/City.class b/Projet/bin/projet/City.class new file mode 100644 index 0000000..f4f1aea Binary files /dev/null and b/Projet/bin/projet/City.class differ diff --git a/Projet/bin/projet/Command.class b/Projet/bin/projet/Command.class new file mode 100644 index 0000000..e8c32ad Binary files /dev/null and b/Projet/bin/projet/Command.class differ diff --git a/Projet/bin/projet/Game.class b/Projet/bin/projet/Game.class new file mode 100644 index 0000000..92ab033 Binary files /dev/null and b/Projet/bin/projet/Game.class differ diff --git a/Projet/bin/projet/Hero.class b/Projet/bin/projet/Hero.class new file mode 100644 index 0000000..6d6903a Binary files /dev/null and b/Projet/bin/projet/Hero.class differ diff --git a/Projet/bin/projet/Item.class b/Projet/bin/projet/Item.class new file mode 100644 index 0000000..d1d5b87 Binary files /dev/null and b/Projet/bin/projet/Item.class differ diff --git a/Projet/bin/projet/ItemMoney.class b/Projet/bin/projet/ItemMoney.class new file mode 100644 index 0000000..877fcab Binary files /dev/null and b/Projet/bin/projet/ItemMoney.class differ diff --git a/Projet/bin/projet/ItemTicket.class b/Projet/bin/projet/ItemTicket.class new file mode 100644 index 0000000..8c62860 Binary files /dev/null and b/Projet/bin/projet/ItemTicket.class differ diff --git a/Projet/bin/projet/Main.class b/Projet/bin/projet/Main.class new file mode 100644 index 0000000..5042efb Binary files /dev/null and b/Projet/bin/projet/Main.class differ diff --git a/Projet/bin/projet/NPC.class b/Projet/bin/projet/NPC.class new file mode 100644 index 0000000..c91fda5 Binary files /dev/null and b/Projet/bin/projet/NPC.class differ diff --git a/Projet/bin/projet/Parchment.class b/Projet/bin/projet/Parchment.class new file mode 100644 index 0000000..86556df Binary files /dev/null and b/Projet/bin/projet/Parchment.class differ diff --git a/Projet/bin/projet/Place.class b/Projet/bin/projet/Place.class new file mode 100644 index 0000000..b2f87b5 Binary files /dev/null and b/Projet/bin/projet/Place.class differ diff --git a/Projet/src/Resources/BeginningConversation.txt b/Projet/src/Resources/BeginningConversation.txt new file mode 100644 index 0000000..4817cf6 --- /dev/null +++ b/Projet/src/Resources/BeginningConversation.txt @@ -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 ! 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 . \ No newline at end of file diff --git a/Projet/src/Resources/Conversation b/Projet/src/Resources/Conversation index 4be6fc5..a6e673b 100644 --- a/Projet/src/Resources/Conversation +++ b/Projet/src/Resources/Conversation @@ -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. -Fine ! Nice to meet you ! 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 . - - 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 ! \ No newline at end of file diff --git a/Projet/src/projet/Bag.java b/Projet/src/projet/Bag.java new file mode 100644 index 0000000..8846b71 --- /dev/null +++ b/Projet/src/projet/Bag.java @@ -0,0 +1,35 @@ +package projet; +import java.util.ArrayList; + +public class Bag { + + private final ArrayList bagItem; + private final ArrayList bagParchment; + private final static int NBR_TOTAL_PARCHMENT = 5; + + public Bag() { + this.bagItem = new ArrayList(); + this.bagParchment = new ArrayList(); + } + + 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; + } + } +} diff --git a/Projet/src/projet/City.java b/Projet/src/projet/City.java new file mode 100644 index 0000000..c6c444f --- /dev/null +++ b/Projet/src/projet/City.java @@ -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 destination; + private ArrayList readDestination; + private final ArrayList 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(); + } + + public String getName() { + return this.name; + } + + public boolean hasAnAirport() { + return this.hasAnAirport; + } + + public ArrayList 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 readDestination(int idIndex) { + + readDestination = new ArrayList(); + + 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; + } +} diff --git a/Projet/src/projet/Command.java b/Projet/src/projet/Command.java new file mode 100644 index 0000000..1c081dc --- /dev/null +++ b/Projet/src/projet/Command.java @@ -0,0 +1,8 @@ +package projet; + +public class Command { + + public Command() { + + } +} diff --git a/Projet/src/projet/Game.java b/Projet/src/projet/Game.java new file mode 100644 index 0000000..294fa14 --- /dev/null +++ b/Projet/src/projet/Game.java @@ -0,0 +1,85 @@ +package projet; +import java.io.File; +import java.util.ArrayList; +import java.util.Scanner; + +public class Game { + + private ArrayList 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("", this.hero.getName()); + this.beginningText = this.beginningText.replace("", this.getDepartureCity().getName()); + System.out.println(this.beginningText); + } + + public void createCity() { + listCity = new ArrayList(); + 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); + } +} diff --git a/Projet/src/projet/Hero.java b/Projet/src/projet/Hero.java new file mode 100644 index 0000000..abfca13 --- /dev/null +++ b/Projet/src/projet/Hero.java @@ -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 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; + } +} diff --git a/Projet/src/projet/Item.java b/Projet/src/projet/Item.java new file mode 100644 index 0000000..8a3fe85 --- /dev/null +++ b/Projet/src/projet/Item.java @@ -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; + } +} diff --git a/Projet/src/projet/ItemMoney.java b/Projet/src/projet/ItemMoney.java new file mode 100644 index 0000000..dfc8d18 --- /dev/null +++ b/Projet/src/projet/ItemMoney.java @@ -0,0 +1,18 @@ +package projet; + +public class ItemMoney extends Item { + + private final String name; + private final int quantity; + + public ItemMoney(String name, int quantity) { + super(name, quantity); + this.quantity = quantity; + this.name = name; + } + + public String getDescription() { + return this.name + " : " + this.quantity; + } + +} diff --git a/Projet/src/projet/ItemTicket.java b/Projet/src/projet/ItemTicket.java new file mode 100644 index 0000000..d729285 --- /dev/null +++ b/Projet/src/projet/ItemTicket.java @@ -0,0 +1,17 @@ +package projet; + +public class ItemTicket extends Item { + + private final String name; + private final int quantity; + + public ItemTicket(String name, int quantity) { + super(name, quantity); + this.name = name; + this.quantity = quantity; + } + + public String getDescription() { + return this.name + " : " + this.quantity; + } +} diff --git a/Projet/src/projet/Main.java b/Projet/src/projet/Main.java new file mode 100644 index 0000000..16ac66e --- /dev/null +++ b/Projet/src/projet/Main.java @@ -0,0 +1,9 @@ +package projet; + +public class Main { + + public static void main(String[] args) { + + Game game = new Game(); + } +} diff --git a/Projet/src/projet/NPC.java b/Projet/src/projet/NPC.java new file mode 100644 index 0000000..a52e665 --- /dev/null +++ b/Projet/src/projet/NPC.java @@ -0,0 +1,47 @@ +package projet; +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +//package projet; + +/** + * + * @author Camille + */ +public abstract class NPC { + private final String NAME; + private boolean isActive; + private Item ITEM; + private final String Question; + private final String Answer; + + public NPC(String name,Item item,String Question,String Answer){ + this.NAME=name; + this.isActive=true; + this.ITEM=item; + this.Question=Question; + this.Answer=Answer; + } + + public void give_Item(Hero hero){ + hero.getBag().addItem(this.ITEM); //POUVOIR RECUPERER LE SAC DU HERO dans le HERO pour ajouter element à son sac + this.ITEM=null; + } + + public void verifyAnswer(String answer){ + if(this.Answer.equals(answer)){ + this.isActive=false; + } + } + + public boolean isActive(){ + return this.isActive; + } + + + //faire plusieurs perso avec un pouvoir juste comme augmenter l'argent etc.. + +} + diff --git a/Projet/src/projet/Parchment.java b/Projet/src/projet/Parchment.java new file mode 100644 index 0000000..dc71669 --- /dev/null +++ b/Projet/src/projet/Parchment.java @@ -0,0 +1,18 @@ +package projet; +public class Parchment { + + private int idParchment; + private boolean isActive; + + public Parchment(int idParchment) { + this.idParchment = idParchment; + } + + public int getIdParchment() { + return this.idParchment; + } + + public void isActive(boolean active) { + this.isActive = active; + } +} diff --git a/Projet/src/projet/Place.java b/Projet/src/projet/Place.java new file mode 100644 index 0000000..4cca472 --- /dev/null +++ b/Projet/src/projet/Place.java @@ -0,0 +1,47 @@ +package projet; +public class Place { + + private final String name; + private final boolean hasNPC; + private final boolean hasMoney; + private final boolean hasParchment; + + public Place(String name, NPC npc) { + this.name = name; + if(npc != null) { + this.hasNPC = true; + } + else { + this.hasNPC = false; + } + //Here function to randomise if there are Money nor parchment on the place + this.hasMoney = false; + this.hasParchment = false; + } + + public String getPlaceName() { + return this.name; + } + + //Useless + public Place getPlace() { + return this; + } + + public String getDescription() { + return this.name; + } + + public boolean hasObject() { + if(this.hasMoney || this.hasParchment) { + return true; + } + else { + return false; + } + } + + public boolean hasNPC() { + return this.hasNPC; + } +}