NetBeansProjects

This commit is contained in:
Clement Bouillot
2021-05-28 10:56:04 +02:00
commit 068f9156f9
121 changed files with 10836 additions and 0 deletions

View File

@@ -0,0 +1,73 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See commented blocks below for -->
<!-- some examples of how to customize the build. -->
<!-- (If you delete it and reopen the project it will be recreated.) -->
<!-- By default, only the Clean and Build commands use this build script. -->
<!-- Commands such as Run, Debug, and Test only use this build script if -->
<!-- the Compile on Save feature is turned off for the project. -->
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
<!-- in the project's Project Properties dialog box.-->
<project name="JeuDeRole2" default="default" basedir=".">
<description>Builds, tests, and runs the project JeuDeRole2.</description>
<import file="nbproject/build-impl.xml"/>
<!--
There exist several targets which are by default empty and which can be
used for execution of your tasks. These targets are usually executed
before and after some main targets. They are:
-pre-init: called before initialization of project properties
-post-init: called after initialization of project properties
-pre-compile: called before javac compilation
-post-compile: called after javac compilation
-pre-compile-single: called before javac compilation of single file
-post-compile-single: called after javac compilation of single file
-pre-compile-test: called before javac compilation of JUnit tests
-post-compile-test: called after javac compilation of JUnit tests
-pre-compile-test-single: called before javac compilation of single JUnit test
-post-compile-test-single: called after javac compilation of single JUunit test
-pre-jar: called before JAR building
-post-jar: called after JAR building
-post-clean: called after cleaning build products
(Targets beginning with '-' are not intended to be called on their own.)
Example of inserting an obfuscator after compilation could look like this:
<target name="-post-compile">
<obfuscate>
<fileset dir="${build.classes.dir}"/>
</obfuscate>
</target>
For list of available properties check the imported
nbproject/build-impl.xml file.
Another way to customize the build is by overriding existing main targets.
The targets of interest are:
-init-macrodef-javac: defines macro for javac compilation
-init-macrodef-junit: defines macro for junit execution
-init-macrodef-debug: defines macro for class debugging
-init-macrodef-java: defines macro for class execution
-do-jar: JAR building
run: execution of project
-javadoc-build: Javadoc generation
test-report: JUnit report generation
An example of overriding the target for project execution could look like this:
<target name="run" depends="JeuDeRole2-impl.jar">
<exec dir="bin" executable="launcher.exe">
<arg file="${dist.jar}"/>
</exec>
</target>
Notice that the overridden target depends on the jar target and not only on
the compile target as the regular run target does. Again, for a list of available
properties which you can use, check the target you are overriding in the
nbproject/build-impl.xml file.
-->
</project>

View File

@@ -0,0 +1,4 @@
#Wed, 05 May 2021 09:30:40 +0200
/home/clement.bouillot/NetBeansProjects/JeuDeRole2=

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View File

@@ -0,0 +1,3 @@
Manifest-Version: 1.0
X-COMMENT: Main-Class will be added automatically by build

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,8 @@
build.xml.data.CRC32=17786340
build.xml.script.CRC32=221123fd
build.xml.stylesheet.CRC32=f85dc8f2@1.95.0.48
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=17786340
nbproject/build-impl.xml.script.CRC32=f1457fcd
nbproject/build-impl.xml.stylesheet.CRC32=f89f7d21@1.95.0.48

View File

@@ -0,0 +1,2 @@
compile.on.save=true
user.properties.file=/home/clement.bouillot/.netbeans/12.0/build.properties

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
<group>
<file>file:/home/clement.bouillot/NetBeansProjects/JeuDeRole2/src/metier/Personnage.java</file>
<file>file:/home/clement.bouillot/NetBeansProjects/JeuDeRole2/src/metier/Voleur.java</file>
<file>file:/home/clement.bouillot/NetBeansProjects/JeuDeRole2/src/metier/Affrontement.java</file>
<file>file:/home/clement.bouillot/NetBeansProjects/JeuDeRole2/src/jeuderole/JeuDeRole.java</file>
<file>file:/home/clement.bouillot/NetBeansProjects/JeuDeRole2/src/metier/Enigme.java</file>
<file>file:/home/clement.bouillot/NetBeansProjects/JeuDeRole2/src/metier/Sorcier.java</file>
<file>file:/home/clement.bouillot/NetBeansProjects/JeuDeRole2/src/metier/Jeu.java</file>
<file>file:/home/clement.bouillot/NetBeansProjects/JeuDeRole2/src/metier/Guerrier.java</file>
</group>
</open-files>
</project-private>

View File

