Début d'interface

This commit is contained in:
steve.maingana 2025-02-10 11:51:22 +01:00
parent c52812f8f6
commit ce222cb614
8 changed files with 589 additions and 46 deletions

View File

@ -1,9 +1,10 @@
annotation.processing.enabled=true annotation.processing.enabled=true
annotation.processing.enabled.in.editor=false annotation.processing.enabled.in.editor=false
annotation.processing.processor.options=
annotation.processing.processors.list= annotation.processing.processors.list=
annotation.processing.run.all.processors=true annotation.processing.run.all.processors=true
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
application.title=JDR
application.vendor=steve.maingana
build.classes.dir=${build.dir}/classes build.classes.dir=${build.dir}/classes
build.classes.excludes=**/*.java,**/*.form build.classes.excludes=**/*.java,**/*.form
# This directory is removed when the project is cleaned: # This directory is removed when the project is cleaned:
@ -32,10 +33,12 @@ dist.jar=${dist.dir}/JDR.jar
dist.javadoc.dir=${dist.dir}/javadoc dist.javadoc.dir=${dist.dir}/javadoc
dist.jlink.dir=${dist.dir}/jlink dist.jlink.dir=${dist.dir}/jlink
dist.jlink.output=${dist.jlink.dir}/JDR dist.jlink.output=${dist.jlink.dir}/JDR
endorsed.classpath=
excludes= excludes=
includes=** includes=**
jar.compress=false jar.compress=false
javac.classpath= javac.classpath=\
${libs.absolutelayout.classpath}
# Space-separated list of extra javac options # Space-separated list of extra javac options
javac.compilerargs= javac.compilerargs=
javac.deprecation=false javac.deprecation=false
@ -71,7 +74,7 @@ jlink.additionalmodules=
jlink.additionalparam= jlink.additionalparam=
jlink.launcher=true jlink.launcher=true
jlink.launcher.name=JDR jlink.launcher.name=JDR
main.class=jdr.JDR main.class=interfaces.jFFJDR
manifest.file=manifest.mf manifest.file=manifest.mf
meta.inf.dir=${src.dir}/META-INF meta.inf.dir=${src.dir}/META-INF
mkdist.disabled=false mkdist.disabled=false

View File

@ -20,47 +20,292 @@
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues> </AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> <Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="140" max="-2" attributes="0"/>
<Component id="jBtGo" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jPChoix" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="32767" attributes="0"/>
<Component id="jPInfos" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="114" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="10" pref="10" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="jPChoix" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="jBtGo" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="jPInfos" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents> <SubComponents>
<Container class="javax.swing.JPanel" name="jPChoix"> <Container class="javax.swing.JPanel" name="jPChoix">
<Constraints> <Properties>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<BorderConstraints direction="Center"/> <Color blue="ff" green="ff" red="ff" type="rgb"/>
</Constraint> </Property>
</Constraints> </Properties>
<Layout> <Layout>
<DimensionLayout dim="0"> <DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="400" max="32767" attributes="0"/> <Group type="102" attributes="0">
<EmptySpace min="100" pref="100" max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="73" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
<DimensionLayout dim="1"> <DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="200" max="32767" attributes="0"/> <Group type="102" attributes="0">
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
</Layout> </Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel1">
<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="jPanel1">
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel3" min="-2" max="-2" attributes="0"/>
<Component id="jPanel2" min="-2" max="-2" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="jLabel3" min="-2" max="-2" attributes="0"/>
<EmptySpace min="13" pref="13" max="-2" attributes="0"/>
<Component id="jPanel2" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel3">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Snap ITC" size="12" style="0"/>
</Property>
<Property name="text" type="java.lang.String" value="Choix du personnage"/>
</Properties>
</Component>
<Container class="javax.swing.JPanel" name="jPanel2">
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="47" pref="47" max="-2" attributes="0"/>
<Component id="jCBPerso1" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="113" max="32767" attributes="0"/>
<Component id="jCBPerso2" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="44" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="6" pref="6" max="-2" attributes="0"/>
<Component id="jPanel4" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="jPanel3" 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" attributes="0">
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jCBPerso1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jCBPerso2" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="6" pref="6" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jPanel4" max="32767" attributes="0"/>
<Component id="jPanel3" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JComboBox" name="jCBPerso1">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="0"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jCBPerso1ActionPerformed"/>
</Events>
<AuxValues>
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="&lt;String&gt;"/>
</AuxValues>
</Component>
<Container class="javax.swing.JPanel" name="jPanel3">
<Properties>
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="0" green="0" red="99" type="rgb"/>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="163" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
</Container>
<Container class="javax.swing.JPanel" name="jPanel4">
<Properties>
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="0" green="0" red="99" type="rgb"/>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="163" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="172" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
</Container>
<Component class="javax.swing.JComboBox" name="jCBPerso2">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="0"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jCBPerso2ActionPerformed"/>
</Events>
<AuxValues>
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="&lt;String&gt;"/>
</AuxValues>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Container>
</SubComponents>
</Container> </Container>
<Container class="javax.swing.JPanel" name="jPInfos"> <Container class="javax.swing.JPanel" name="jPInfos">
<Constraints> <Properties>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<BorderConstraints direction="East"/> <Color blue="0" green="0" red="33" type="rgb"/>
</Constraint> </Property>
</Constraints> </Properties>
<Layout> <Layout>
<DimensionLayout dim="0"> <DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="420" max="32767" attributes="0"/> <Group type="102" attributes="0">
<EmptySpace min="30" pref="30" max="-2" attributes="0"/>
<Component id="jLabel2" min="-2" pref="190" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<EmptySpace min="10" pref="10" max="-2" attributes="0"/>
<Component id="jScrollPane1" min="-2" pref="240" max="-2" attributes="0"/>
</Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
<DimensionLayout dim="1"> <DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="310" max="32767" attributes="0"/> <Group type="102" attributes="0">
<EmptySpace min="10" pref="10" max="-2" attributes="0"/>
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace min="10" pref="10" max="-2" attributes="0"/>
<Component id="jScrollPane1" min="-2" pref="290" max="-2" attributes="0"/>
</Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
</Layout> </Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel2">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/img/adj_1.jpg"/>
</Property>
<Property name="toolTipText" type="java.lang.String" value=""/>
</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="jTAInfos">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="0" green="0" red="33" type="rgb"/>
</Property>
<Property name="columns" type="int" value="20"/>
<Property name="rows" type="int" value="5"/>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Container> </Container>
<Component class="javax.swing.JButton" name="jBtGo">
<Properties>
<Property name="text" type="java.lang.String" value="GO"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jBtGoActionPerformed"/>
</Events>
</Component>
</SubComponents> </SubComponents>
</Form> </Form>

