Esempio n. 1
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);
        }
Esempio n. 2
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);
        }