@@ -0,0 +1,95 @@
annotation.processing.enabled=true
annotation.processing.enabled.in.editor=false
annotation.processing.processor.options=
annotation.processing.processors.list=
annotation.processing.run.all.processors=true
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
build.classes.dir=${build.dir}/classes
build.classes.excludes=**/*.java,**/*.form
# This directory is removed when the project is cleaned:
build.dir=build
build.generated.dir=${build.dir}/generated
build.generated.sources.dir=${build.dir}/generated-sources
# Only compile against the classpath explicitly listed here:
build.sysclasspath=ignore
build.test.classes.dir=${build.dir}/test/classes
build.test.results.dir=${build.dir}/test/results
# Uncomment to specify the preferred debugger connection transport:
#debug.transport=dt_socket
debug.classpath=\
${run.classpath}
debug.modulepath=\
${run.modulepath}
debug.test.classpath=\
${run.test.classpath}
debug.test.modulepath=\
${run.test.modulepath}
# Files in build.classes.dir which should be excluded from distribution jar
dist.archive.excludes=
# This directory is removed when the project is cleaned:
dist.dir=dist
dist.jar=${dist.dir}/JeuDeRole2.jar
dist.javadoc.dir=${dist.dir}/javadoc
dist.jlink.dir=${dist.dir}/jlink
dist.jlink.output=${dist.jlink.dir}/JeuDeRole2
excludes=
includes=**
jar.compress=false
javac.classpath=
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false
javac.external.vm=true
javac.modulepath=
javac.processormodulepath=
javac.processorpath=\
${javac.classpath}
javac.source=11
javac.target=11
javac.test.classpath=\
${javac.classpath}:\
${build.classes.dir}
javac.test.modulepath=\
${javac.modulepath}
javac.test.processorpath=\
${javac.test.classpath}
javadoc.additionalparam=
javadoc.author=false
javadoc.encoding=${source.encoding}
javadoc.html5=false
javadoc.noindex=false
javadoc.nonavbar=false
javadoc.notree=false
javadoc.private=false
javadoc.splitindex=true
javadoc.use=true
javadoc.version=false
javadoc.windowtitle=
# The jlink additional root modules to resolve
jlink.additionalmodules=
# The jlink additional command line parameters
jlink.additionalparam=
jlink.launcher=true
jlink.launcher.name=JeuDeRole2
main.class=jeuderole.JeuDeRole
manifest.file=manifest.mf
meta.inf.dir=${src.dir}/META-INF
mkdist.disabled=false
platform.active=default_platform
run.classpath=\
${javac.classpath}:\
${build.classes.dir}
# Space-separated list of JVM arguments used when running the project.
# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
# To set system properties for unit tests define test-sys-prop.name=value:
run.jvmargs=
run.modulepath=\
${javac.modulepath}
run.test.classpath=\
${javac.test.classpath}:\
${build.test.classes.dir}
run.test.modulepath=\
${javac.test.modulepath}
source.encoding=UTF-8
src.dir=src
test.src.dir=test

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.java.j2seproject</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
<name>JeuDeRole2</name>
<source-roots>
<root id="src.dir"/>
</source-roots>
<test-roots>
<root id="test.src.dir"/>
</test-roots>
</data>
</configuration>
</project>

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View File

@@ -0,0 +1,90 @@
/*
* 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 jeuderole;
import java.util.ArrayList;
import metier.Guerrier;
import metier.Jeu;
import metier.Personnage;
import metier.Sorcier;
import metier.Voleur;
/**
*
* @author Dominique_2
*/
public class JeuDeRole {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
/* System.out.println("1. Création de 2 guerrier identiques : ");
Guerrier leGuerrier1 = new Guerrier("Invincible", "Guerrier05.JPG", 30, 10, "Epée");
Guerrier leGuerrier2 = new Guerrier("Invincible", "Guerrier05.JPG", 30, 10, "Epée");
System.out.println("\tleGuerrier1 : " + leGuerrier1);
System.out.println("\tleGuerrier2 : " + leGuerrier2);
System.out.println("\n2. Comparaison des 2 guerriers : ");
if (leGuerrier1.equals(leGuerrier2)) {
System.out.println("\tLes 2 guerriers sont identiques");
} else {
System.out.println("\tLes 2 guerriers sont différents");
}
System.out.println("\n3. Création d'un 3ème guerrier : et comparaison guerrier1 et guerrier3");
Guerrier leGuerrier3 = new Guerrier("Spartacus", "Guerrier05.JPG", 30, 10, "Epée");
System.out.println("\tleGuerrier3 : " + leGuerrier3);
if (leGuerrier1.equals(leGuerrier3)) {
System.out.println("\tLes 2 guerriers sont identiques");
} else {
System.out.println("\tLes 2 guerriers sont différents");
}
System.out.println("\n4. Création d'un Sorcier et d'un Voleur : ");
Sorcier laSorciere = new Sorcier("ReineSorciere", "Sorciere1.jpg", 20, 30, "Pomme","enigme");
Voleur leVoleur1 = new Voleur("Arsène Lupin", "Barbare04.jpg", 15, 25, "Pince");
System.out.println("\tlaSorciere : " + laSorciere);
System.out.println("\tleVoleur1 : " + leVoleur1);
System.out.println("\n5. Rencontre entre le sorcier et le guerrier2 : ");
//System.out.println(laSorciere.rencontrer(leGuerrier2));
System.out.println("\n6. Salutation entre la sorciere et le guerrier2 : ");
laSorciere.saluer(leGuerrier2);
System.out.println("\n7. Salutation entre le guerrier2 et le voleur1 : ");
leGuerrier2.saluer(leVoleur1);
System.out.println("\n8. Salutation entre le voleur1 et la sorciere : ");
leVoleur1.saluer(laSorciere);
// Création d'une collection de Personnage
ArrayList<Personnage> lesPersonnages = new ArrayList<>();
Personnage g1 = new Guerrier("Barbare","", 6, 4, "Hache");
lesPersonnages.add(g1);
Personnage v1 = new Voleur("Raptout", "", 2, 4 , "Marteau");
lesPersonnages.add(v1);
Sorcier s1 = new Sorcier("Panoramix","", 10, 5, "De laurier","Enigme");
lesPersonnages.add(s1);
System.out.println("\n9. Collection de personnages créée :\n "+lesPersonnages);
System.out.println("\n10. Rencontre entre le guerrier2 et la sorcière : ");
leGuerrier2.rencontrer(laSorciere);
System.out.println("\n11. Rencontre entre un voleur et la sorcière : ");
leVoleur1.rencontrer(laSorciere);
*/
Jeu unJeu=new Jeu("Rencontre fatale");
unJeu.getLesPersonnages().get(5).rencontrer(unJeu.getLesPersonnages().get(6));
unJeu.getLesPersonnages().get(6).setEnergie(0);
unJeu.getLesPersonnages().get(5).combattre(unJeu.getLesPersonnages().get(6));
}
}

