Ejemplo n.º 1
0
        private void generateLineUPXML(List <PlayerEvaluationEntry> evaluatedLineUp, XmlElement teamNode)
        {
            XmlElement lineupNode = xmlDoc.CreateElement("lineup");
            int        sub        = 0;

            for (int i = 0; i < 11; i++)
            {
                PlayerEvaluationEntry en = evaluatedLineUp.ElementAt(i);
                if (en.Pid.Equals("ris") || en.Pid.Equals("none"))
                {
                    sub++;
                }
                lineupNode.AppendChild(generatePlayerXML(en));
            }
            teamNode.AppendChild(lineupNode);

            XmlElement substitutesNode = xmlDoc.CreateElement("substitutes");

            for (int i = 11; i < 19 + sub; i++)
            {
                substitutesNode.AppendChild(generatePlayerXML(evaluatedLineUp.ElementAt(i)));
            }
            teamNode.AppendChild(substitutesNode);

            XmlElement excludedNode = xmlDoc.CreateElement("excluded");

            for (int i = 19 + sub; i < evaluatedLineUp.Count; i++)
            {
                excludedNode.AppendChild(generatePlayerXML(evaluatedLineUp.ElementAt(i)));
            }
            teamNode.AppendChild(excludedNode);
        }
Ejemplo n.º 2
0
        private double calculateParzialeSquadra(List <PlayerEvaluationEntry> evaluatedLinueUp)
        {
            double parziale = 0;

            for (int i = 0; i < 11; i++)
            {
                PlayerEvaluationEntry e = evaluatedLinueUp.ElementAt(i);
                parziale += e.Vote + e.BonusMalus;
            }
            return(parziale);
        }
Ejemplo n.º 3
0
        private double calculateModAttacco(List <PlayerEvaluationEntry> evaluatedLineUp)
        {
            double sum = 0;

            for (int i = 0; i < 11; i++)
            {
                PlayerEvaluationEntry en = evaluatedLineUp.ElementAt(i);
                Player p = PlayerList.getPlayer(en.Pid);
                if (!en.Pid.Equals("ris") && !en.Pid.Equals("none") && p.Position.Equals("S") && !en.ScoredGoal && en.Vote > 6)
                {
                    sum += en.Vote - 6;
                }
            }
            return(sum);
        }
Ejemplo n.º 4
0
        private double calculateModDifesa(List <PlayerEvaluationEntry> evaluatedLineUpHome)
        {
            int    nrPlayer = 0;
            double sum      = 0;

            for (int i = 0; i < 11; i++)
            {
                PlayerEvaluationEntry en = evaluatedLineUpHome.ElementAt(i);
                Player p = PlayerList.getPlayer(en.Pid);
                if (!en.Pid.Equals("ris") && !en.Pid.Equals("none") && p.Position.Equals("D"))
                {
                    sum += en.Vote;
                    nrPlayer++;
                }
            }
            int correction = nrPlayer - 4;

            sum += correction;

            return(getModDifesa(sum / nrPlayer));
        }
Ejemplo n.º 5
0
        private double[] calculateModCentrocampo(List <PlayerEvaluationEntry> evaluatedLineUpHome, List <PlayerEvaluationEntry> evaluatedLineUpAway)
        {
            int    nrPlayerHome = 0;
            double sumHome      = 0;

            for (int i = 0; i < 11; i++)
            {
                PlayerEvaluationEntry en = evaluatedLineUpHome.ElementAt(i);
                Player p = PlayerList.getPlayer(en.Pid);
                if (!en.Pid.Equals("ris") && !en.Pid.Equals("none") && p.Position.Equals("M"))
                {
                    sumHome += evaluatedLineUpHome.ElementAt(i).Vote;
                    nrPlayerHome++;
                }

                /*else if ((en.Pid.Equals("ris") || en.Pid.Equals("none")) && en.Pos.Equals("M"))
                 * {
                 *  nrPlayerHome++;
                 * }*/
            }

            int    nrPlayerAway = 0;
            double sumAway      = 0;

            for (int i = 0; i < 11; i++)
            {
                PlayerEvaluationEntry en = evaluatedLineUpAway.ElementAt(i);
                Player p = PlayerList.getPlayer(en.Pid);
                if (!en.Pid.Equals("ris") && !en.Pid.Equals("none") && p.Position.Equals("M"))
                {
                    sumAway += evaluatedLineUpAway.ElementAt(i).Vote;
                    nrPlayerAway++;
                }

                /*else if ((en.Pid.Equals("ris") || en.Pid.Equals("none")) && en.Pos.Equals("M"))
                 * {
                 *  nrPlayerAway++;
                 * }*/
            }

            if (nrPlayerHome > nrPlayerAway)
            {
                int correction = nrPlayerHome - nrPlayerAway;
                sumAway += correction * 5;
            }
            else if (nrPlayerHome < nrPlayerAway)
            {
                int correction = nrPlayerAway - nrPlayerHome;
                sumHome += correction * 5;
            }

            double[] mod = new double[2];
            if (sumHome < sumAway)
            {
                double erg = getModCentrocampo(sumAway - sumHome);
                mod[0] = erg * -1;
                mod[1] = erg;
            }
            else
            {
                double erg = getModCentrocampo(sumHome - sumAway);
                mod[0] = erg;
                mod[1] = erg * -1;
            }

            return(mod);
        }
Ejemplo n.º 6
0
        private XmlElement generatePlayerXML(PlayerEvaluationEntry en)
        {
            XmlElement playerNode = xmlDoc.CreateElement("footballer");

            playerNode.SetAttribute("id", en.Pid);
            string role;
            string name;
            string squad;
            string grade;
            string bonus;
            string total;

            if (en.Pid.Equals("none"))
            {
                role  = en.Pos;
                name  = "-----------------------";
                squad = "";
            }
            else if (en.Pid.Equals("ris"))
            {
                role  = en.Pos;
                name  = "Riserva d'Ufficio";
                squad = "";
            }
            else
            {
                Player p = PlayerList.getPlayer(en.Pid);
                role  = p.Position;
                name  = p.Name;
                squad = p.Team;
            }
            grade = en.Vote + "";
            bonus = en.BonusMalus + "";
            total = (en.Vote + en.BonusMalus) + "";
            XmlElement playerPosNode = xmlDoc.CreateElement("role");

            playerPosNode.InnerText = role;
            playerNode.AppendChild(playerPosNode);
            XmlElement playerNameNode = xmlDoc.CreateElement("name");

            playerNameNode.InnerText = name;
            playerNode.AppendChild(playerNameNode);
            XmlElement playerSqadNode = xmlDoc.CreateElement("squad");

            playerSqadNode.InnerText = squad;
            playerNode.AppendChild(playerSqadNode);
            XmlElement playerGradeNode = xmlDoc.CreateElement("grade");

            playerGradeNode.InnerText = grade;
            playerNode.AppendChild(playerGradeNode);
            XmlElement playerBonusNode = xmlDoc.CreateElement("bonus");

            playerBonusNode.InnerText = bonus;
            playerNode.AppendChild(playerBonusNode);
            XmlElement playerTotalNode = xmlDoc.CreateElement("total");

            playerTotalNode.InnerText = total;
            playerNode.AppendChild(playerTotalNode);

            return(playerNode);
        }