OS2.jugend: Unterschied zwischen den Versionen

Aus Online-Soccer-Wiki
Zur Navigation springen Zur Suche springen
(OS2.jugendV2, Version 2)
 
(OS2.jugendV3, Version 3)
Zeile 1: Zeile 1:
[[Kategorie:GreaseMonkey]]
[[Kategorie:GreaseMonkey]]
{| style="background-color:white; font-size:11px; float: right; margin:3px 3px 3px 10px; border:1px solid #999; border-color: #9C1818; border-collapse:collapse;" width=500 cellpadding=3 cellspacing=0
{| style="background-color:white; font-size:11px; float: right; margin:3px 3px 3px 10px; border:1px solid #999; border-color: #9C1818; border-collapse:collapse;" width=500 cellpadding=3 cellspacing=0
| colspan="2" style="padding:0.3em; background-color:#9C1818; font-size: 18px; color:#FFFFFF" align=center| '''OS2.jugendV2'''
| colspan="2" style="padding:0.3em; background-color:#9C1818; font-size: 18px; color:#FFFFFF" align=center| '''OS2.jugendV3'''
|- bgcolor="#FFCC00"
|- bgcolor="#FFCC00"
| '''Dateiname'''
| '''Dateiname'''
| '''os2.jugendV2.user.js'''
| '''os2.jugendV3.user.js'''
|- bgcolor="#FFCC00"
|- bgcolor="#FFCC00"
| '''Version'''
| '''Version'''
| '''2.0'''
| '''3.0'''
|- bgcolor="#FFCC00"
|- bgcolor="#FFCC00"
| '''Autor'''
| '''Autor'''
Zeile 27: Zeile 27:
<pre>
<pre>
// ==UserScript==
// ==UserScript==
// @name OS2.jugendV2
// @name OS2.jugendV3
// @description Jugendteam-Script fuer Online Soccer 2.0
// @description Jugendteam-Script fuer Online Soccer 2.0
// @include http://os.ongapo.com/ju.php?page=2
// @include http://os.ongapo.com/ju.php?page=2
Zeile 33: Zeile 33:
// @include http://www.online-soccer.eu/ju.php?page=2
// @include http://www.online-soccer.eu/ju.php?page=2
// ==/UserScript==
// ==/UserScript==
// Konfiguration ************************************************************************
// Entscheidend fuer die Berechnung der Werte mit Ende 18, sollte also moeglichst aktuell sein
// Fuer jeden Skill wird anhand der Ist-Daten die Anzahl an Aufwertungen pro Zat bestimmt
// Diese Zahl wird auch fuer die Zukunft angenommen
// D.h. es wird angenommen, dass jeder Spieler bis zum Ende genau so trainiert wie bisher
var aktuellerZat = 1;
// Spaltenauswahl fuer die aktuellen Werte (true = anzeigen, false = nicht anzeigen)
// anzahlOpti gibt die Anzahl der Opti-Spalten an
// 1: nur bester Opti, 2: die beiden besten, ..., 6: Alle inklusive TOR
// Bei Torhuetern wird immer nur der TOR-Opti angezeigt
// Werte < 1 oder > 6 schalten die Anzeige aus
// anzahlMW funktioniert analog
var zeigeSkill = true;
var zeigePosition = false;
var anzahlOpti = 1;
var anzahlMW = 1;
// Spaltenauswahl fuer die Werte mit Ende 18
// Bedeutungen sind wie fuer die aktuellen Werte
var zeigeSkillEnde = true;
var anzahlOptiEnde = 1;
var anzahlMWEnde = 1;
// Text, mit dem die "Ende 18"-Spaltentitel gekennzeichnet werden
// "\u03A9" stellt das Unicode-Zeichen Nummer 03A9 dar (grosses Omega)
var kennzeichenEnde = " \u03A9";
// Variablen ****************************************************************************


var url = window.location.href;
var url = window.location.href;
var borderString = "solid white 1px";
var borderString = "solid white 1px";
var colIndexAge = 3;
var titleColor = "#FFFFFF";
var rowOffsetUpper = 1;
var rowOffset = 1;
var players = [];
var playerRows = document.getElementsByTagName("table")[1].getElementsByTagName("tr");
 
// Programm *****************************************************************************


addColumns();
var colMan = new ColumnManager();
colMan.addTitles();
init();
for (var i = 0; i < players.length; i++) {
colMan.addValues(players[i], playerRows[i + rowOffset]);
}
separateAgeGroups();
separateAgeGroups();
// Spaltentitel zentrieren
playerRows[0].align = "center";


function addColumns() {
// Funktionen ***************************************************************************
var playerRows = document.getElementsByTagName("table")[1].getElementsByTagName("tr");


for (var i = 0; i < playerRows.length; i++) {
// Erschafft die Spieler-Objekte und fuellt sie mit Werten
var playerRow = playerRows[i];
//
function init() {
var playerRow;
var age;
var skills;
var isGoalie;
for (var i = rowOffset; i < playerRows.length; i++) {
playerRow = playerRows[i];
age = getAgeFromHTML(playerRow);
skills = getSkillsFromHTML(playerRow);
isGoalie = isGoalieFromHTML(playerRow);
players[i - rowOffset] = new PlayerRecord(age, skills, isGoalie);
players[i - rowOffset].initPlayer();
}
}


// Zellen hinzufuegen:
// Trennt die Jahrgaenge mit Linien
var colIndexSkill = playerRow.cells.length; // Skillschnitt
//
playerRow.insertCell(-1);
function separateAgeGroups() {
var colIndexOpti1 = playerRow.cells.length; // Opti 1
var colIdxAge = 3;
playerRow.insertCell(-1);
var playerTable = document.getElementsByTagName("table")[1];
var colIndexMW1 = playerRow.cells.length; // Marktwert 1
playerRow.insertCell(-1);
var colIndexOpti2 = playerRow.cells.length; // Opti 2
playerRow.insertCell(-1);
var colIndexMW2 = playerRow.cells.length; // MW 2
playerRow.insertCell(-1);


if (i > 0) {
for (var i = rowOffset; i < playerTable.rows.length - 1; i++) {
var skill = getSkill(playerRow);
if (playerTable.rows[i].cells[colIdxAge].textContent != playerTable.rows[i + 1].cells[colIdxAge].textContent) {
if (playerRow.cells[colIndexAge].className == "TOR") {
for (var j = colIdxAge; j < playerTable.rows[i].cells.length; j++) {
// Torwart:
playerTable.rows[i].cells[j].style.borderBottom = borderString;
var alter = parseInt(playerRow.cells[colIndexAge].textContent);
}
var pos1 = "TOR";
}
var opti1 = getOptSkillTOR(playerRow);
}
var color1 = getColor(pos1);
}
var marktwert = getMarketValue(skill, opti1, alter);
 
// Klasse ColumnManager *****************************************************************
 
function ColumnManager() {
this.skill = zeigeSkill;
this.pos = zeigePosition;
this.opti = ((anzahlOpti >= 1) && (anzahlOpti <= 6)) ? true : false;
this.mw = ((anzahlMW >= 1) && (anzahlMW <= 6)) ? true : false;
this.anzOpti = anzahlOpti;
this.anzMw = anzahlMW;
this.skillE = zeigeSkillEnde;
this.optiE = ((anzahlOptiEnde >= 1) && (anzahlOptiEnde <= 6)) ? true : false;
this.mwE = ((anzahlMWEnde >= 1) && (anzahlMWEnde <= 6)) ? true : false;
this.anzOptiE = anzahlOptiEnde;
this.anzMwE = anzahlMWEnde;
this.kennzE = kennzeichenEnde;
 
this.toString = function() {
var result = "Skillschnitt\t\t" + this.skill + "\n";
result += "Beste Position\t" + this.pos + "\n";
result += "Optis\t\t\t" + this.opti + " (" + this.anzOpti + ")\n";
result += "Marktwerte\t\t" + this.mw + " (" + this.anzMw + ")\n";
result += "Skillschnitt Ende\t" + this.skillE + "\n";
result += "Optis Ende\t\t" + this.optiE + " (" + this.anzOptiE + ")\n";
result += "Marktwerte Ende\t" + this.mwE + " (" + this.anzMwE + ")\n";
return result;
}
 
this.addCell = function(tableRow) {
tableRow.insertCell(-1);
return tableRow.cells.length - 1;
}


playerRow.cells[colIndexSkill].textContent = skill.toFixed(2);
this.addAndFillCell = function(tableRow, value, color) {
playerRow.cells[colIndexSkill].style.color = color1;
if (isFinite(value) && (value !== true) && (value !== false)) {
playerRow.cells[colIndexOpti1].textContent = opti1.toFixed(2);
// Zahl einfuegen
playerRow.cells[colIndexOpti1].style.color = color1;
if (value < 1000) {
playerRow.cells[colIndexMW1].textContent = getNumberString(marktwert.toString());
// Mit 2 Nachkommastellen darstellen
playerRow.cells[colIndexMW1].style.color = color1;
tableRow.cells[this.addCell(tableRow)].textContent = value.toFixed(2);
} else {
} else {
// Feldspieler:
// Mit Tausenderpunkten darstellen
var positionValues = getSortedValuesByPosition(playerRow);
tableRow.cells[this.addCell(tableRow)].textContent = getNumberString(value.toString());
var pos1 = positionValues[0][0];
var opti1 = positionValues[0][1];
var marktwert1 = getNumberString((positionValues[0][2]).toString());
var color1 = getColor(pos1);
var pos2 = positionValues[1][0];
var opti2 = positionValues[1][1];
var marktwert2 = getNumberString((positionValues[1][2]).toString());
var color2 = getColor(pos2);
 
playerRow.cells[colIndexSkill].textContent = skill.toFixed(2);
playerRow.cells[colIndexOpti1].textContent = opti1.toFixed(2);
playerRow.cells[colIndexOpti1].style.color = color1;
playerRow.cells[colIndexMW1].textContent = marktwert1;
playerRow.cells[colIndexMW1].style.color = color1;
playerRow.cells[colIndexOpti2].textContent = opti2.toFixed(2);
playerRow.cells[colIndexMW2].textContent = marktwert2;
playerRow.cells[colIndexMW2].style.color = color2;
playerRow.cells[colIndexOpti2].style.color = color2;
}
}
} else {
} else {
// Ueberschriften:
// String einfuegen
playerRow.cells[colIndexSkill].textContent = "Skillschnitt";
tableRow.cells[this.addCell(tableRow)].textContent = value;
playerRow.cells[colIndexOpti1].textContent = "Opti 1";
playerRow.cells[colIndexMW1].textContent = "Marktwert 1";
playerRow.cells[colIndexOpti2].textContent = "Opti 2";
playerRow.cells[colIndexMW2].textContent = "Marktwert 2";
}
}
tableRow.cells[tableRow.cells.length - 1].style.color = color;
}
}
this.addTitles = function() {
// Titel fuer die aktuellen Werte
if (this.skill) { this.addAndFillCell(playerRows[0], "Skill", titleColor); }
if (this.pos) { this.addAndFillCell(playerRows[0], "Pos", titleColor); }
if (this.opti) {
for (var i = 1; i <= this.anzOpti; i++) {
this.addAndFillCell(playerRows[0], "Opti " + i, titleColor);
if (this.mw && (this.anzMw >= i)) {
this.addAndFillCell(playerRows[0], "MW " + i, titleColor);
}
}
if (this.mw) {
for (var i = this.anzOpti + 1; i <= this.anzMw; i++) {
// Mehr MW- als Opti-Spalten
this.addAndFillCell(playerRows[0], "MW " + i, titleColor);
}
}
} else if (this.mw) {
// Keine Opti-, dafuer MW-Spalten
for (var i = 1; i <= this.anzMw; i++) {
this.addAndFillCell(playerRows[0], "MW " + i, titleColor);
}
}
// Titel fuer die Werte mit Ende 18
if (this.skillE) { this.addAndFillCell(playerRows[0], "Skill" + this.kennzE, titleColor); }
if (this.optiE) {
for (var i = 1; i <= this.anzOptiE; i++) {
this.addAndFillCell(playerRows[0], "Opti " + i + this.kennzE, titleColor);
if (this.mwE && (this.anzMwE >= i)) {
this.addAndFillCell(playerRows[0], "MW " + i + this.kennzE, titleColor);
}
}
if (this.mwE) {
for (var i = this.anzOptiE + 1; i <= this.anzMwE; i++) {
this.addAndFillCell(playerRows[0], "MW " + i + this.kennzE, titleColor);
}
}
} else if (this.mwE) {
for (var i = 1; i <= this.anzMwE; i++) {
this.addAndFillCell(playerRows[0], "MW " + i + this.kennzE, titleColor);
}
}
} // Ende addTitles()
this.addValues = function(player, playerRow) {
// Aktuelle Werte
if (this.skill) {
if (player.isGoalie) { this.addAndFillCell(playerRow, player.getSkill(true), getColor("TOR")); }
else { this.addAndFillCell(playerRow, player.getSkill(true), titleColor); }
}
if (this.pos) {
if (player.isGoalie) { this.addAndFillCell(playerRow, "TOR", getColor("TOR")); }
else { this.addAndFillCell(playerRow, player.getPos(1), getColor(player.getPos(1))); }
}
if (this.opti) {
for (var i = 1; i <= this.anzOpti; i++) {
if (player.isGoalie) {
if (i == 1) {
// TOR-Opti anzeigen
this.addAndFillCell(playerRow, player.getOpti("TOR", true), getColor("TOR"));
} else {
// TOR, aber nicht bester Opti -> nur Zelle hinzufuegen
this.addCell(playerRow);
}
} else {
// Feld-Opti anzeigen
this.addAndFillCell(playerRow, player.getOpti(player.getPos(i), true), getColor(player.getPos(i)));
}
if (this.mw && (this.anzMw >= i)) {
if (player.isGoalie) {
if (i == 1) {
// TOR-MW anzeigen
this.addAndFillCell(playerRow, player.getMarketValue("TOR", true), getColor("TOR"));
} else {
// TOR, aber nicht bester MW -> nur Zelle hinzufuegen
this.addCell(playerRow);
}
} else {
// Feld-MW anzeigen
this.addAndFillCell(playerRow, player.getMarketValue(player.getPos(i), true), getColor(player.getPos(i)));
}
}
}
// Verbleibende MW anzeigen
if (this.mw) {
for (var i = this.anzOpti + 1; i <= this.anzMw; i++) {
if (player.isGoalie) {
if (i == 1) {
// TOR-MW anzeigen
this.addAndFillCell(playerRow, player.getMarketValue("TOR", true), getColor("TOR"));
} else {
// TOR, aber nicht bester MW -> nur Zelle hinzufuegen
this.addCell(playerRow);
}
} else {
// Feld-MW anzeigen
this.addAndFillCell(playerRow, player.getMarketValue(player.getPos(i), true), getColor(player.getPos(i)));
}
}
}
} else if (this.mw) {
// Opti soll nicht angezeigt werden, dafuer aber MW
for (var i = 1; i <= this.anzMw; i++) {
if (player.isGoalie) {
if (i == 1) {
// TOR-MW anzeigen
this.addAndFillCell(playerRow, player.getMarketValue("TOR", true), getColor("TOR"));
} else {
// TOR, aber nicht bester MW -> nur Zelle hinzufuegen
this.addCell(playerRow);
}
} else {
// Feld-MW anzeigen
this.addAndFillCell(playerRow, player.getMarketValue(player.getPos(i), true), getColor(player.getPos(i)));
}
}
}
// Werte mit Ende 18
if (this.skillE) {
if (player.isGoalie) { this.addAndFillCell(playerRow, player.getSkill(false), getColor("TOR")); }
else { this.addAndFillCell(playerRow, player.getSkill(false), titleColor); }
}
if (this.optiE) {
for (var i = 1; i <= this.anzOptiE; i++) {
if (player.isGoalie) {
if (i == 1) {
// TOR-Opti anzeigen
this.addAndFillCell(playerRow, player.getOpti("TOR", false), getColor("TOR"));
} else {
// TOR, aber nicht bester Opti -> nur Zelle hinzufuegen
this.addCell(playerRow);
}
} else {
// Feld-Opti anzeigen
this.addAndFillCell(playerRow, player.getOpti(player.getPos(i), false), getColor(player.getPos(i)));
}
if (this.mwE && (this.anzMwE >= i)) {
if (player.isGoalie) {
if (i == 1) {
// TOR-MW anzeigen
this.addAndFillCell(playerRow, player.getMarketValue("TOR", false), getColor("TOR"));
} else {
// TOR, aber nicht bester MW -> nur Zelle hinzufuegen
this.addCell(playerRow);
}
} else {
// Feld-MW anzeigen
this.addAndFillCell(playerRow, player.getMarketValue(player.getPos(i), false), getColor(player.getPos(i)));
}
}
}
// Verbleibende MW anzeigen
if (this.mwE) {
for (var i = this.anzOptiE + 1; i <= this.anzMwE; i++) {
if (player.isGoalie) {
if (i == 1) {
// TOR-MW anzeigen
this.addAndFillCell(playerRow, player.getMarketValue("TOR", false), getColor("TOR"));
} else {
// TOR, aber nicht bester MW -> nur Zelle hinzufuegen
this.addCell(playerRow);
}
} else {
// Feld-MW anzeigen
this.addAndFillCell(playerRow, player.getMarketValue(player.getPos(i), false), getColor(player.getPos(i)));
}
}
}
} else if (this.mwE) {
// Opti soll nicht angezeigt werden, dafuer aber MW
for (var i = 1; i <= this.anzMwE; i++) {
if (player.isGoalie) {
if (i == 1) {
// TOR-MW anzeigen
this.addAndFillCell(playerRow, player.getMarketValue("TOR", false), getColor("TOR"));
} else {
// TOR, aber nicht bester MW -> nur Zelle hinzufuegen
this.addCell(playerRow);
}
} else {
// Feld-MW anzeigen
this.addAndFillCell(playerRow, player.getMarketValue(player.getPos(i), false), getColor(player.getPos(i)));
}
}
}
} // Ende addValues(player, playerRow)
}
}


function separateAgeGroups() {
// Klasse PlayerRecord ******************************************************************
var playerTable = document.getElementsByTagName("table")[1];
 
function PlayerRecord(age, skills, isGoalie) {
// in this.initPlayer() definiert:
// this.positions[][]: Positionstext und Opti; TOR-Index ist 5
// this.skillsEnd[]: Berechnet aus this.skills, this.age und aktuellerZat
this.age = age;
this.skills = skills;
this.isGoalie = isGoalie;
 
this.toString = function() {
var result = "Alter\t\t" + this.age + "\n\n";
result += "Aktuelle Werte\n";
result += "Skillschnitt\t" + this.getSkill(true).toFixed(2) + "\n";
result += "Optis und Marktwerte";
for (var i = 0; i < this.positions.length; i++) {
result += "\n\t" + this.getPos()[i] + " \t";
result += this.getOpti(this.getPos()[i], true).toFixed(2) + "\t";
result += getNumberString(this.getMarketValue(this.getPos()[i], true).toString());
}
result += "\n\nWerte mit Ende 18\n"
result += "Skillschnitt\t" + this.getSkill(false).toFixed(2) + "\n";
result += "Optis und Marktwerte";
for (var i = 0; i < this.positions.length; i++) {
result += "\n\t" + this.getPos()[i] + " \t";
result += this.getOpti(this.getPos()[i], false).toFixed(2) + "\t";
result += getNumberString(this.getMarketValue(this.getPos()[i], false).toString());
}
return result;
} // Ende this.toString()
 
// Berechnet die Opti-Werte, sortiert das Positionsfeld und berechnet die Einzelskills mit Ende 18
//
this.initPlayer = function() {
this.positions = [];
// ABW
this.positions[0] = [];
this.positions[0][0] = "ABW";
this.positions[0][1] = this.getOpti("ABW", true);
// DMI
this.positions[1] = [];
this.positions[1][0] = "DMI";
this.positions[1][1] = this.getOpti("DMI", true);
// MIT
this.positions[2] = [];
this.positions[2][0] = "MIT";
this.positions[2][1] = this.getOpti("MIT", true);
// OMI
this.positions[3] = [];
this.positions[3][0] = "OMI";
this.positions[3][1] = this.getOpti("OMI", true);
// STU
this.positions[4] = [];
this.positions[4][0] = "STU";
this.positions[4][1] = this.getOpti("STU", true);
// TOR
this.positions[5] = [];
this.positions[5][0] = "TOR";
this.positions[5][1] = this.getOpti("TOR", true);
// Sortieren
sortPositionArray(this.positions);


for (var i = rowOffsetUpper; i < playerTable.rows.length - 1; i++) {
// Einzelskills mit Ende 18 berechnen
if (playerTable.rows[i].cells[colIndexAge].textContent != playerTable.rows[i + 1].cells[colIndexAge].textContent) {
this.skillsEnd = [];
for (var j = colIndexAge; j < playerTable.rows[i].cells.length; j++) {
var zatSoFar = (this.age - 13) * 72 + aktuellerZat;
playerTable.rows[i].cells[j].style.borderBottom = borderString;
var zatTillEnd = (18 - this.age) * 72 + (71 - aktuellerZat);
for (var i = 0; i < this.skills.length; i++) {
if (isTrainableSkill(i)) {
// Auf ganze Zahl runden und parseInt, da das sonst irgendwie als String interpretiert wird
this.skillsEnd[i] = parseInt((this.skills[i] * (1 + zatTillEnd / zatSoFar)).toFixed(0));
} else {
this.skillsEnd[i] = this.skills[i];
}
}
}
}
} // Ende this.iniPlayer()
this.getSkill = function(now) {
var temp = (now) ? this.skills : this.skillsEnd;
var result = 0;
for (var i = 0; i < temp.length; i++) {
result += temp[i];
}
return result / temp.length;
}
this.getPos = function(idx) {
var idxOffset = 1;
return this.positions[idx - idxOffset][0];
}
this.getOpti = function(pos, now) {
var temp = (now) ? this.skills : this.skillsEnd;
var idxPriSkills = getIdxPriSkills(pos);
var idxSecSkills = getIdxSecSkills(pos);
var sumPriSkills = 0;
var sumSecSkills = 0;
for (var i = 0; i < idxPriSkills.length; i++) {
sumPriSkills += temp[idxPriSkills[i]];
}
for (var i = 0; i < idxSecSkills.length; i++) {
sumSecSkills += temp[idxSecSkills[i]];
}
return (5 * sumPriSkills + sumSecSkills) / 27;
}
}
this.getMarketValue = function(pos, now) {
var age = (now) ? this.age : 18;
return Math.round(Math.pow((1 + this.getSkill(now)/100)*(1 + this.getOpti(pos, now)/100)*(2 - age/100), 10) * 2);
}
}
// Funktionen fuer die HTML-Seite *******************************************************
// Liest das Alter aus
//
function getAgeFromHTML(playerRow) {
var colIndexAge = 3;
return parseInt(playerRow.cells[colIndexAge].textContent);
}
}


function getSortedValuesByPosition(playerRow) {
// Liest die Einzelskills aus
//
function getSkillsFromHTML(playerRow) {
var numberOfSkills = 17;
var colOffset = 4;
var result = [];
var result = [];
var skill = getSkill(playerRow);
for (var i = 0; i < numberOfSkills; i++) {
var alter = parseInt(playerRow.cells[colIndexAge].textContent);
result[i] = parseInt(playerRow.cells[i + colOffset].textContent);
 
// Mit Reihenfolge ABW, DMI, MIT, OMI, STU initialisieren:
for (var i = 0; i < 5; i++) {
result[i] = [];
switch (i) {
case 0: result[i][0] = "ABW"; result[i][1] = getOptSkillABW(playerRow); break;
case 1: result[i][0] = "DMI"; result[i][1] = getOptSkillDMI(playerRow); break;
case 2: result[i][0] = "MIT"; result[i][1] = getOptSkillMIT(playerRow); break;
case 3: result[i][0] = "OMI"; result[i][1] = getOptSkillOMI(playerRow); break;
case 4: result[i][0] = "STU"; result[i][1] = getOptSkillSTU(playerRow); break;
}
// Marktwert hinzufuegen:
result[i][2] = getMarketValue(skill, result[i][1], alter);
}
}
// Sortieren:
sortValuesByPosition(result);
return result;
return result;
}
}


function sortValuesByPosition(array) {
// Liest aus, ob der Spieler Torwart oder Feldspieler ist
//
function isGoalieFromHTML(playerRow) {
var colIndexAge = 3;
return (playerRow.cells[colIndexAge].className == "TOR");
}
 
// Hilfsfunktionen **********************************************************************
 
// Sortiert das Positionsfeld per BubbleSort
//
function sortPositionArray(array) {
var temp = [];
var temp = [];
var transposed = true;
var transposed = true;
var length = array.length;
// TOR soll immer die letzte Position im Feld sein, deshalb - 1
var length = array.length - 1;


while (transposed && (length > 1)) {
while (transposed && (length > 1)) {
Zeile 157: Zeile 514:
temp[0] = array[i][0];
temp[0] = array[i][0];
temp[1] = array[i][1];
temp[1] = array[i][1];
temp[2] = array[i][2];
array[i][0] = array[i + 1][0];
array[i][0] = array[i + 1][0];
array[i][1] = array[i + 1][1];
array[i][1] = array[i + 1][1];
array[i][2] = array[i + 1][2];
array[i + 1][0] = temp[0];
array[i + 1][0] = temp[0];
array[i + 1][1] = temp[1];
array[i + 1][1] = temp[1];
array[i + 1][2] = temp[2];
transposed = true;
transposed = true;
}
}
Zeile 171: Zeile 525:
}
}


function getSkill(playerRow) {
// Fuegt in die uebergebene Zahl Tausender-Trennpunkte ein
var colIndexFirstSkill = 4;
// Wandelt einen etwaig vorhandenen Dezimalpunkt in ein Komma um
var colIndexLastSkill = 20;
//
var summe = 0;
 
for (var i = colIndexFirstSkill; i <= colIndexLastSkill; i++) {
summe += parseInt(playerRow.cells[i].textContent);
}
return summe / 17;
}
 
function getMarketValue(skill, opti, alter) {
return Math.round(Math.pow((1 + skill/100)*(1 + opti/100)*(2 - alter/100), 10) * 2);
}
 
function getNumberString(numberString) {
function getNumberString(numberString) {
if (numberString.lastIndexOf(".") != -1) {
if (numberString.lastIndexOf(".") != -1) {
Zeile 205: Zeile 547:
}
}


// Dreht den uebergebenen String um
//
function reverseString(string) {
function reverseString(string) {
var result = "";
var result = "";
Zeile 213: Zeile 557:
}
}


// Schaut nach, ob der uebergebene Index zu einem trainierbaren Skill gehoert
// Die Indizes gehen von 0 (SCH) bis 16 (EIN)
//
function isTrainableSkill(idx) {
var trainableSkills = [0, 1, 2, 3, 4, 5, 8, 9, 10, 11, 15];
var result = false;
for (var i = 0; i < trainableSkills.length; i++) {
if (idx == trainableSkills[i]) { result = true; break; }
}
return result;
}
// Gibt die Indizes der Primaerskills zurueck
//
function getIdxPriSkills(pos) {
switch(pos) {
case "TOR": return new Array(2, 3, 4, 5);
case "ABW": return new Array(2, 3, 4, 15);
case "DMI": return new Array(1, 4, 9, 11);
case "MIT": return new Array(1, 3, 9, 11);
case "OMI": return new Array(1, 5, 9, 11);
case "STU": return new Array(0, 2, 3, 5);
default: return new Array();
}
}
// Gibt die Indizes der Sekundaerskills zurueck
//
function getIdxSecSkills(pos) {
switch(pos) {
case "TOR": return new Array(0, 1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
case "ABW": return new Array(0, 1, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16);
case "DMI": return new Array(0, 2, 3, 5, 6, 7, 8, 10, 12, 13, 14, 15, 16);
case "MIT": return new Array(0, 2, 4, 5, 6, 7, 8, 10, 12, 13, 14, 15, 16);
case "OMI": return new Array(0, 2, 3, 4, 6, 7, 8, 10, 12, 13, 14, 15, 16);
case "STU": return new Array(1, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
default: return new Array();
}
}
// Gibt die zur Position gehoerige Farbe zurueck
//
function getColor(pos) {
function getColor(pos) {
switch (pos) {
switch (pos) {
Zeile 222: Zeile 608:
case "STU": return "#FF0000";
case "STU": return "#FF0000";
case "LEI": return "#FFFFFF";
case "LEI": return "#FFFFFF";
default: return "";
default: return "";
}
}
 
function getOptSkillTOR(playerRow) {
var colIndicesPriTOR = new Array(6, 7, 8, 9);
var colIndicesSecTOR = new Array(4, 5, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20);
var sumPrimary = 0;
var sumSecondary = 0;
for (var i = 0; i < colIndicesPriTOR.length; i++) {
sumPrimary += parseInt(playerRow.cells[colIndicesPriTOR[i]].textContent);
}
for (var i = 0; i < colIndicesSecTOR.length; i++) {
sumSecondary += parseInt(playerRow.cells[colIndicesSecTOR[i]].textContent);
}
return (5 * sumPrimary + sumSecondary) / 27;
}
 
function getOptSkillABW(playerRow) {
var colIndicesPriABW = new Array(6, 7, 8, 19);
var colIndicesSecABW = new Array(4, 5, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20);
var sumPrimary = 0;
var sumSecondary = 0;
for (var i = 0; i < colIndicesPriABW.length; i++) {
sumPrimary += parseInt(playerRow.cells[colIndicesPriABW[i]].textContent);
}
for (var i = 0; i < colIndicesSecABW.length; i++) {
sumSecondary += parseInt(playerRow.cells[colIndicesSecABW[i]].textContent);
}
return (5 * sumPrimary + sumSecondary) / 27;
}
 
function getOptSkillDMI(playerRow) {
var colIndicesPriDMI = new Array(5, 8, 13, 15);
var colIndicesSecDMI = new Array(4, 6, 7, 9, 10, 11, 12, 14, 16, 17, 18, 19, 20);
var sumPrimary = 0;
var sumSecondary = 0;
for (var i = 0; i < colIndicesPriDMI.length; i++) {
sumPrimary += parseInt(playerRow.cells[colIndicesPriDMI[i]].textContent);
}
for (var i = 0; i < colIndicesSecDMI.length; i++) {
sumSecondary += parseInt(playerRow.cells[colIndicesSecDMI[i]].textContent);
}
return (5 * sumPrimary + sumSecondary) / 27;
}
 
function getOptSkillMIT(playerRow) {
var colIndicesPriMIT = new Array(5, 7, 13, 15);
var colIndicesSecMIT = new Array(4, 6, 8, 9, 10, 11, 12, 14, 16, 17, 18, 19, 20);
var sumPrimary = 0;
var sumSecondary = 0;
for (var i = 0; i < colIndicesPriMIT.length; i++) {
sumPrimary += parseInt(playerRow.cells[colIndicesPriMIT[i]].textContent);
}
for (var i = 0; i < colIndicesSecMIT.length; i++) {
sumSecondary += parseInt(playerRow.cells[colIndicesSecMIT[i]].textContent);
}
return (5 * sumPrimary + sumSecondary) / 27;
}
 
function getOptSkillOMI(playerRow) {
var colIndicesPriOMI = new Array(5, 9, 13, 15);
var colIndicesSecOMI = new Array(4, 6, 7, 8, 10, 11, 12, 14, 16, 17, 18, 19, 20);
var sumPrimary = 0;
var sumSecondary = 0;
for (var i = 0; i < colIndicesPriOMI.length; i++) {
sumPrimary += parseInt(playerRow.cells[colIndicesPriOMI[i]].textContent);
}
for (var i = 0; i < colIndicesSecOMI.length; i++) {
sumSecondary += parseInt(playerRow.cells[colIndicesSecOMI[i]].textContent);
}
return (5 * sumPrimary + sumSecondary) / 27;
}
 
function getOptSkillSTU(playerRow) {
var colIndicesPriSTU = new Array(4, 6, 7, 9);
var colIndicesSecSTU = new Array(5, 8, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20);
var sumPrimary = 0;
var sumSecondary = 0;
for (var i = 0; i < colIndicesPriSTU.length; i++) {
sumPrimary += parseInt(playerRow.cells[colIndicesPriSTU[i]].textContent);
}
for (var i = 0; i < colIndicesSecSTU.length; i++) {
sumSecondary += parseInt(playerRow.cells[colIndicesSecSTU[i]].textContent);
}
}
return (5 * sumPrimary + sumSecondary) / 27;
}
}
</pre>
</pre>

Version vom 14. Februar 2013, 20:03 Uhr

OS2.jugendV3
Dateiname os2.jugendV3.user.js
Version 3.0
Autor Andreas Eckes, Strindheim BK
Beschreibung Jugendteam-Script fuer Online Soccer 2.0
Webseiten ju.php?page=2
Jugend-Spielereinzelwerte
Funktionalität Trennstriche zwischen den Jahrgängen
Aktueller Skill, Opti und MW
Prognose von Opti und MW für Ende Jahrgang 18
Letzte Änderung 14.02.2013
// ==UserScript==
// @name OS2.jugendV3
// @description Jugendteam-Script fuer Online Soccer 2.0
// @include http://os.ongapo.com/ju.php?page=2
// @include http://online-soccer.eu/ju.php?page=2
// @include http://www.online-soccer.eu/ju.php?page=2
// ==/UserScript==

// Konfiguration ************************************************************************

// Entscheidend fuer die Berechnung der Werte mit Ende 18, sollte also moeglichst aktuell sein
// Fuer jeden Skill wird anhand der Ist-Daten die Anzahl an Aufwertungen pro Zat bestimmt
// Diese Zahl wird auch fuer die Zukunft angenommen
// D.h. es wird angenommen, dass jeder Spieler bis zum Ende genau so trainiert wie bisher
var aktuellerZat = 1;

// Spaltenauswahl fuer die aktuellen Werte (true = anzeigen, false = nicht anzeigen)
// anzahlOpti gibt die Anzahl der Opti-Spalten an
// 1: nur bester Opti, 2: die beiden besten, ..., 6: Alle inklusive TOR
// Bei Torhuetern wird immer nur der TOR-Opti angezeigt
// Werte < 1 oder > 6 schalten die Anzeige aus
// anzahlMW funktioniert analog
var zeigeSkill = true;
var zeigePosition = false;
var anzahlOpti = 1;
var anzahlMW = 1;

// Spaltenauswahl fuer die Werte mit Ende 18
// Bedeutungen sind wie fuer die aktuellen Werte
var zeigeSkillEnde = true;
var anzahlOptiEnde = 1;
var anzahlMWEnde = 1;

// Text, mit dem die "Ende 18"-Spaltentitel gekennzeichnet werden
// "\u03A9" stellt das Unicode-Zeichen Nummer 03A9 dar (grosses Omega)
var kennzeichenEnde = " \u03A9";

// Variablen ****************************************************************************

var url = window.location.href;
var borderString = "solid white 1px";
var titleColor = "#FFFFFF";
var rowOffset = 1;
var players = [];
var playerRows = document.getElementsByTagName("table")[1].getElementsByTagName("tr");

// Programm *****************************************************************************

var colMan = new ColumnManager();
colMan.addTitles();
init();
for (var i = 0; i < players.length; i++) {
	colMan.addValues(players[i], playerRows[i + rowOffset]);
}
separateAgeGroups();
// Spaltentitel zentrieren
playerRows[0].align = "center";

// Funktionen ***************************************************************************

// Erschafft die Spieler-Objekte und fuellt sie mit Werten
//
function init() {
	var playerRow;
	var age;
	var skills;
	var isGoalie;
	for (var i = rowOffset; i < playerRows.length; i++) {
		playerRow = playerRows[i];
		age = getAgeFromHTML(playerRow);
		skills = getSkillsFromHTML(playerRow);
		isGoalie = isGoalieFromHTML(playerRow);
		players[i - rowOffset] = new PlayerRecord(age, skills, isGoalie);
		players[i - rowOffset].initPlayer();
	}
}

// Trennt die Jahrgaenge mit Linien
//
function separateAgeGroups() {
	var colIdxAge = 3;
	var playerTable = document.getElementsByTagName("table")[1];

	for (var i = rowOffset; i < playerTable.rows.length - 1; i++) {
		if (playerTable.rows[i].cells[colIdxAge].textContent != playerTable.rows[i + 1].cells[colIdxAge].textContent) {
			for (var j = colIdxAge; j < playerTable.rows[i].cells.length; j++) {
				playerTable.rows[i].cells[j].style.borderBottom = borderString;
			}
		}
	}
}

// Klasse ColumnManager *****************************************************************

function ColumnManager() {
	this.skill = zeigeSkill;
	this.pos = zeigePosition;
	this.opti = ((anzahlOpti >= 1) && (anzahlOpti <= 6)) ? true : false;
	this.mw = ((anzahlMW >= 1) && (anzahlMW <= 6)) ? true : false;
	this.anzOpti = anzahlOpti;
	this.anzMw = anzahlMW;
	this.skillE = zeigeSkillEnde;
	this.optiE = ((anzahlOptiEnde >= 1) && (anzahlOptiEnde <= 6)) ? true : false;
	this.mwE = ((anzahlMWEnde >= 1) && (anzahlMWEnde <= 6)) ? true : false;
	this.anzOptiE = anzahlOptiEnde;
	this.anzMwE = anzahlMWEnde;
	this.kennzE = kennzeichenEnde;

	this.toString = function() {
		var result = "Skillschnitt\t\t" + this.skill + "\n";
		result += "Beste Position\t" + this.pos + "\n";
		result += "Optis\t\t\t" + this.opti + " (" + this.anzOpti + ")\n";
		result += "Marktwerte\t\t" + this.mw + " (" + this.anzMw + ")\n";
		result += "Skillschnitt Ende\t" + this.skillE + "\n";
		result += "Optis Ende\t\t" + this.optiE + " (" + this.anzOptiE + ")\n";
		result += "Marktwerte Ende\t" + this.mwE + " (" + this.anzMwE + ")\n";
		return result;
	}

	this.addCell = function(tableRow) {
		tableRow.insertCell(-1);
		return tableRow.cells.length - 1;
	}

	this.addAndFillCell = function(tableRow, value, color) {
		if (isFinite(value) && (value !== true) && (value !== false)) {
			// Zahl einfuegen
			if (value < 1000) {
				// Mit 2 Nachkommastellen darstellen
				tableRow.cells[this.addCell(tableRow)].textContent = value.toFixed(2);
			} else {
				// Mit Tausenderpunkten darstellen
				tableRow.cells[this.addCell(tableRow)].textContent = getNumberString(value.toString());
			}
		} else {
			// String einfuegen
			tableRow.cells[this.addCell(tableRow)].textContent = value;
		}
		tableRow.cells[tableRow.cells.length - 1].style.color = color;
	}

	this.addTitles = function() {
		// Titel fuer die aktuellen Werte
		if (this.skill) { this.addAndFillCell(playerRows[0], "Skill", titleColor); }
		if (this.pos) { this.addAndFillCell(playerRows[0], "Pos", titleColor); }
		if (this.opti) {
			for (var i = 1; i <= this.anzOpti; i++) {
				this.addAndFillCell(playerRows[0], "Opti " + i, titleColor);
				if (this.mw && (this.anzMw >= i)) {
					this.addAndFillCell(playerRows[0], "MW " + i, titleColor);
				}
			}
			if (this.mw) {
				for (var i = this.anzOpti + 1; i <= this.anzMw; i++) {
					// Mehr MW- als Opti-Spalten
					this.addAndFillCell(playerRows[0], "MW " + i, titleColor);
				}
			}
		} else if (this.mw) {
			// Keine Opti-, dafuer MW-Spalten
			for (var i = 1; i <= this.anzMw; i++) {
				this.addAndFillCell(playerRows[0], "MW " + i, titleColor);
			}
		}

		// Titel fuer die Werte mit Ende 18
		if (this.skillE) { this.addAndFillCell(playerRows[0], "Skill" + this.kennzE, titleColor); }
		if (this.optiE) {
			for (var i = 1; i <= this.anzOptiE; i++) {
				this.addAndFillCell(playerRows[0], "Opti " + i + this.kennzE, titleColor);
				if (this.mwE && (this.anzMwE >= i)) {
					this.addAndFillCell(playerRows[0], "MW " + i + this.kennzE, titleColor);
				}
			}
			if (this.mwE) {
				for (var i = this.anzOptiE + 1; i <= this.anzMwE; i++) {
					this.addAndFillCell(playerRows[0], "MW " + i + this.kennzE, titleColor);
				}
			}
		} else if (this.mwE) {
			for (var i = 1; i <= this.anzMwE; i++) {
				this.addAndFillCell(playerRows[0], "MW " + i + this.kennzE, titleColor);
			}
		}
	} // Ende addTitles()

	this.addValues = function(player, playerRow) {
		// Aktuelle Werte
		if (this.skill) {
			if (player.isGoalie) { this.addAndFillCell(playerRow, player.getSkill(true), getColor("TOR")); }
			else { this.addAndFillCell(playerRow, player.getSkill(true), titleColor); }
		}
		if (this.pos) {
			if (player.isGoalie) { this.addAndFillCell(playerRow, "TOR", getColor("TOR")); }
			else { this.addAndFillCell(playerRow, player.getPos(1), getColor(player.getPos(1))); }
		}
		if (this.opti) {
			for (var i = 1; i <= this.anzOpti; i++) {
				if (player.isGoalie) {
					if (i == 1) {
						// TOR-Opti anzeigen
						this.addAndFillCell(playerRow, player.getOpti("TOR", true), getColor("TOR"));
					} else {
						// TOR, aber nicht bester Opti -> nur Zelle hinzufuegen
						this.addCell(playerRow);
					}
				} else {
					// Feld-Opti anzeigen
					this.addAndFillCell(playerRow, player.getOpti(player.getPos(i), true), getColor(player.getPos(i)));
				}
				if (this.mw && (this.anzMw >= i)) {
					if (player.isGoalie) {
						if (i == 1) {
							// TOR-MW anzeigen
							this.addAndFillCell(playerRow, player.getMarketValue("TOR", true), getColor("TOR"));
						} else {
							// TOR, aber nicht bester MW -> nur Zelle hinzufuegen
							this.addCell(playerRow);
						}
					} else {
						// Feld-MW anzeigen
						this.addAndFillCell(playerRow, player.getMarketValue(player.getPos(i), true), getColor(player.getPos(i)));
					}
				}
			}
			// Verbleibende MW anzeigen
			if (this.mw) {
				for (var i = this.anzOpti + 1; i <= this.anzMw; i++) {
					if (player.isGoalie) {
						if (i == 1) {
							// TOR-MW anzeigen
							this.addAndFillCell(playerRow, player.getMarketValue("TOR", true), getColor("TOR"));
						} else {
							// TOR, aber nicht bester MW -> nur Zelle hinzufuegen
							this.addCell(playerRow);
						}
					} else {
						// Feld-MW anzeigen
						this.addAndFillCell(playerRow, player.getMarketValue(player.getPos(i), true), getColor(player.getPos(i)));
					}
				}
			}
		} else if (this.mw) {
			// Opti soll nicht angezeigt werden, dafuer aber MW
			for (var i = 1; i <= this.anzMw; i++) {
				if (player.isGoalie) {
					if (i == 1) {
						// TOR-MW anzeigen
						this.addAndFillCell(playerRow, player.getMarketValue("TOR", true), getColor("TOR"));
					} else {
						// TOR, aber nicht bester MW -> nur Zelle hinzufuegen
						this.addCell(playerRow);
					}
				} else {
					// Feld-MW anzeigen
					this.addAndFillCell(playerRow, player.getMarketValue(player.getPos(i), true), getColor(player.getPos(i)));
				}
			}
		}

		// Werte mit Ende 18
		if (this.skillE) {
			if (player.isGoalie) { this.addAndFillCell(playerRow, player.getSkill(false), getColor("TOR")); }
			else { this.addAndFillCell(playerRow, player.getSkill(false), titleColor); }
		}
		if (this.optiE) {
			for (var i = 1; i <= this.anzOptiE; i++) {
				if (player.isGoalie) {
					if (i == 1) {
						// TOR-Opti anzeigen
						this.addAndFillCell(playerRow, player.getOpti("TOR", false), getColor("TOR"));
					} else {
						// TOR, aber nicht bester Opti -> nur Zelle hinzufuegen
						this.addCell(playerRow);
					}
				} else {
					// Feld-Opti anzeigen
					this.addAndFillCell(playerRow, player.getOpti(player.getPos(i), false), getColor(player.getPos(i)));
				}
				if (this.mwE && (this.anzMwE >= i)) {
					if (player.isGoalie) {
						if (i == 1) {
							// TOR-MW anzeigen
							this.addAndFillCell(playerRow, player.getMarketValue("TOR", false), getColor("TOR"));
						} else {
							// TOR, aber nicht bester MW -> nur Zelle hinzufuegen
							this.addCell(playerRow);
						}
					} else {
						// Feld-MW anzeigen
						this.addAndFillCell(playerRow, player.getMarketValue(player.getPos(i), false), getColor(player.getPos(i)));
					}
				}
			}
			// Verbleibende MW anzeigen
			if (this.mwE) {
				for (var i = this.anzOptiE + 1; i <= this.anzMwE; i++) {
					if (player.isGoalie) {
						if (i == 1) {
							// TOR-MW anzeigen
							this.addAndFillCell(playerRow, player.getMarketValue("TOR", false), getColor("TOR"));
						} else {
						 	// TOR, aber nicht bester MW -> nur Zelle hinzufuegen
							this.addCell(playerRow);
						}
					} else {
						// Feld-MW anzeigen
						this.addAndFillCell(playerRow, player.getMarketValue(player.getPos(i), false), getColor(player.getPos(i)));
					}
				}
			}
		} else if (this.mwE) {
			// Opti soll nicht angezeigt werden, dafuer aber MW
			for (var i = 1; i <= this.anzMwE; i++) {
				if (player.isGoalie) {
					if (i == 1) {
						// TOR-MW anzeigen
						this.addAndFillCell(playerRow, player.getMarketValue("TOR", false), getColor("TOR"));
					} else {
						// TOR, aber nicht bester MW -> nur Zelle hinzufuegen
						this.addCell(playerRow);
					}
				} else {
					// Feld-MW anzeigen
					this.addAndFillCell(playerRow, player.getMarketValue(player.getPos(i), false), getColor(player.getPos(i)));
				}
			}
		}
	} // Ende addValues(player, playerRow)
}

// Klasse PlayerRecord ******************************************************************

function PlayerRecord(age, skills, isGoalie) {
	// in this.initPlayer() definiert:
	// this.positions[][]: Positionstext und Opti; TOR-Index ist 5
	// this.skillsEnd[]: Berechnet aus this.skills, this.age und aktuellerZat
	this.age = age;
	this.skills = skills;
	this.isGoalie = isGoalie;

	this.toString = function() {
		var result = "Alter\t\t" + this.age + "\n\n";
		result += "Aktuelle Werte\n";
		result += "Skillschnitt\t" + this.getSkill(true).toFixed(2) + "\n";
		result += "Optis und Marktwerte";
		for (var i = 0; i < this.positions.length; i++) {
			result += "\n\t" + this.getPos()[i] + " \t";
			result += this.getOpti(this.getPos()[i], true).toFixed(2) + "\t";
			result += getNumberString(this.getMarketValue(this.getPos()[i], true).toString());
		}
		result += "\n\nWerte mit Ende 18\n"
		result += "Skillschnitt\t" + this.getSkill(false).toFixed(2) + "\n";
		result += "Optis und Marktwerte";
		for (var i = 0; i < this.positions.length; i++) {
			result += "\n\t" + this.getPos()[i] + " \t";
			result += this.getOpti(this.getPos()[i], false).toFixed(2) + "\t";
			result += getNumberString(this.getMarketValue(this.getPos()[i], false).toString());
		}
		return result;
	} // Ende this.toString()

	// Berechnet die Opti-Werte, sortiert das Positionsfeld und berechnet die Einzelskills mit Ende 18
	//
	this.initPlayer = function() {
		this.positions = [];
		// ABW
		this.positions[0] = [];
		this.positions[0][0] = "ABW";
		this.positions[0][1] = this.getOpti("ABW", true);
		// DMI
		this.positions[1] = [];
		this.positions[1][0] = "DMI";
		this.positions[1][1] = this.getOpti("DMI", true);
		// MIT
		this.positions[2] = [];
		this.positions[2][0] = "MIT";
		this.positions[2][1] = this.getOpti("MIT", true);
		// OMI
		this.positions[3] = [];
		this.positions[3][0] = "OMI";
		this.positions[3][1] = this.getOpti("OMI", true);
		// STU
		this.positions[4] = [];
		this.positions[4][0] = "STU";
		this.positions[4][1] = this.getOpti("STU", true);
		// TOR
		this.positions[5] = [];
		this.positions[5][0] = "TOR";
		this.positions[5][1] = this.getOpti("TOR", true);
		// Sortieren
		sortPositionArray(this.positions);

		// Einzelskills mit Ende 18 berechnen
		this.skillsEnd = [];
		var zatSoFar = (this.age - 13) * 72 + aktuellerZat;
		var zatTillEnd = (18 - this.age) * 72 + (71 - aktuellerZat);
		for (var i = 0; i < this.skills.length; i++) {
			if (isTrainableSkill(i)) {
				// Auf ganze Zahl runden und parseInt, da das sonst irgendwie als String interpretiert wird
				this.skillsEnd[i] = parseInt((this.skills[i] * (1 + zatTillEnd / zatSoFar)).toFixed(0));
			} else {
				this.skillsEnd[i] = this.skills[i];
			}
		}
	} // Ende this.iniPlayer()

	this.getSkill = function(now) {
		var temp = (now) ? this.skills : this.skillsEnd;
		var result = 0;
		for (var i = 0; i < temp.length; i++) {
			result += temp[i];
		}
		return result / temp.length;
	}

	this.getPos = function(idx) {
		var idxOffset = 1;
		return this.positions[idx - idxOffset][0];
	}

	this.getOpti = function(pos, now) {
		var temp = (now) ? this.skills : this.skillsEnd;
		var idxPriSkills = getIdxPriSkills(pos);
		var idxSecSkills = getIdxSecSkills(pos);
		var sumPriSkills = 0;
		var sumSecSkills = 0;
		for (var i = 0; i < idxPriSkills.length; i++) {
			sumPriSkills += temp[idxPriSkills[i]];
		}
		for (var i = 0; i < idxSecSkills.length; i++) {
			sumSecSkills += temp[idxSecSkills[i]];
		}
		return (5 * sumPriSkills + sumSecSkills) / 27;
	}

	this.getMarketValue = function(pos, now) {
		var age = (now) ? this.age : 18;
		return Math.round(Math.pow((1 + this.getSkill(now)/100)*(1 + this.getOpti(pos, now)/100)*(2 - age/100), 10) * 2);
	}
}

// Funktionen fuer die HTML-Seite *******************************************************

// Liest das Alter aus
//
function getAgeFromHTML(playerRow) {
	var colIndexAge = 3;
	return parseInt(playerRow.cells[colIndexAge].textContent);
}

// Liest die Einzelskills aus
//
function getSkillsFromHTML(playerRow) {
	var numberOfSkills = 17;
	var colOffset = 4;
	var result = [];
	for (var i = 0; i < numberOfSkills; i++) {
		result[i] = parseInt(playerRow.cells[i + colOffset].textContent);
	}
	return result;
}

// Liest aus, ob der Spieler Torwart oder Feldspieler ist
//
function isGoalieFromHTML(playerRow) {
	var colIndexAge = 3;
	return (playerRow.cells[colIndexAge].className == "TOR");
}

// Hilfsfunktionen **********************************************************************

// Sortiert das Positionsfeld per BubbleSort
//
function sortPositionArray(array) {
	var temp = [];
	var transposed = true;
	// TOR soll immer die letzte Position im Feld sein, deshalb - 1
	var length = array.length - 1;

	while (transposed && (length > 1)) {
		transposed = false;
		for (var i = 0; i < length - 1; i++) {
			// Vergleich Opti-Werte:
			if (array[i][1] < array[i + 1][1]) {
				// vertauschen
				temp[0] = array[i][0];
				temp[1] = array[i][1];
				array[i][0] = array[i + 1][0];
				array[i][1] = array[i + 1][1];
				array[i + 1][0] = temp[0];
				array[i + 1][1] = temp[1];
				transposed = true;
			}
		}
		length -= 1;
	}
}

// Fuegt in die uebergebene Zahl Tausender-Trennpunkte ein
// Wandelt einen etwaig vorhandenen Dezimalpunkt in ein Komma um
//
function getNumberString(numberString) {
	if (numberString.lastIndexOf(".") != -1) {
		// Zahl enthaelt Dezimalpunkt
		var wholePart = numberString.substring(0, numberString.lastIndexOf("."));
		var decimalPart = numberString.substring(numberString.lastIndexOf(".") + 1, numberString.length);
		return getNumberString(wholePart) + "," + decimalPart;
	} else {
		// Kein Dezimalpunkt, fuege Tausender-Trennpunkte ein:
		// String umdrehen, nach jedem dritten Zeichen Punkt einfuegen, dann wieder umdrehen:
		var temp = reverseString(numberString);
		var result = "";
		for (var i = 0; i < temp.length; i++) {
			if ((i > 0) && (i % 3 == 0)) { result += "."; }
			result += temp.substr(i, 1);
		}
		return reverseString(result);
	}
}

// Dreht den uebergebenen String um
//
function reverseString(string) {
	var result = "";
	for (var i = string.length - 1; i >= 0; i--) {
		result += string.substr(i, 1);
	}
	return result;
}

// Schaut nach, ob der uebergebene Index zu einem trainierbaren Skill gehoert
// Die Indizes gehen von 0 (SCH) bis 16 (EIN)
//
function isTrainableSkill(idx) {
	var trainableSkills = [0, 1, 2, 3, 4, 5, 8, 9, 10, 11, 15];
	var result = false;
	for (var i = 0; i < trainableSkills.length; i++) {
		if (idx == trainableSkills[i]) { result = true; break; }
	}
	return result;
}

// Gibt die Indizes der Primaerskills zurueck
//
function getIdxPriSkills(pos) {
	switch(pos) {
		case "TOR": return new Array(2, 3, 4, 5);
		case "ABW": return new Array(2, 3, 4, 15);
		case "DMI": return new Array(1, 4, 9, 11);
		case "MIT": return new Array(1, 3, 9, 11);
		case "OMI": return new Array(1, 5, 9, 11);
		case "STU": return new Array(0, 2, 3, 5);
		default: return new Array();
	}
}

// Gibt die Indizes der Sekundaerskills zurueck
//
function getIdxSecSkills(pos) {
	switch(pos) {
		case "TOR": return new Array(0, 1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
		case "ABW": return new Array(0, 1, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16);
		case "DMI": return new Array(0, 2, 3, 5, 6, 7, 8, 10, 12, 13, 14, 15, 16);
		case "MIT": return new Array(0, 2, 4, 5, 6, 7, 8, 10, 12, 13, 14, 15, 16);
		case "OMI": return new Array(0, 2, 3, 4, 6, 7, 8, 10, 12, 13, 14, 15, 16);
		case "STU": return new Array(1, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
		default: return new Array();
	}
}

// Gibt die zur Position gehoerige Farbe zurueck
//
function getColor(pos) {
	switch (pos) {
		case "TOR": return "#FFFF00";
		case "ABW": return "#00FF00";
		case "DMI": return "#3366FF";
		case "MIT": return "#66FFFF";
		case "OMI": return "#FF66FF";
		case "STU": return "#FF0000";
		case "LEI": return "#FFFFFF";
		default: return "";
	}
}