View File

@@ -0,0 +1,317 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jPanel2" min="-2" max="-2" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="220" max="-2" attributes="0"/>
<Component id="okBT" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="jPanel1" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jPanel1" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="jPanel2" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="okBT" min="-2" pref="31" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JPanel" name="jPanel1">
<Properties>
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="33" green="33" red="33" type="rgb"/>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jScrollPane1" pref="237" max="32767" attributes="0"/>
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<Component id="image1" min="-2" pref="209" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="10" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="18" max="-2" attributes="0"/>
<Component id="image1" pref="0" max="32767" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="jScrollPane1" min="-2" pref="368" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="image1">
<Properties>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="ee" green="ee" red="ee" type="rgb"/>
</Property>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/img/adj_1.jpg"/>
</Property>
</Properties>
</Component>
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
<AuxValues>
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JTextArea" name="descriptionAffrontement">
<Properties>
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="33" green="33" red="33" type="rgb"/>
</Property>
<Property name="columns" type="int" value="20"/>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="ee" green="ee" red="ee" type="rgb"/>
</Property>
<Property name="rows" type="int" value="5"/>
<Property name="text" type="java.lang.String" value="Texte"/>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="jPanel2">
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jPanel3" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="149" max="-2" attributes="0"/>
<Component id="image2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="6" max="-2" attributes="0"/>
<Component id="image2" min="-2" pref="124" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="jPanel3" max="32767" attributes="0"/>
<EmptySpace min="-2" pref="6" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="image2">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/img/famille_1.jpg"/>
</Property>
</Properties>
</Component>
<Container class="javax.swing.JPanel" name="jPanel3">
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jPanel4" min="-2" max="-2" attributes="0"/>
<Component id="choixAttaquant" min="-2" pref="200" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="43" max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jPanel5" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="choixAttaqué" alignment="1" min="-2" pref="200" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="choixAttaquant" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="choixAttaqué" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jPanel4" max="32767" attributes="0"/>
<Component id="jPanel5" max="32767" attributes="0"/>
</Group>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JComboBox" name="choixAttaquant">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="4">
<StringItem index="0" value="Item 1"/>
<StringItem index="1" value="Item 2"/>
<StringItem index="2" value="Item 3"/>
<StringItem index="3" value="Item 4"/>
</StringArray>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="choixAttaquantActionPerformed"/>
</Events>
<AuxValues>
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="&lt;String&gt;"/>
</AuxValues>
</Component>
<Component class="javax.swing.JComboBox" name="choixAttaqu&#xe9;">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="4">
<StringItem index="0" value="Item 1"/>
<StringItem index="1" value="Item 2"/>
<StringItem index="2" value="Item 3"/>
<StringItem index="3" value="Item 4"/>
</StringArray>
</Property>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="&lt;String&gt;"/>
</AuxValues>
</Component>
<Container class="javax.swing.JPanel" name="jPanel4">
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="descriprionAttaquant" min="-2" pref="201" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="62" max="-2" attributes="0"/>
<Component id="imageAttaquant" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="descriprionAttaquant" min="-2" pref="181" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="32" max="-2" attributes="0"/>
<Component id="imageAttaquant" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="45" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JTextField" name="descriprionAttaquant">
<Properties>
<Property name="text" type="java.lang.String" value="jTextField1"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="imageAttaquant">
<Properties>
<Property name="text" type="java.lang.String" value="jLabel1"/>
</Properties>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="jPanel5">
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="61" max="-2" attributes="0"/>
<Component id="imageAttaqué" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<Component id="descriptionAttaqué" min="-2" pref="201" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="descriptionAttaqué" min="-2" pref="181" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="32" max="-2" attributes="0"/>
<Component id="imageAttaqué" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JTextField" name="descriptionAttaqu&#xe9;">
<Properties>
<Property name="text" type="java.lang.String" value="jTextField2"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="imageAttaqu&#xe9;">
<Properties>
<Property name="text" type="java.lang.String" value="jLabel2"/>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Container>
</SubComponents>
</Container>
<Component class="javax.swing.JToggleButton" name="okBT">
<Properties>
<Property name="text" type="java.lang.String" value="Ok"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="okBTActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Form>

View File

