示例#1
0
        public virtual void  initTeam()
        {
            this._injuries      = 0;
            this._substitutions = 0;
            for (int i = 0; i < _team.Length; i++)
            {
                ((ESMSPlayer)_team[i]).Status = ESMSPlayer.PLAYING;
            }
            for (int i = 0; i < _subs.Length; i++)
            {
                ((ESMSPlayer)_subs[i]).Status = ESMSPlayer.SUBSTITUTION;
            }

            this._score          = 0;
            this._finalShots_On  = 0;
            this._finalShots_Off = 0;
            this._finalFouls     = 0;
            this._team_tackling  = 0;
            this._team_passing   = 0;
            this._team_shooting  = 0;

            for (int i = 1; i <= this.NumPlayers; i++)
            {
                ESMSPlayer temp = (ESMSPlayer)this.getPlayer(i);
                temp.initPlayer();
            }
        }
示例#2
0
        public virtual void  calcTeamContributions(int player)
        {
            ESMSPlayer p = ((ESMSPlayer)getPlayer(player));

            if (p.Status == ESMSPlayer.PLAYING)
            {
                this._team_tackling += p.tacklingContrib;
                this._team_shooting += p.shootingContrib;
                this._team_passing  += p.passingContrib;
            }
        }
示例#3
0
        public virtual void  calcAggression()
        {
            this._aggression = 0;

            for (int i = 1; i <= this.NumPlayers; i++)
            {
                ESMSPlayer player = (ESMSPlayer)getPlayer(i);
                if (player.Status == ESMSPlayer.PLAYING)
                {
                    this._aggression += player.getAggression();
                }
                // Alesk comment about aggressivity
                //if (player.getStatus()!=ESMSPlayer.PLAYING)
                //    player.setAggression(0);
                //this.aggression += player.getAggression();
            }
        }
示例#4
0
        public virtual void  calcPlayerContributions(int player, ESMSTeam opponent)
        {
            if (!getPosition(player).Equals("GK") && ((ESMSPlayer)getPlayer(player)).Status == ESMSPlayer.PLAYING)
            {
                double tkMult = Tactic.getMult(opponent.Tactic.Name, getPosition(player), "TK");
                double psMult = Tactic.getMult(opponent.Tactic.Name, getPosition(player), "PS");
                double shMult = Tactic.getMult(opponent.Tactic.Name, getPosition(player), "SH");

                ESMSPlayer temp = ((ESMSPlayer)getPlayer(player));
                temp.tacklingContrib = tkMult * temp.Tackling * temp.fatigue;
                temp.passingContrib  = psMult * temp.Passing * temp.fatigue;
                temp.shootingContrib = shMult * temp.Shooting * temp.fatigue;
            }
            else
            {
                ESMSPlayer temp = ((ESMSPlayer)getPlayer(player));
                temp.tacklingContrib = 0;
                temp.passingContrib  = 0;
                temp.shootingContrib = 0;
            }
        }
示例#5
0
        public virtual void  updateStats(ESMSTeam team)
        {
            this._team_tackling = 0;
            this._team_passing  = 0;
            this._team_shooting = 0;

            this.calcAggression();
            for (int player = 2; player < NumPlayers; player++)
            {
                calcPlayerContributions(player, team);
                calcTeamContributions(player);
            }
            for (int player = 2; player < NumPlayers; player++)
            {
                ESMSPlayer temp = ((ESMSPlayer)getPlayer(player));
                if (temp.Status == ESMSPlayer.PLAYING)
                {
                    temp.fatigue *= 0.996;
                    /*Dovrei tagliare il float a 2 cifre decimali ma non ho idea del perche'*/
                }
            }
        }
示例#6
0
        public ESMSTeam(string fileName) : base(fileName)
        {
            try
            {
                _players = new ESMSPlayer[11 + Config.getConfig().NumSubs];

                /*Convert Actions and Conditions to ESMS counterparts*/
                // Rebuild the teamsheet to store ESMSPlayers instead of normal Players.
                for (int i = 0; i < _team.Length; i++)
                {
                    _team[i] = new ESMSPlayer(_team[i]);
                    if (_penaltyKicker.Name.Equals(_team[i].Name))
                    {
                        _penaltyKicker = _team[i];
                    }
                    ((ESMSPlayer)_team[i]).Status = ESMSPlayer.PLAYING;
                }

                for (int i = 0; i < _subs.Length; i++)
                {
                    _subs[i] = new ESMSPlayer(_subs[i]);
                    ((ESMSPlayer)_team[i]).Status = ESMSPlayer.SUBSTITUTION;
                }

                /* Find the penaltykicker */

                Conditional[] cond = Conditionals;
                /*Rebuild Conditional*/
                for (int i = 0; i < cond.Length; i++)
                {
                    _vCond[i] = parseConditional(cond[i]);
                }
            }
            catch (System.Exception err)
            {
                System.Console.Out.WriteLine("Exception raised while trying to read the number of subs from Configuration object");
                SupportClass.WriteStackTrace(err, Console.Error);
            }
        }