View File

@ -4,17 +4,41 @@
*/ */
package interfaces; package interfaces;
import java.util.*;
import javax.swing.*;
import metier.*;
/** /**
* *
* @author steve.maingana * @author steve.maingana
*/ */
public class jFFJDR extends javax.swing.JFrame { public class jFFJDR extends javax.swing.JFrame {
public Jeu jdr = new Jeu("JDR");
/** /**
* Creates new form jFFJDR * Creates new form jFFJDR
*/ */
public jFFJDR() { public jFFJDR() {
initComponents(); initComponents();
actualiserInformations();
}
public void actualiserInformations() {
String str = "";
ArrayList<Personnage> lesPersonnages = this.jdr.getPersos();
str += "Jeu: "+jdr.getNomJeu()+"\n";
str += "*************\n";
for (Personnage unPerso : lesPersonnages) {
str += unPerso.resumerPersonnage();
str += "-----------------------\n";
}
jTAInfos.setText(str);
jCBPerso1.setModel(new DefaultComboBoxModel(jdr.getLesPersonnagesVivants()));
jCBPerso1.setSelectedIndex(0);
jCBPerso2.setModel(new DefaultComboBoxModel(jdr.getLesPersonnagesVivants()));
jCBPerso2.setSelectedIndex(0);
} }
/** /**
@ -27,39 +51,216 @@ public class jFFJDR extends javax.swing.JFrame {
private void initComponents() { private void initComponents() {
jPChoix = new javax.swing.JPanel(); jPChoix = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jPanel1 = new javax.swing.JPanel();
jLabel3 = new javax.swing.JLabel();
jPanel2 = new javax.swing.JPanel();
jCBPerso1 = new javax.swing.JComboBox<>();
jPanel3 = new javax.swing.JPanel();
jPanel4 = new javax.swing.JPanel();
jCBPerso2 = new javax.swing.JComboBox<>();
jPInfos = new javax.swing.JPanel(); jPInfos = new javax.swing.JPanel();
jLabel2 = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
jTAInfos = new javax.swing.JTextArea();
jBtGo = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jPChoix.setBackground(new java.awt.Color(255, 255, 255));
jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/famille_1.jpg"))); // NOI18N
jLabel3.setFont(new java.awt.Font("Snap ITC", 0, 12)); // NOI18N
jLabel3.setText("Choix du personnage");
jCBPerso1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jCBPerso1ActionPerformed(evt);
}
});
jPanel3.setBackground(new java.awt.Color(153, 0, 0));
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 163, Short.MAX_VALUE)
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 0, Short.MAX_VALUE)
);
jPanel4.setBackground(new java.awt.Color(153, 0, 0));
javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
jPanel4.setLayout(jPanel4Layout);
jPanel4Layout.setHorizontalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 163, Short.MAX_VALUE)
);
jPanel4Layout.setVerticalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 172, Short.MAX_VALUE)
);
jCBPerso2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jCBPerso2ActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(47, 47, 47)
.addComponent(jCBPerso1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 113, Short.MAX_VALUE)
.addComponent(jCBPerso2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(44, 44, 44))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(6, 6, 6)
.addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jCBPerso1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jCBPerso2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(6, 6, 6)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel3)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel3)
.addGap(13, 13, 13)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
);
javax.swing.GroupLayout jPChoixLayout = new javax.swing.GroupLayout(jPChoix); javax.swing.GroupLayout jPChoixLayout = new javax.swing.GroupLayout(jPChoix);
jPChoix.setLayout(jPChoixLayout); jPChoix.setLayout(jPChoixLayout);
jPChoixLayout.setHorizontalGroup( jPChoixLayout.setHorizontalGroup(
jPChoixLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) jPChoixLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 400, Short.MAX_VALUE) .addGroup(jPChoixLayout.createSequentialGroup()
.addGap(100, 100, 100)
.addComponent(jLabel1)
.addGap(73, 73, 73))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPChoixLayout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
); );
jPChoixLayout.setVerticalGroup( jPChoixLayout.setVerticalGroup(
jPChoixLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) jPChoixLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 200, Short.MAX_VALUE) .addGroup(jPChoixLayout.createSequentialGroup()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
); );
getContentPane().add(jPChoix, java.awt.BorderLayout.CENTER); jPInfos.setBackground(new java.awt.Color(51, 0, 0));
jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/adj_1.jpg"))); // NOI18N
jLabel2.setToolTipText("");
jTAInfos.setEditable(false);
jTAInfos.setBackground(new java.awt.Color(51, 0, 0));
jTAInfos.setColumns(20);
jTAInfos.setRows(5);
jScrollPane1.setViewportView(jTAInfos);
javax.swing.GroupLayout jPInfosLayout = new javax.swing.GroupLayout(jPInfos); javax.swing.GroupLayout jPInfosLayout = new javax.swing.GroupLayout(jPInfos);
jPInfos.setLayout(jPInfosLayout); jPInfos.setLayout(jPInfosLayout);
jPInfosLayout.setHorizontalGroup( jPInfosLayout.setHorizontalGroup(
jPInfosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) jPInfosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 420, Short.MAX_VALUE) .addGroup(jPInfosLayout.createSequentialGroup()
.addGap(30, 30, 30)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 190, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPInfosLayout.createSequentialGroup()
.addGap(10, 10, 10)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 240, javax.swing.GroupLayout.PREFERRED_SIZE))
); );
jPInfosLayout.setVerticalGroup( jPInfosLayout.setVerticalGroup(
jPInfosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) jPInfosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 310, Short.MAX_VALUE) .addGroup(jPInfosLayout.createSequentialGroup()
.addGap(10, 10, 10)
.addComponent(jLabel2)
.addGap(10, 10, 10)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 290, javax.swing.GroupLayout.PREFERRED_SIZE))
); );
getContentPane().add(jPInfos, java.awt.BorderLayout.EAST); jBtGo.setText("GO");
jBtGo.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jBtGoActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(140, 140, 140)
.addComponent(jBtGo))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPChoix, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPInfos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(114, 114, 114))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(10, 10, 10)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jPChoix, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jBtGo))
.addComponent(jPInfos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pack(); pack();
}// </editor-fold>//GEN-END:initComponents }// </editor-fold>//GEN-END:initComponents
private void jBtGoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtGoActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jBtGoActionPerformed
private void jCBPerso2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCBPerso2ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jCBPerso2ActionPerformed
private void jCBPerso1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCBPerso1ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jCBPerso1ActionPerformed
/** /**
* @param args the command line arguments * @param args the command line arguments
*/ */
@ -96,7 +297,19 @@ public class jFFJDR extends javax.swing.JFrame {
} }
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jBtGo;
private javax.swing.JComboBox<String> jCBPerso1;
private javax.swing.JComboBox<String> jCBPerso2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JPanel jPChoix; private javax.swing.JPanel jPChoix;
private javax.swing.JPanel jPInfos; private javax.swing.JPanel jPInfos;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JPanel jPanel4;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextArea jTAInfos;
// End of variables declaration//GEN-END:variables // End of variables declaration//GEN-END:variables
} }