@@ -0,0 +1,254 @@
/*
* 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 metier;
/**
*
* @author clement.bouillot
*/
public class Affrontement extends javax.swing.JPanel {
/**
* Creates new form Affrontement
*/
public Affrontement() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
image1 = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
descriptionAffrontement = new javax.swing.JTextArea();
jPanel2 = new javax.swing.JPanel();
image2 = new javax.swing.JLabel();
jPanel3 = new javax.swing.JPanel();
choixAttaquant = new javax.swing.JComboBox<>();
choixAttaqué = new javax.swing.JComboBox<>();
jPanel4 = new javax.swing.JPanel();
descriprionAttaquant = new javax.swing.JTextField();
imageAttaquant = new javax.swing.JLabel();
jPanel5 = new javax.swing.JPanel();
descriptionAttaqué = new javax.swing.JTextField();
imageAttaqué = new javax.swing.JLabel();
okBT = new javax.swing.JToggleButton();
jPanel1.setBackground(new java.awt.Color(51, 51, 51));
image1.setForeground(new java.awt.Color(238, 238, 238));
image1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/adj_1.jpg"))); // NOI18N
descriptionAffrontement.setBackground(new java.awt.Color(51, 51, 51));
descriptionAffrontement.setColumns(20);
descriptionAffrontement.setForeground(new java.awt.Color(238, 238, 238));
descriptionAffrontement.setRows(5);
descriptionAffrontement.setText("Texte");
jScrollPane1.setViewportView(descriptionAffrontement);
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 237, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(image1, javax.swing.GroupLayout.PREFERRED_SIZE, 209, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(10, 10, 10)))
.addContainerGap())
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(18, 18, 18)
.addComponent(image1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
.addGap(18, 18, 18)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 368, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
image2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/famille_1.jpg"))); // NOI18N
choixAttaquant.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
choixAttaquant.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
choixAttaquantActionPerformed(evt);
}
});
choixAttaqué.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
descriprionAttaquant.setText("jTextField1");
imageAttaquant.setText("jLabel1");
javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
jPanel4.setLayout(jPanel4Layout);
jPanel4Layout.setHorizontalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addComponent(descriprionAttaquant, javax.swing.GroupLayout.PREFERRED_SIZE, 201, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE))
.addGroup(jPanel4Layout.createSequentialGroup()
.addGap(62, 62, 62)
.addComponent(imageAttaquant)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel4Layout.setVerticalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addComponent(descriprionAttaquant, javax.swing.GroupLayout.PREFERRED_SIZE, 181, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(32, 32, 32)
.addComponent(imageAttaquant)
.addContainerGap(45, Short.MAX_VALUE))
);
descriptionAttaqué.setText("jTextField2");
imageAttaqué.setText("jLabel2");
javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
jPanel5.setLayout(jPanel5Layout);
jPanel5Layout.setHorizontalGroup(
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel5Layout.createSequentialGroup()
.addGap(61, 61, 61)
.addComponent(imageAttaqué)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(descriptionAttaqué, javax.swing.GroupLayout.PREFERRED_SIZE, 201, javax.swing.GroupLayout.PREFERRED_SIZE))
);
jPanel5Layout.setVerticalGroup(
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel5Layout.createSequentialGroup()
.addComponent(descriptionAttaqué, javax.swing.GroupLayout.PREFERRED_SIZE, 181, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(32, 32, 32)
.addComponent(imageAttaqué)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(choixAttaquant, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 43, Short.MAX_VALUE)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel5, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(choixAttaqué, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(choixAttaquant, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(choixAttaqué, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
);
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(149, 149, 149)
.addComponent(image2)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(6, 6, 6)
.addComponent(image2, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(6, 6, 6))
);
okBT.setText("Ok");
okBT.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
okBTActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addGap(220, 220, 220)
.addComponent(okBT)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(okBT, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
}// </editor-fold>//GEN-END:initComponents
private void okBTActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okBTActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_okBTActionPerformed
private void choixAttaquantActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_choixAttaquantActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_choixAttaquantActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JComboBox<String> choixAttaquant;
private javax.swing.JComboBox<String> choixAttaqué;
private javax.swing.JTextField descriprionAttaquant;
private javax.swing.JTextArea descriptionAffrontement;
private javax.swing.JTextField descriptionAttaqué;
private javax.swing.JLabel image1;
private javax.swing.JLabel image2;
private javax.swing.JLabel imageAttaquant;
private javax.swing.JLabel imageAttaqué;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JPanel jPanel4;
private javax.swing.JPanel jPanel5;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JToggleButton okBT;
// End of variables declaration//GEN-END:variables
}

View File

@@ -0,0 +1,51 @@
package metier;
import java.io.Serializable;
/**
*
* @author Dominique_2
*/
public class Enigme implements Serializable{
private String question;
private String reponse;
/**
* @return the question
*/
public String getQuestion() {
return question;
}
/**
* @param question the question to set
*/
public void setQuestion(String question) {
this.question = question;
}
/**
* @return the reponse
*/
public String getReponse() {
return reponse;
}
/**
* @param reponse the reponse to set
*/
public void setReponse(String reponse) {
this.reponse = reponse;
}
public Enigme(String question, String reponse) {
this.question = question;
this.reponse = reponse;
}
@Override
public String toString() {
return "Enigme {" + "question=" + question + ", reponse=" + reponse + '}';
}
}

View File

@@ -0,0 +1,146 @@
package metier;
import java.util.Objects;
import javax.swing.Icon;
import javax.swing.JOptionPane;
import static javax.swing.JOptionPane.WARNING_MESSAGE;
/**
* Classe Guerrier, hérite de la classe Personnage
* @author Dominique_2
* @version 20210311
*/
public class Guerrier extends Personnage{
// Variable membre
private String arme;
/**
* Valorisation des variables membres
* @param nom nom du guerrier
* @param img nom de l'image représentant le guerrier
* @param energie valeur énergétique du guerrier
* @param dureeVie durée de vie du guerrier
* @param arme armu du guerrier
*/
public Guerrier(String nom, String img, int energie, int dureeVie, String arme) {
super(nom, img, energie, dureeVie);
this.arme = arme;
}
/**
* Permet d'obtenir les valeurs des attributs de l'objet courant
* @return liste des attributs avec leurs valeurs
*/
@Override
public String toString() {
return super.toString() + "\n\tGuerrier{" + "arme=" + arme + '}';
}
@Override
public int hashCode() {
int hash = 7;
hash = super.hashCode() + (13 * hash + Objects.hashCode(this.arme));
return hash;
}
/**
* Comparaison de l'objet courant avec l'objet passé en paramètre
* @param obj objet à comparer avec l'objet courant
* @return true : les 2 objets sont identiques, false sinon
*/
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Guerrier other = (Guerrier) obj;
if (!Objects.equals(this.arme, other.arme)) {
return false;
}
if(!super.equals(obj)){
return false;
}
return true;
}
/**
* Get the value of arme *
* @return the value of arme
*/
public String getArme() {
return arme;
}
/**
* Set the value of arme *
* @param arme new value of arme
*/
public void setArme(String arme) {
this.arme = arme;
}
/**
* Rencontre du guerrier avec un autre personnage (Combat de dés)
* @param p
*/
@Override
public void rencontrer(Personnage p) {
Icon iCombat;
Icon iDes = new javax.swing.ImageIcon(getClass().getResource("../img/des.jpg"));
int score1 = 0;
int score2 = 0;
int nbJeu = 0;
String message = "Es-tu prêt à me combattre " + p.getNom() + " ? " ;
String titre = this.getNom() + " rencontre " + p.getNom() + " : ";
while (score1 == score2) {
if (nbJeu > 0) {
message = "Égalité. Rejoue vite ";
}
JOptionPane.showMessageDialog( null,
message,
titre + "défi dés",
WARNING_MESSAGE,
iDes);
score1 = Jeu.genererNbAleatoire(1, 6);
score2 = Jeu.genererNbAleatoire(1, 6);
nbJeu++;
}
String resultat="Ton score : " + score2 + " - Le mien : " + score1;
int type;
if (score1 >= score2) {
resultat += "\n\nTu as perdu,"
+ "\nattention à toi " + p.getNom()
+ ",\nta vie est en danger!";
iCombat = new javax.swing.ImageIcon(getClass().getResource("/img/Combat.jpg"));
p.varierDureeVie(-1);
p.varierEnergie(-2);
} else {
resultat += "\n\nTu as gagné ce défi,"
+ "\nmais je me vengerai de toi,\n"
+ p.getNom() +", prends garde à toi!";
iCombat = new javax.swing.ImageIcon(getClass().getResource("/img/CombatPerdu.jpg"));
p.varierEnergie(+2); // +2 pour le gagnant attaqué
varierEnergie(-1); // -1 pour le perdant attaquant
}
JOptionPane.showMessageDialog( null,
resultat,
titre + "résultat",
WARNING_MESSAGE,
iCombat);
}
/**
* Rencontre avec un autre personnage
* @param unPerso personnage à saluer
*/
@Override
public void saluer(Personnage unPerso) {
String titre = this.getNom() + " salue " + unPerso.getNom();
String message = "Bonjour " + unPerso.getNom() + ", \nsauve-toi vite avant que je ne te frappe avec mon arme redoutable!";
JOptionPane.showMessageDialog(null, message, titre, JOptionPane.INFORMATION_MESSAGE);
}
}

View File

@@ -0,0 +1,141 @@
package metier;
import java.util.ArrayList;
import java.util.Vector;
/**
*
* @author Dominique_2
*/
public class Jeu {
private String nomJeu;
private ArrayList<Personnage> lesPersonnages;
/**
* @return the nomJeu
*/
public String getNomJeu() {
return nomJeu;
}
/**
* @return the lesPersonnages
*/
public ArrayList<Personnage> getLesPersonnages() {
return lesPersonnages;
}
@Override
public String toString() {
return "Jeu{" + "lesPersonnages=" + lesPersonnages + '}';
}
/**
* Constructeur
*
* @param nomJeu
*/
public Jeu(String nomJeu) {
this.nomJeu = nomJeu;
this.lesPersonnages = new ArrayList<>();
chargerLesPersonnages();
}
/**
* Création des personnages du jeu
*/
public void chargerLesPersonnages() {
Personnage g1 = new Guerrier("Dudule", "Guerrier05.JPG", 5, 6, "Epée");
Personnage g2 = new Guerrier("Toto", "Guerrier10.JPG", 8, 7, "Epée");
Personnage g3 = new Guerrier("Dur à cuire", "Guerrier08.JPG", 4, 5, "Poignard");
Personnage g4 = new Guerrier("Prêt à tout", "Guerrier12.JPG", 6, 4, "Matraque");
lesPersonnages.add(g1);
lesPersonnages.add(g2);
lesPersonnages.add(g3);
lesPersonnages.add(g4);
Personnage clampin = new Personnage("Simone", "Simone.JPG", 4, 3);
lesPersonnages.add(clampin);
Sorcier s1 = new Sorcier("Panoramix", "panoramix.gif", 10, 5, "Sortilèges");
Enigme uneEnigme = new Enigme("Je suis vague en bord de mer.\n"
+ "Je descends des montagnes en hiver.\n"
+ "Sans moi vous n'aurez plus une larme.",
"L'eau");
s1.ajouterEnigme(uneEnigme);
uneEnigme = new Enigme("Je serai hier, j'étais demain.",
"Aujourd'hui");
s1.ajouterEnigme(uneEnigme);
uneEnigme = new Enigme("Si de ton doigt tu veux me toucher, apprête toi alors à le retirer.\n"
+ "Mais si tu sais me manipuler ta demeure en sera réchauffée et illuminée.\n"
+ "Qui suis-je ?",
"Le feu");
s1.ajouterEnigme(uneEnigme);
uneEnigme = new Enigme("Je suis si fragile que lorsque l'on prononce mon nom, je meurs.",
"Le silence");
s1.ajouterEnigme(uneEnigme);
lesPersonnages.add(s1);
s1 = new Sorcier("FaitPeur", "Sorcier02.JPG", 10, 4, "Sortilèges");
s1.ajouterEnigme(uneEnigme);
uneEnigme = new Enigme("Connu pour ses galeries,\n"
+ "Et le ton de son gris,\n"
+ "Elle évoque la mauvaise vision,\n"
+ "Et c'est un excellent espion",
"La taupe");
s1.ajouterEnigme(uneEnigme);
uneEnigme = new Enigme("Symbole de maladresse, pour beaucoup je suis signe de malédiction.\n"
+ "Quand on passe l'arme, c'est parfois à moi.\n"
+ "Que suis-je ?",
"La gauche");
s1.ajouterEnigme(uneEnigme);
uneEnigme = new Enigme("Vous ne pouvez que me deviner et ne pouvez qu'avancer vers moi.\n"
+ "Quand vous arrivez, je ne suis plus là.\n"
+ "Car à chaque pas avancé, je recule d'autant.\n"
+ "Que suis-je ?",
"Le futur");
s1.ajouterEnigme(uneEnigme);
lesPersonnages.add(s1);
Personnage rapTout = new Voleur("Raptout", "Barbare04.jpg", 2, 4, "Tournevis");
lesPersonnages.add(rapTout);
}
/**
* Recherche du personnage dont le nom est passé en paramètre
*
* @param n nom du personnage recherché
* @return personnage correspondant au nom s'il existe, null sinon
*/
public Personnage rechercherPerso(String n) {
int i = 0;
Personnage p = null;
while (p == null && i < lesPersonnages.size()) {
if (lesPersonnages.get(i).getNom().equals(n)) {
p = lesPersonnages.get(i);
} else {
i++;
}
}
return p;
}
/**
* Recherche d'un nombre aléatoire entre min et max inclus
*
* @param min
* @param max
* @return entier compris entre min et max
*/
public static int genererNbAleatoire(int min, int max) {
return min + (int) (Math.random() * ((max - min) + 1));
}
/* public Vector<String> getPersonnagesVivants{
}
*/
}

View File

@@ -0,0 +1,195 @@
package metier;
import java.util.Objects;
import javax.swing.Icon;
import javax.swing.JOptionPane;
/**
* Classe Mère Personnage
* @author Dominique_2
* @version 20210311
*/
public class Personnage {
// Variables membres
private String nom;
private String img;
private int energie;
private int dureeVie;
/**
* Valorisation des variables membres
* @param nom nom du personnage
* @param img nom de l'image du personnage
* @param energie valeur énergétique
* @param dureeVie durée de vie, en année
*/
public Personnage(String nom, String img, int energie, int dureeVie) {
this.nom = nom;
this.img = img;
this.energie = energie;
this.dureeVie = dureeVie;
}
/**
* Permet d'obtenir les valeurs des attributs de l'objet courant
* @return liste des attributs avec leurs valeurs
*/
@Override
public String toString() {
return "Personnage{" + "nom=" + nom + ", img=" + img + ", energie=" + energie + ", dureeVie=" + dureeVie + '}';
}
@Override
public int hashCode() {
int hash = 3;
hash = 47 * hash + Objects.hashCode(this.nom);
hash = 47 * hash + Objects.hashCode(this.img);
hash = 47 * hash + this.energie;
hash = 47 * hash + this.dureeVie;
return hash;
}
/**
* Comparaison de l'objet courant avec l'objet passé en paramètre
* @param obj objet à comparer avec l'objet courant
* @return true : les 2 objets sont identiques, false sinon
*/
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Personnage other = (Personnage) obj;
if (this.energie != other.energie) {
return false;
}
if (this.dureeVie != other.dureeVie) {
return false;
}
if (!Objects.equals(this.nom, other.nom)) {
return false;
}
if (!Objects.equals(this.img, other.img)) {
return false;
}
return true;
}
/**
* Get the value of energie *
* @return the value of energie
*/
public int getEnergie() {
return energie;
}
/**
* Set the value of energie *
* @param energie new value of energie
*/
public void setEnergie(int energie) {
this.energie = energie;
}
/**
* Get the value of dureeVie *
* @return the value of dureeVie
*/
public int getDureeVie() {
return dureeVie;
}
/**
* Set the value of dureeVie *
* @param dureeVie new value of dureeVie
*/
public void setDureeVie(int dureeVie) {
this.dureeVie = dureeVie;
}
/**
* Get the value of img *
* @return the value of img
*/
public String getImg() {
return img;
}
/**
* Set the value of img *
* @param img new value of img
*/
public void setImg(String img) {
this.img = img;
}
/**
* Get the value of nom *
* @return the value of nom
*/
public String getNom() {
return nom;
}
/**
* Set the value of nom *
* @param nom new value of nom
*/
public void setNom(String nom) {
this.nom = nom;
}
/**
* Rencontre avec un autre personnage
* @param unPerso : personnage rencontré
* @return
*/
public void rencontrer(Personnage unPerso) {
String titre = this.getNom() + " rencontre " + unPerso.getNom();
String message = "Bonjour " + unPerso.getNom() + " !";
JOptionPane.showMessageDialog(null, message, titre, JOptionPane.INFORMATION_MESSAGE);
String source = "/img/" + this.getImg();
Icon imgPerso = new javax.swing.ImageIcon(getClass().getResource(source));
JOptionPane.showMessageDialog(null, message, titre, JOptionPane.INFORMATION_MESSAGE, imgPerso);
}
/**
* Rencontre avec un autre personnage
* @param unPerso personnage à saluer
*/
public void saluer(Personnage unPerso) {
String titre = this.getNom() + " salue " + unPerso.getNom();
String message = "Bonjour " + unPerso.getNom() + ", \nje suis content de te revoir!";
JOptionPane.showMessageDialog(null, message, titre, JOptionPane.INFORMATION_MESSAGE);
}
/**
* Ajout du nombre passé en paramètre à l'énergie
* Si le résultat de l'ajout est négatif, il est forcé à 0
* @param nb ; nombre à ajouter (positif ou négatif)
*/
public void varierEnergie(int nb){
energie = energie+nb > 0 ? energie+nb : 0;
}
/**
* Ajout du nombre passé en paramètre à la durée de vie
* Si le résultat de l'ajout est négatif, il est forcé à 0
* @param nb ; nombre à ajouter (positif ou négatif)
*/
public void varierDureeVie(int nb){
dureeVie = dureeVie+nb > 0 ? dureeVie+nb : 0;
}
public void combattre(Personnage unPerso) {
if(unPerso.getEnergie()==0){
String titre = this.getNom() + " veut combattre " + unPerso.getNom();
String message = "Aide moi..."+ getNom() +" Je n'ai plus d'énérgie" ;
JOptionPane.showMessageDialog(null, message, titre, JOptionPane.INFORMATION_MESSAGE);
}
}
}

