Esempio n. 1
0
        private void GenerateSpecialTrainings(Team team)
        {
            foreach (SpecialTrainingDefinition def in mContext.SpecialTrainingDefinitions)
            {
                SpecialTraining tr = new SpecialTraining();

                tr.SpecialTrainingDefinitionID = def.SpecialTrainingDefinitionID;
                tr.Team = team;
                tr.IsCompleted = false;
                tr.EnergyCurrent = 0;

                mContext.SpecialTrainings.InsertOnSubmit(tr);
            }
        }
Esempio n. 2
0
        private Team GenerateTeamFromPredefinedTeamID(int predefinedTeamID)
        {
            var predefinedTeam = (from pr in mContext.PredefinedTeams
                                  where pr.PredefinedTeamID == predefinedTeamID
                                  select pr).FirstOrDefault();

            if (predefinedTeam == null)
                throw new Exception("Unknown predefinedTeamID: " + predefinedTeamID.ToString());

            Team ret = new Team();

            var predefinedSoccerPlayers = from prSP in mContext.PredefinedSoccerPlayers
                                          where prSP.PredefinedTeamID == predefinedTeamID
                                          select prSP;
            int defPos = 1;
            int medPos = 4;
            int delPos = 6;
            int subsPos = 100;

            foreach (PredefinedSoccerPlayer prSoccerPlayer in predefinedSoccerPlayers)
            {
                SoccerPlayer newSoccerPlayer = new SoccerPlayer();
                newSoccerPlayer.Team = ret;
                newSoccerPlayer.Name = prSoccerPlayer.Name;
                newSoccerPlayer.Type = prSoccerPlayer.Type;

                if (prSoccerPlayer.IsSubstitute)
                    newSoccerPlayer.FieldPosition = subsPos++;
                else
                {
                    if (prSoccerPlayer.Type == 0)
                        newSoccerPlayer.FieldPosition = 0;
                    else
                    if (prSoccerPlayer.Type == 1)
                        newSoccerPlayer.FieldPosition = defPos++;
                    else
                    if (prSoccerPlayer.Type == 2)
                        newSoccerPlayer.FieldPosition = medPos++;
                    else
                    if (prSoccerPlayer.Type == 3)
                        newSoccerPlayer.FieldPosition = delPos++;
                }

                newSoccerPlayer.Number = prSoccerPlayer.Number;

                newSoccerPlayer.Power = 0;
                newSoccerPlayer.Sliding = 0;
                newSoccerPlayer.Weight = 0;

                mContext.SoccerPlayers.InsertOnSubmit(newSoccerPlayer);
            }

            if (defPos != 4)
                Log.log(MAINSERVICE, "Fallo en la defensa, generando equipo: " + predefinedTeam.Name);
            if (medPos != 6)
                Log.log(MAINSERVICE, "Fallo en el medio, generando equipo: " + predefinedTeam.Name);
            if (delPos != 8)
                Log.log(MAINSERVICE, "Fallo en la delantera, generando equipo: " + predefinedTeam.Name);

            ret.Formation = "3-2-2";
            ret.XP = 0;
            ret.TrueSkill = 0;
            ret.Mean = DEFAULT_INITIAL_MEAN;
            ret.StandardDeviation = DEFAULT_INITIAL_STANDARD_DEVIATION;
            ret.SkillPoints = 500;
            ret.Energy = 100;
            ret.Fitness = 50;

            ret.PredefinedTeamID = predefinedTeamID;

            return ret;
        }
		private void detach_Teams(Team entity)
		{
			this.SendPropertyChanging();
			entity.PredefinedTeam = null;
		}