public void LoadVotesFromDatabase(List <DatabaseEntry> votesData)
 {
     for (int index = 0; index < votesData.Count; ++index)
     {
         DatabaseEntry databaseEntry = votesData[index];
         PoliticalVote inVote        = new PoliticalVote();
         if (Enum.IsDefined(typeof(CarPart.PartType), (object)databaseEntry.GetStringValue("Object Type")))
         {
             inVote.currentPartType = (CarPart.PartType)Enum.Parse(typeof(CarPart.PartType), databaseEntry.GetStringValue("Object Type"));
         }
         inVote.displayRule        = databaseEntry.GetBoolValue("Display Rule");
         inVote.group              = databaseEntry.GetStringValue("Rule Group");
         inVote.nameID             = databaseEntry.GetStringValue("Rule Name ID");
         inVote.descriptionID      = databaseEntry.GetStringValue("Rule Description ID");
         inVote.ID                 = databaseEntry.GetIntValue("ID");
         inVote.lockedToPlayerVote = databaseEntry.GetBoolValue("Locked To Player Vote");
         inVote.effectType         = databaseEntry.GetStringValue("Effect Type");
         inVote.impacts            = VotesManager.GetImpacts(inVote.effectType, inVote);
         inVote.messageCriteria    = VotesManager.GetMessageCriteria(databaseEntry.GetStringValue("Message Trigger"));
         string stringValue1 = databaseEntry.GetStringValue("Benefits");
         char[] chArray1     = new char[1] {
             ';'
         };
         foreach (string str1 in stringValue1.Split(chArray1))
         {
             string str2 = str1.Trim();
             if (!Enum.IsDefined(typeof(PoliticalVote.TeamCharacteristics), (object)str2))
             {
                 Console.WriteLine(34.ToString() + str2 + (object)'"' + " does not exist in the teamCharacteristicsEnum");
             }
             else
             {
                 inVote.benificialCharacteristics.Add((PoliticalVote.TeamCharacteristics)Enum.Parse(typeof(PoliticalVote.TeamCharacteristics), str2));
             }
         }
         string stringValue2 = databaseEntry.GetStringValue("Challenges");
         char[] chArray2     = new char[1] {
             ';'
         };
         foreach (string str1 in stringValue2.Split(chArray2))
         {
             string str2 = str1.Trim();
             if (!Enum.IsDefined(typeof(PoliticalVote.TeamCharacteristics), (object)str2))
             {
                 Console.WriteLine(34.ToString() + str2 + (object)'"' + " does not exist in the teamCharacteristicsEnum");
             }
             else
             {
                 inVote.detrimentalCharacteristics.Add((PoliticalVote.TeamCharacteristics)Enum.Parse(typeof(PoliticalVote.TeamCharacteristics), str2));
             }
         }
         if (this.votes.ContainsKey(inVote.ID))
         {
             Console.WriteLine("Rule Changes database contains rules with duplicate IDs: {0}", (object)inVote.ID);
         }
         this.votes.Add(inVote.ID, inVote);
         this.voteIDs.Add(inVote.ID);
     }
     Console.WriteLine("RulesLoaded");
 }
 private void addButton_Click(object sender, RoutedEventArgs e)
 {
     if (ruleList.SelectedItems.Count == 1)
     {
         ChosenRule = ruleList.SelectedItem as PoliticalVote;
         Close();
     }
 }
 public bool CanVoteBeUsed(PoliticalVote inVote, List <PoliticalVote> inList)
 {
     for (int index = 0; index < inList.Count; ++index)
     {
         if (inList[index].group == inVote.group)
         {
             return(false);
         }
     }
     return(true);
 }
Exemple #4
0
 public PoliticalVote GetVoteForGroup(string inGroup)
 {
     for (int index = 0; index < this.mRules.Count; ++index)
     {
         PoliticalVote mRule = this.mRules[index];
         if (mRule.group == inGroup)
         {
             return(mRule);
         }
     }
     return((PoliticalVote)null);
 }
Exemple #5
0
 public void RemoveRule(PoliticalVote inRule)
 {
     for (int index = 0; index < this.mRules.Count; ++index)
     {
         PoliticalVote mRule = this.mRules[index];
         if (mRule.ID == inRule.ID)
         {
             this.mRules.Remove(mRule);
             --index;
         }
     }
 }
    public bool HasVote(PoliticalVote inVote)
    {
        int count = this.mChampionship.Rules.ActiveRules.Count;

        for (int index = 0; index < count; ++index)
        {
            if (this.mChampionship.Rules.ActiveRules[index].ID == inVote.ID)
            {
                return(true);
            }
        }
        return(false);
    }