View File

@@ -0,0 +1,163 @@
package metier;
import java.util.ArrayList;
import java.util.Objects;
import javax.swing.Icon;
import javax.swing.JOptionPane;
import static javax.swing.JOptionPane.QUESTION_MESSAGE;
/**
* Classe Sorier, hérite de la classe Personnage
* @author Dominique_2
* @version 20210318
*/
public class Sorcier extends Personnage {
private String baguette;
private ArrayList<Enigme> lesEnigmes;
/**
* Valorisation des variables membres
* @param nom nom du sorcier
* @param img nom de l'image représentant le sorcier
* @param energie valeur énergétique du sorcier
* @param dureeVie durée de vie du sorcier
* @param baguette baguette du sorcier
* @param e inutile désormais
*/
public Sorcier(String nom, String img, int energie, int dureeVie, String baguette, String e) {
super(nom, img, energie, dureeVie);
this.lesEnigmes = new ArrayList<>();
this.baguette = baguette;
}
/**
* Valorisation des variables membres
* @param nom nom du sorcier
* @param img nom de l'image représentant le sorcier
* @param energie valeur énergétique du sorcier
* @param dureeVie durée de vie du sorcier
* @param baguette baguette du sorcier
*/
public Sorcier(String nom, String img, int energie, int dureeVie, String baguette) {
super(nom, img, energie, dureeVie);
this.lesEnigmes = new ArrayList<>();
this.baguette = baguette;
}
@Override
public int hashCode() {
int hash = 7;
hash = super.hashCode() + (73 * hash + Objects.hashCode(this.baguette));
return hash;
}
/**
* Comparaison de l'objet courant avec l'objet passé en paramètre
* @param obj objet à comparer avec l'objet courant
* @return true : les 2 objets sont identiques, false sinon
*/
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Sorcier other = (Sorcier) obj;
if (!Objects.equals(this.baguette, other.baguette)) {
return false;
}
if (!Objects.equals(this.lesEnigmes, other.lesEnigmes)) {
return false;
}
if (!super.equals(obj)) {
return false;
}
return true;
}
/**
* Permet d'obtenir les valeurs des attributs de l'objet courant
* @return liste des attributs avec leurs valeurs
*/
@Override
public String toString() {
return super.toString() + "\n\tSorcier{" + "baguette=" + baguette + ", nb enigmes = " + getLesEnigmes().size() +'}';
}
/**
* Get the value of baguette *
* @return the value of baguette
*/
public String getBaguette() {
return baguette;
}
/**
* Set the value of baguette *
* @param baguette new value of baguette
*/
public void setBaguette(String baguette) {
this.baguette = baguette;
}
public ArrayList<Enigme> getEnigme() {
return getLesEnigmes();
}
/**
* Rencontre avec un autre personnage
* @param unPerso personnage à saluer
*/
public void saluer(Personnage unPerso) {
String titre = this.getNom() + " salue " + unPerso.getNom();
String message = "Bonjour " + unPerso.getNom() + ", \nje t'ai jeté un sort, tu es désormais sous ma dépendance!";
JOptionPane.showMessageDialog(null, message, titre, JOptionPane.INFORMATION_MESSAGE);
}
/**
* Ajout de l'énigme passée en paramètre dans la collection les Enigmes
* @param e Enigme
*/
public void ajouterEnigme(Enigme e) {
getLesEnigmes().add(e);
}
public void rencontrer(Personnage p) {
int indiceEnigme = Jeu.genererNbAleatoire(0, getLesEnigmes().size()-1);
String titre = this.getNom() + " rencontre " + p.getNom();
String reponse = JOptionPane.showInputDialog(
null,
getLesEnigmes().get(indiceEnigme).getQuestion(),
titre + " : énigme",
QUESTION_MESSAGE);
String resultat="";
int type;
if (getLesEnigmes().get(indiceEnigme).getReponse().equals(reponse)) {
resultat = "Bonne réponse, tu peux passer ton chemin!";
type = JOptionPane.INFORMATION_MESSAGE;
p.varierDureeVie(1);
} else {
resultat = "Mauvaise réponse, "
+ "\nattention à toi " + p.getNom() +", "
+ "\nta vie est en danger!";
type = JOptionPane.WARNING_MESSAGE;
p.varierDureeVie(-2);
}
varierEnergie(-1);
Icon iMagie = new javax.swing.ImageIcon(getClass().getResource("/img/magie.jpg"));
JOptionPane.showMessageDialog(null, resultat, titre + " : résultat",type, iMagie);
}
/**
* @return the lesEnigmes
*/
public ArrayList<Enigme> getLesEnigmes() {
return lesEnigmes;
}
}

