Skip to content

Commit

Permalink
#1455 Initialize series table if no matches are played yet (#2073)
Browse files Browse the repository at this point in the history
* #2069 reduce space between team summary labels

* #2069 release_notes.md

* #1455 initialize series table if no matches are played yet

* #1455 fix initial order of series table

* #1455 review

* #1455 review

* #1455 review

* #1455 review

* #1455 review
  • Loading branch information
wsbrenk committed Jun 6, 2024
1 parent f8fe1f0 commit 1397f13
Show file tree
Hide file tree
Showing 8 changed files with 247 additions and 318 deletions.
96 changes: 9 additions & 87 deletions src/main/java/core/model/series/LigaTabelle.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

import core.util.Helper;

import java.util.Comparator;
import java.util.Vector;
import java.util.stream.Collectors;

public class LigaTabelle {
//~ Instance fields ----------------------------------------------------------------------------
protected String m_sLigaLandName = "";
protected String m_sLigaName = "";
protected Vector<SerieTableEntry> m_vEintraege = new Vector<SerieTableEntry>();
protected Vector<SerieTableEntry> m_vEintraege = new Vector<>();
protected int m_iLigaId = -1;
protected int m_iLigaLandId = -1;
/** Maximale ANzahl an Spielklassen */
Expand All @@ -33,7 +35,7 @@ public final Vector<SerieTableEntry> getEntries() {
* liefert den Eintrag zu einem Team
*/
public final SerieTableEntry getEintragByTeamId(int teamId) {
SerieTableEntry tmp = null;
SerieTableEntry tmp;

for (int i = 0; (teamId >= 0) && (i < m_vEintraege.size()); i++) {
tmp = m_vEintraege.elementAt(i);
Expand All @@ -55,15 +57,6 @@ public final void setLigaId(int m_iLigaId) {
this.m_iLigaId = m_iLigaId;
}

/**
* Getter for property m_iLigaId.
*
* @return Value of property m_iLigaId.
*/
public final int getLigaId() {
return m_iLigaId;
}

/**
* Setter for property m_iLigaLandId.
*
Expand All @@ -73,15 +66,6 @@ public final void setLigaLandId(int m_iLigaLandId) {
this.m_iLigaLandId = m_iLigaLandId;
}

/**
* Getter for property m_iLigaLandId.
*
* @return Value of property m_iLigaLandId.
*/
public final int getLigaLandId() {
return m_iLigaLandId;
}

/**
* Setter for property m_sLigaLandName.
*
Expand All @@ -91,15 +75,6 @@ public final void setLigaLandName(java.lang.String m_sLigaLandName) {
this.m_sLigaLandName = m_sLigaLandName;
}

/**
* Getter for property m_sLigaLandName.
*
* @return Value of property m_sLigaLandName.
*/
public final java.lang.String getLigaLandName() {
return m_sLigaLandName;
}

/**
* Setter for property m_sLigaName.
*
Expand All @@ -109,15 +84,6 @@ public final void setLigaName(java.lang.String m_sLigaName) {
this.m_sLigaName = m_sLigaName;
}

/**
* Getter for property m_sLigaName.
*
* @return Value of property m_sLigaName.
*/
public final java.lang.String getLigaName() {
return m_sLigaName;
}

/**
* Setter for property m_iMaxAnzahlSpielklassen.
*
Expand All @@ -127,15 +93,6 @@ public final void setMaxAnzahlSpielklassen(int m_iMaxAnzahlSpielklassen) {
this.m_iMaxAnzahlSpielklassen = m_iMaxAnzahlSpielklassen;
}

/**
* Getter for property m_iMaxAnzahlSpielklassen.
*
* @return Value of property m_iMaxAnzahlSpielklassen.
*/
public final int getMaxAnzahlSpielklassen() {
return m_iMaxAnzahlSpielklassen;
}

/**
* Setter for property m_iSpielklasse.
*
Expand All @@ -145,52 +102,14 @@ public final void setSpielklasse(int m_iSpielklasse) {
this.m_iSpielklasse = m_iSpielklasse;
}

/**
* Getter for property m_iSpielklasse.
*
* @return Value of property m_iSpielklasse.
*/
public final int getSpielklasse() {
return m_iSpielklasse;
}

////////////////////////////////////////////////////////////////////////////////
//Logic
////////////////////////////////////////////////////////////////////////////////

/**
* liefert tendenz zur Platzierung des Teams im Vergleich mit der angegebenen Tabelle -1 ==
* abgerutscht, 0 = gleich, 1 == aufgestiegen
*/
public final byte getTeamPlatzTendenz(int teamId, LigaTabelle compare) {
SerieTableEntry aktu = null;
SerieTableEntry vergleich = null;

if (compare != null) {
aktu = getEintragByTeamId(teamId);
vergleich = compare.getEintragByTeamId(teamId);

if ((aktu != null) && (vergleich != null)) {
if (aktu.getPosition() < vergleich.getPosition()) {
return (byte) 1;
} else if (aktu.getPosition() > vergleich.getPosition()) {
return (byte) -1;
}
}
}

//default
return (byte) 0;
}

public final void addEintrag(SerieTableEntry lte) {
if ((lte != null) && (!m_vEintraege.contains(lte))) {
m_vEintraege.add(lte);
}
}

/*
*Sortiert die Einträge
* Sort series table entries
*/
public final void sort() {
SerieTableEntry[] list = new SerieTableEntry[m_vEintraege.size()];
Expand All @@ -208,6 +127,9 @@ public final void sort() {

//zurückkopieren
Helper.copyArray2Vector(list, m_vEintraege);
list = null;
}

public void sortByPosition() {
m_vEintraege = m_vEintraege.stream().sorted(Comparator.comparing(SerieTableEntry::getPosition)).collect(Collectors.toCollection(Vector::new));
}
}
Loading

0 comments on commit 1397f13

Please sign in to comment.