コード例 #1
0
        public void Cycle()
        {
            if (TimeLeft == 90)
            {
                StartTheMatch();
            }

            var attacker = GetAttackingPlayer();
            var defender = GetDefendingPlayer();

            double shoot   = attacker.Shoot() / defender.PositionLevel;
            double defend  = defender.Defend();
            double dribble = attacker.Dribble() / dribbleStreak;
            double pass    = attacker.Pass();

            if (shoot >= defend)
            {
                //Score
                dribbleStreak = 1;

                CurrentAction = new MatchLog($"{attacker} scored!", TimeLeft, TeamHome.ReturnActivePlayer(), TeamGuest.ReturnActivePlayer(), HomeInPossession);
                Logs.Insert(0, CurrentAction);
                Score();
            }
            else if (dribble > defend && defender.PositionLevel != 1)
            {
                //Dribble
                dribbleStreak++; //This is to bring the chance of being a Maradona down. Player will have half chance to dribble next player and will be 8ced to pass or lose the ball.
                CurrentAction = new MatchLog($"{attacker} Dribbled {defender}!", TimeLeft, TeamHome.ReturnActivePlayer(), TeamGuest.ReturnActivePlayer(), HomeInPossession);
                Logs.Insert(0, CurrentAction);
                Dribble(defender);
            }
            else if (pass > defend && defender.PositionLevel != 1)
            {
                //Pass
                dribbleStreak = 1.5;
                string oldAttacker = attacker.ToString();
                Pass(attacker, defender);
                attacker      = GetAttackingPlayer();
                CurrentAction = new MatchLog($"{oldAttacker} passed to {attacker}!", TimeLeft, TeamHome.ReturnActivePlayer(), TeamGuest.ReturnActivePlayer(), HomeInPossession);
                Logs.Insert(0, CurrentAction);
            }
            else
            {
                //Lose the ball
                dribbleStreak = 1;
                CurrentAction = new MatchLog($"{attacker} Lost the ball to {defender}!", TimeLeft, TeamHome.ReturnActivePlayer(), TeamGuest.ReturnActivePlayer(), HomeInPossession);
                Logs.Insert(0, CurrentAction);
                TurnPossession();
            }
            TimeLeft -= Randomizer.Rnd.Next(1, 4);
            if (TimeLeft < 1)
            {
                MatchEnd();
            }
        }
コード例 #2
0
 void KickOfF(Team teamInPossession)
 {
     TeamHome.Clear();
     TeamGuest.Clear();
     teamInPossession.ReturnByPosition(6).IsInPossesion = true;
     if (teamInPossession == TeamHome)
     {
         TeamGuest.ReturnByPosition(6).IsDefending = true;
         HomeInPossession = true;
     }
     else
     {
         TeamHome.ReturnByPosition(6).IsDefending = true;
         HomeInPossession = false;
     }
     CurrentAction = new MatchLog("Kick off!", TimeLeft, TeamHome.ReturnActivePlayer(), TeamGuest.ReturnActivePlayer(), HomeInPossession);
     Logs.Insert(0, CurrentAction);
 }