Exemple #7
0
 public void AddRule(PoliticalVote inRule)
 {
     for (int index = 0; index < this.mRules.Count; ++index)
     {
         PoliticalVote mRule = this.mRules[index];
         if (mRule.group == inRule.group)
         {
             this.mRules.Remove(mRule);
             --index;
         }
     }
     this.mRules.Add(inRule);
 }
    public static List <PoliticalImpact> GetImpacts(string inString, PoliticalVote inVote)
    {
        List <PoliticalImpact> politicalImpactList = new List <PoliticalImpact>();
        string str1 = inString;

        char[] chArray = new char[1] {
            ';'
        };
        foreach (string str2 in str1.Split(chArray))
        {
            string str3     = str2.Trim();
            string inName   = string.Empty;
            string inEffect = string.Empty;
            bool   flag     = false;
            for (int index = 0; index < str3.Length; ++index)
            {
                if (!flag)
                {
                    if ((int)str3[index] != 40)
                    {
                        inName = inName.Insert(inName.Length, str3[index].ToString());
                    }
                    else if ((int)str3[index] == 40)
                    {
                        flag = true;
                    }
                }
                else if ((int)str3[index] != 40 && (int)str3[index] != 41)
                {
                    inEffect = inEffect.Insert(inEffect.Length, str3[index].ToString());
                }
            }
            PoliticalImpact impact = VotesManager.CreateImpact(inName, inEffect, inVote);
            if (impact != null)
            {
                politicalImpactList.Add(impact);
            }
        }
        return(politicalImpactList);
    }
Exemple #9
0
 public void ValidateChampionshipRules()
 {
     string[] strArray = new string[6]
     {
         "PromotionBonus",
         "LastPlaceBonus",
         "EnergyRecoverySystem",
         "HybridPower",
         "ChargeBasedOnStandings",
         "Sprinklers"
     };
     int[] numArray = new int[6] {
         81, 75, 76, 80, 95, 72
     };
     for (int index = 0; index < strArray.Length; ++index)
     {
         if (this.GetVoteForGroup(strArray[index]) == null)
         {
             int key = numArray[index];
             if (!VotesManager.Instance.votes.ContainsKey(key))
             {
                 Console.WriteLine("Championship {0} references invalid rule {1}; ignoring rule", new object[2]
                 {
                     (object)this.mChampionship.championshipID,
                     (object)key
                 });
             }
             else
             {
                 PoliticalVote inRule = VotesManager.Instance.votes[key];//.Clone();
                 inRule.Initialize(this.mChampionship);
                 this.AddRule(inRule);
             }
         }
     }
 }
    private static PoliticalImpact CreateImpact(string inName, string inEffect, PoliticalVote inVote)
    {
        inEffect = inEffect.Trim();
        inName   = inName.Trim();
        string text = inName;

        switch (text)
        {
        case "Points":
        case "FinalRacePointsDoubled":
        case "FastestLapBonus":
        case "PoleBonus":
            return(new PoliticalImpactPoints(inName, inEffect));

        case "TyreSpeed":
        case "TyreSupplierSpeedBonus":
        case "TyreWearRate":
        case "TyreSupplier":
        case "TyreType":
        case "TyresAvailable":
        case "TyreCompoundChoice":
        case "TyreCompoundsAvailable":
            return(new PoliticalImpactTyreSettings(inName, inEffect));

        case "PitlaneSpeed":
            return(new PoliticalImpactPitlaneSpeed(inName, inEffect));

        case "EnergySystem":
            return(new PoliticalImpactEnergyRecoverySystem(inName, inEffect));

        case "FuelLimit":
        case "Refuelling":
            return(new PoliticalImpactFuelSettings(inName, inEffect));

        case "ChangeTrackLayout":
        case "ReplaceTrack":
        case "AddTrack":
        case "RemoveTrack":
        case "AddLayout":
            return(new PoliticalImpactChangeTrack(inName, inEffect));

        case "Practice":
        case "Qualifying":
        case "Race":
            return(new PoliticalImpactSessionLength(inName, inEffect));

        case "PrizePoolCashGap":
            return(new PoliticalImpactPrizePoolAdjustement(inName, inEffect));

        case "SafetyCar":
            return(new PoliticalImpactSafetyCar(inName, inEffect));

        case "SpecPart":
            return(new PoliticalImpactSpecPart(inName, inEffect));

        case "Grid":
            return(new PoliticalImpactGridSettings(inName, inEffect));

        case "PitStopCrew":
            return(new PoliticalImpactPitStopCrew(inName, inEffect));

        case "Sprinkler":
            return(new PoliticalImpactSprinklers(inName, inEffect));

        case "LastPlaceBonus":
            return(new PoliticalImpactLastPlaceBonus(inName, inEffect));

        case "PromotionBonus":
            return(new PoliticalImpactPromotionBonus(inName, inEffect));
        }
        return(null);
    }