View File

@ -83,6 +83,21 @@ public class Guerrier extends Personnage{
this.arme = arme; this.arme = arme;
} }
/**
* Résume les informations sur le personnage
* @return Informations du personnage
*/
@Override
public String resumerPersonnage() {
String str = "";
str += "Nom "+this.getNom()+"\n";
str += "Énergie "+this.getEnergie()+"\n";
str += "Durée de vie "+this.getDureeVie()+"\n";
str += "Guerrier arme : "+this.getArme()+"\n";
return str;
}
/** /**
* Initie la rencontre avec un autre personnage * Initie la rencontre avec un autre personnage
* @param unPerso un Personnage * @param unPerso un Personnage

View File

@ -4,8 +4,8 @@
*/ */
package metier; package metier;
import java.util.ArrayList; import java.util.*;
import javax.swing.JOptionPane; import javax.swing.*;
/** /**
* *
@ -15,7 +15,7 @@ public class Jeu {
// Nom du jeu // Nom du jeu
private String nomJeu; private String nomJeu;
// Tableau de personnages // Tableau de personnages
private Personnage[] persos; private ArrayList<Personnage> persos;
// Equipes de jeu // Equipes de jeu
private ArrayList<Personnage> Equipe1; private ArrayList<Personnage> Equipe1;
private ArrayList<Personnage> Equipe2; private ArrayList<Personnage> Equipe2;
@ -27,7 +27,7 @@ public class Jeu {
public Jeu(String nomJeu) { public Jeu(String nomJeu) {
this.setNomJeu(nomJeu); this.setNomJeu(nomJeu);
this.chargerPersonnages(); this.chargerPersonnages();
this.definirEquipes(); // this.definirEquipes();
} }
/** /**
@ -37,8 +37,8 @@ public class Jeu {
public String toString() { public String toString() {
String envoi = ""; String envoi = "";
envoi += "Jeu{" + "nomJeu=" + this.nomJeu + ",\n persos="; envoi += "Jeu{" + "nomJeu=" + this.nomJeu + ",\n persos=";
for (int i = 0; i < this.persos.length; i++) { for (int i = 0; i < this.persos.size(); i++) {
envoi += this.persos[i].toString(); envoi += this.persos.get(i).toString();
envoi += ",\n"; envoi += ",\n";
} }
envoi += "}"; envoi += "}";
@ -55,14 +55,22 @@ public class Jeu {
this.nomJeu = nomJeu; this.nomJeu = nomJeu;
} }
public String getNomJeu() {
return nomJeu;
}
/** /**
* Défini le tableau de personnages * Défini le tableau de personnages
* @param persos Tableau de personnages * @param persos Tableau de personnages
*/ */
public void setPersos(Personnage[] persos) { public void setPersos(ArrayList<Personnage> persos) {
this.persos = persos; this.persos = persos;
} }
public ArrayList getPersos() {
return this.persos;
}
/** /**
* Initialise le tableau de personnages * Initialise le tableau de personnages
*/ */
@ -82,30 +90,44 @@ public class Jeu {
new Enigme("Un escargot est au fond d'un puits de 10 mètres. Chaque matin il monte de 3 mètres et chaque nuit il descend de 2 mètres. Combien de jours lui faudra-t-il pour sortir de ce puits ?","7") new Enigme("Un escargot est au fond d'un puits de 10 mètres. Chaque matin il monte de 3 mètres et chaque nuit il descend de 2 mètres. Combien de jours lui faudra-t-il pour sortir de ce puits ?","7")
}; };
Personnage[] persos = { ArrayList<Personnage> persos = new ArrayList<Personnage>();
new Guerrier("Jayce", "Jayce.jpg", 5, 5, "Hache"), persos.add(new Guerrier("Jayce", "Jayce.jpg", 5, 5, "Hache"));
new Guerrier("Ambresa", "Ambresa.jpg", 8, 9, "Lance"), persos.add(new Guerrier("Ambresa", "Ambresa.jpg", 8, 9, "Lance"));
new Guerrier("Ekko", "Ekko.jpg", 5, 6, "Poignard"), persos.add(new Guerrier("Ekko", "Ekko.jpg", 5, 6, "Poignard"));
new Sorcier("Mel", "Mel.jpg", 6, 7, "De laurier", enigmes1), persos.add(new Sorcier("Mel", "Mel.jpg", 6, 7, "De laurier", enigmes1));
new Sorcier("Viktor", "Viktor.jpg", 10, 5, "Hexcore", enigmes2), persos.add(new Sorcier("Viktor", "Viktor.jpg", 10, 5, "Hexcore", enigmes2));
new Voleur("Jinx", "Jinx.jpg", 7, 6, "Marteau") persos.add(new Voleur("Jinx", "Jinx.jpg", 7, 6, "Marteau"));
};
this.setPersos(persos); this.setPersos(persos);
System.out.println("Personnages chargés !"); System.out.println("Personnages chargés !");
} }
/** /**
* Répartit les personnages en équipes de 3 * Obtenir la liste des personnages encore en vie
* @return Liste des personnages encore en vie
*/
public Vector getLesPersonnagesVivants() {
Vector<String> lesPersonnages = new Vector<>();
for (Personnage perso : this.persos) {
if (perso.getDureeVie() > 0) {
lesPersonnages.add(perso.getClass().getSimpleName()+":"+perso.getNom());
}
}
return lesPersonnages;
}
/**
* Répartit les personnages en équipes de 3
*/ */
private void definirEquipes() { private void definirEquipes() {
for (int i = 0; i < 6; i++) { for (int i = 0; i < 6; i++) {
int rollEquipe = (int) (Math.random()*2)+1; int rollEquipe = (int) (Math.random()*2)+1;
if (rollEquipe == 1) { if (rollEquipe == 1) {
if (this.Equipe1.size() == 3) { if (this.Equipe1.size() == 3) {
this.Equipe2.add(this.persos[i]); this.Equipe2.add(this.persos.get(i));
} else { } else {
this.Equipe1.add(this.persos[i]); this.Equipe1.add(this.persos.get(i));
} }
} }
} }
@ -120,9 +142,9 @@ public class Jeu {
Personnage perso = null; Personnage perso = null;
boolean trouve = false; boolean trouve = false;
int i = 0; int i = 0;
while (!trouve && i < this.persos.length) { while (!trouve && i < this.persos.size()) {
if (this.persos[i].getNom().equals(nom)) { if (this.persos.get(i).getNom().equals(nom)) {
perso = this.persos[i]; perso = this.persos.get(i);
trouve = true; trouve = true;
} else { } else {
i++; i++;

View File

@ -156,6 +156,21 @@ public class Personnage {
this.nom = nom; this.nom = nom;
} }
/**
* Résume les informations sur le personnage
* @return Informations du personnage
*/
public String resumerPersonnage() {
String str = "";
str += "Nom "+this.getNom()+"\n";
str += "Énergie "+this.getEnergie()+"\n";
str += "Durée de vie "+this.getDureeVie()+"\n";
str += "Civil arme : Aucune\n";
return str;
}
/** /**
* Initie la rencontre avec un autre personnage * Initie la rencontre avec un autre personnage
* @param unPerso un Personnage * @param unPerso un Personnage

View File

@ -67,6 +67,21 @@ public class Sorcier extends Personnage {
return this.enigmes; return this.enigmes;
} }
/**
* Résume les informations sur le personnage
* @return Informations du personnage
*/
@Override
public String resumerPersonnage() {
String str = "";
str += "Nom "+this.getNom()+"\n";
str += "Énergie "+this.getEnergie()+"\n";
str += "Durée de vie "+this.getDureeVie()+"\n";
str += "Sorcier arme : "+this.getBaguette()+"\n";
return str;
}
public void ajouterEnigme(Enigme e) { public void ajouterEnigme(Enigme e) {
int tailleEnigmes = this.enigmes.length+1; int tailleEnigmes = this.enigmes.length+1;
Enigme[] enigmes = new Enigme[tailleEnigmes]; Enigme[] enigmes = new Enigme[tailleEnigmes];

View File

@ -103,6 +103,21 @@ public class Voleur extends Personnage{
} }
} }
/**
* Résume les informations sur le personnage
* @return Informations du personnage
*/
@Override
public String resumerPersonnage() {
String str = "";
str += "Nom "+this.getNom()+"\n";
str += "Énergie "+this.getEnergie()+"\n";
str += "Durée de vie "+this.getDureeVie()+"\n";
str += "Voleur arme : "+this.getOutil()+"\n";
return str;
}
/** /**
* Initie la rencontre avec un autre personnage * Initie la rencontre avec un autre personnage
* @param unPerso un Personnage * @param unPerso un Personnage