View File

@@ -0,0 +1,153 @@
package metier;
import java.util.Objects;
import javax.swing.Icon;
import javax.swing.JOptionPane;
import static javax.swing.JOptionPane.DEFAULT_OPTION;
import static javax.swing.JOptionPane.QUESTION_MESSAGE;
/**
*
* @author Dominique_2
*/
public class Voleur extends Personnage{
private String outil;
String [] outils = {"Pierre", "Feuille", "Ciseaux"};
/**
* Valorisation des variables membres
* @param nom nom du guerrier
* @param img nom de l'image représentant le guerrier
* @param energie valeur énergétique du guerrier
* @param dureeVie durée de vie du guerrier
* @param outil outil du guerrier
*/
public Voleur(String nom, String img, int energie, int dureeVie, String outil) {
super(nom, img, energie, dureeVie);
this.outil = outil;
}
@Override
public int hashCode() {
int hash = 7;
hash = super.hashCode() + (29 * hash + Objects.hashCode(this.outil));
return hash;
}
/**
* Comparaison de l'objet courant avec l'objet passé en paramètre
* @param obj objet à comparer avec l'objet courant
* @return true : les 2 objets sont identiques, false sinon
*/
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Voleur other = (Voleur) obj;
if (!Objects.equals(this.outil, other.outil)) {
return false;
}
if (!super.equals(obj)) {
return false;
}
return true;
}
/**
* Permet d'obtenir les valeurs des attributs de l'objet courant
* @return liste des attributs avec leurs valeurs
*/
@Override
public String toString() {
return super.toString() + "\n\tVoleur{" + "outil=" + outil + '}';
}
/**
* Get the value of outil *
* @return the value of outil
*/
public String getOutil() {
return outil;
}
/**
* Set the value of outil *
* @param outil new value of outil
*/
public void setOutil(String outil) {
this.outil = outil;
}
public void rencontrer(Personnage p) {
// int indiceOutil = Jeu.genererNbAleatoire(0, outils.length -1);
Icon iPFC = new javax.swing.ImageIcon(getClass().getResource("/img/pierreFeuilleCiseaux.jpg"));
// String reponse = (String) JOptionPane.showInputDialog(
// null,
// "Pierre, feuille, ciseaux ? ",
// "Quel est ton choix ?" + p.getNom(),
// QUESTION_MESSAGE, iPFC,
// outils,"");
int nbJeu = 0;
String mess = "Que choisis-tu \n" + p.getNom() + " ?";
String titre = this.getNom() + " rencontre " + p.getNom();
int rep=-1, indiceOutil=-1;
while (rep == indiceOutil) {
if (nbJeu > 0) {
mess = "Égalité, rejoue vite!";
}
indiceOutil = Jeu.genererNbAleatoire(0, outils.length -1);
rep = JOptionPane.showOptionDialog(
null,
mess,
titre,
DEFAULT_OPTION,
QUESTION_MESSAGE,
iPFC,
outils,
0);
nbJeu++;
}
boolean gagne = true; // Position du personnage rencontré
String explication = "";
switch (indiceOutil) {
case 0 : // Cas Pierre
if (rep == 2) { // Cas Ciseaux
gagne = false; // La pierre aiguise les ciseaux
explication = "La pierre aiguise les ciseaux";
}
break;
case 1 : // Cas Feuille
if (rep == 0) { // Cas Pierre
gagne = false; // La feuille bat la pierre en l'enveloppant
explication = "La feuille enveloppe la pierre"; }
break;
case 2 : // Cas Ciseaux
if (rep == 1) { // Cas Feuille
gagne = false; // Les ciseaux coupent la feuille
explication = "Les ciseaux coupent la feuille";
}
}
mess = "J'ai choisi " + outils[indiceOutil] + " et toi " + outils[rep] + "\n" + explication + "\n\n";
mess += gagne ?
"Aujourd'hui tu as gagné "+p.getNom()+",\n mais qu'en sera-t-il demain ?" :
"Ah, ah, ah ! Perdu pour toi "+p.getNom()+".\nAu plaisir de te revoir...";
JOptionPane.showMessageDialog(null, mess, titre + " : résultat",0, iPFC);
if (!gagne) {
p.varierDureeVie(-1);
p.varierEnergie(-1);
} else {
p.varierEnergie(1);
varierEnergie(-1);
}
}
}