示例#7
0
        public virtual void  calcAbility(int score, int oppScore)
        {
            //Add simple bonuses
            for (int i = 1; i <= NumPlayers; i++)
            {
                ESMSPlayer p = ((ESMSPlayer)getPlayer(i));
                p.esmsShootingAbility += Config.getConfig().AbGoal *p.getGoals();
                p.esmsPassingAbility  += Config.getConfig().AbAssist *p.getAssists();
                p.esmsTacklingAbility += Config.getConfig().AbKeyTackling *p.getTackles();
                p.esmsPassingAbility  += Config.getConfig().AbKeyPasses *p.getKeyPasses();
                p.esmsShootingAbility += Config.getConfig().AbShotsOn *p.ShotsOn;
                p.esmsShootingAbility += Config.getConfig().AbShotsOff *p.ShotsOff;
                p.esmsKeepingAbility  += Config.getConfig().AbSaves *p.getSaves();
                p.esmsKeepingAbility  += Config.getConfig().AbConceded *p.Conceded;

                if (getPosition(i).Equals("GK"))
                {
                    p.esmsKeepingAbility += Config.getConfig().AbYellow *p.YellowCards;
                    p.esmsKeepingAbility += Config.getConfig().AbRed *p.RedCard;
                }
                else
                {
                    p.esmsShootingAbility += Config.getConfig().AbYellow *p.YellowCards;
                    p.esmsShootingAbility += Config.getConfig().AbRed *p.RedCard;
                    p.esmsTacklingAbility += Config.getConfig().AbYellow *p.YellowCards;
                    p.esmsTacklingAbility += Config.getConfig().AbRed *p.RedCard;
                    p.esmsPassingAbility  += Config.getConfig().AbYellow *p.YellowCards;
                    p.esmsPassingAbility  += Config.getConfig().AbRed *p.RedCard;
                }
            }
            //Add Random Victory Bonuses
            if (score > oppScore)
            {
                int        num = 0, n = 0;
                ESMSPlayer p;

                /* Only two player get the ability increase (this explains why
                 *              using a single num variable) */
                for (int k = 1; k <= 2; k++)
                {
                    do
                    {
                        n = CSEsMS.ESMS.ESMS.Random.Next(NumPlayers) + 1;
                        p = ((ESMSPlayer)getPlayer(n));
                    }while (p.Minutes == 0 || n == num);
                    if (getPosition(n).Equals("GK"))
                    {
                        p.esmsKeepingAbility += Config.getConfig().AbVictoryRandom;
                    }
                    else
                    {
                        p.esmsShootingAbility += Config.getConfig().AbVictoryRandom;
                        p.esmsTacklingAbility += Config.getConfig().AbVictoryRandom;
                        p.esmsPassingAbility  += Config.getConfig().AbVictoryRandom;
                    }

                    num = n;
                }
            }
            //Add Random Defeat Maluses
            else if (score < oppScore)
            {
                int        num = 0, n = 0;
                ESMSPlayer p;

                /* Only two player get the ability decrease (this explains why
                 *              using a single num variable) */
                for (int k = 1; k <= 2; k++)
                {
                    do
                    {
                        n = CSEsMS.ESMS.ESMS.Random.Next(NumPlayers) + 1;
                        p = ((ESMSPlayer)getPlayer(n));
                    }while (p.Minutes == 0 || n == num);
                    if (getPosition(n).Equals("GK"))
                    {
                        p.esmsKeepingAbility += Config.getConfig().AbDefeatRandom;
                    }
                    else
                    {
                        p.esmsShootingAbility += Config.getConfig().AbDefeatRandom;
                        p.esmsTacklingAbility += Config.getConfig().AbDefeatRandom;
                        p.esmsPassingAbility  += Config.getConfig().AbDefeatRandom;
                    }

                    num = n;
                }
            }
            //Add Clean Sheet Bonuses (if oppScore==0)
            if (oppScore == 0)
            {
                //int n = 0;
                for (int i = 1; i <= NumPlayers; i++)
                {
                    ESMSPlayer p = ((ESMSPlayer)getPlayer(i));
                    if (getPosition(i).Equals("GK") && p.Minutes > 46)
                    {
                        p.esmsKeepingAbility += Config.getConfig().AbCleanSheet;
                    }

                    /* It shouldn't be better to keep the condition of >46
                     *              also for defenders? */
                    else if (getPosition(i).Equals("DF") && p.Minutes > 0)
                    {
                        p.esmsTacklingAbility += Config.getConfig().AbCleanSheet;
                    }
                }
            }
        }
示例#8
0
 /// <summary>Method used to clear counter of yellowCarded, redCarded and injured players. </summary>
 public virtual void  clean()
 {
     this._yellowCarded = null;
     this._redCarded    = null;
     this._injured      = null;
 }
示例#9
0
 public virtual void  clearCards()
 {
     _redCarded    = null;
     _yellowCarded = null;
 }