public string GetRandomClip(List <StrIntPair> clips) { if (clips == null || clips.Count == 0) { return(null); } int num = 0; int count = clips.Count; for (int i = 0; i < count; i++) { num += clips[i].IntVal; } if (clips == null) { return(null); } int num2 = Service.Rand.ViewRangeInt(0, num); string result = string.Empty; for (int j = 0; j < count; j++) { StrIntPair strIntPair = clips[j]; int intVal = strIntPair.IntVal; if (num2 < intVal) { result = strIntPair.StrKey; break; } num2 -= intVal; } return(result); }
private Dictionary <string, int> GetData(Row row, int columnIndex) { ValueObjectController valueObjectController = Service.Get <ValueObjectController>(); List <StrIntPair> strIntPairs = valueObjectController.GetStrIntPairs(this.Uid, row.TryGetString(columnIndex)); if (strIntPairs == null) { return(null); } Dictionary <string, int> dictionary = new Dictionary <string, int>(); int i = 0; int count = strIntPairs.Count; while (i < count) { StrIntPair strIntPair = strIntPairs[i]; dictionary.Add(strIntPair.StrKey, strIntPair.IntVal); i++; } return(dictionary); }
public void ReadRow(Row row) { this.Uid = row.Uid; this.SoundName = row.TryGetString(NotificationTypeVO.COLUMN_soundName); if (this.SoundName.Equals("")) { this.SoundName = null; } this.Desc = row.TryGetString(NotificationTypeVO.COLUMN_desc); this.MinCompletionTime = row.TryGetInt(NotificationTypeVO.COLUMN_minCompletionTime); this.RepeatTime = row.TryGetInt(NotificationTypeVO.COLUMN_repeatTime); ValueObjectController valueObjectController = Service.Get <ValueObjectController>(); List <StrIntPair> strIntPairs = valueObjectController.GetStrIntPairs(this.Uid, row.TryGetString(NotificationTypeVO.COLUMN_validTimeRange)); int earliestValidTime = 10; int latestValidTime = 21; if (strIntPairs != null) { int i = 0; int count = strIntPairs.Count; while (i < count) { StrIntPair strIntPair = strIntPairs[i]; string strKey = strIntPair.StrKey; if (strKey == "earliest") { earliestValidTime = strIntPair.IntVal; } else if (strKey == "latest") { latestValidTime = strIntPair.IntVal; } i++; } } this.EarliestValidTime = earliestValidTime; this.LatestValidTime = latestValidTime; }
private void AddError(ref List <StrIntPair> errors, string error) { if (errors == null) { errors = new List <StrIntPair>(); } else { int i = 0; int count = errors.Count; while (i < count) { StrIntPair strIntPair = errors[i]; if (strIntPair.StrKey == error) { strIntPair.IntVal++; return; } i++; } } errors.Add(new StrIntPair(error, 1)); }
public void ReadRow(Row row) { this.Uid = row.Uid; this.MissionType = StringUtils.ParseEnum <MissionType>(row.TryGetString(CampaignMissionVO.COLUMN_missionType)); this.Waves = row.TryGetString(CampaignMissionVO.COLUMN_waves); this.Map = row.TryGetString(CampaignMissionVO.COLUMN_map); this.CampaignUid = row.TryGetString(CampaignMissionVO.COLUMN_campaignUid); this.Title = row.TryGetString(CampaignMissionVO.COLUMN_title); this.UnlockOrder = row.TryGetInt(CampaignMissionVO.COLUMN_unlockOrder); this.Description = row.TryGetString(CampaignMissionVO.COLUMN_description); this.Rewards = row.TryGetString(CampaignMissionVO.COLUMN_rewards); this.MasteryStars = 3; this.IntroStory = row.TryGetString(CampaignMissionVO.COLUMN_introStory); this.SuccessStory = row.TryGetString(CampaignMissionVO.COLUMN_winStory); this.FailureStory = row.TryGetString(CampaignMissionVO.COLUMN_loseStory); this.GoalFailureStory = row.TryGetString(CampaignMissionVO.COLUMN_goalFailStory); this.OpponentName = row.TryGetString(CampaignMissionVO.COLUMN_opponentName); this.GoalString = row.TryGetString(CampaignMissionVO.COLUMN_goalString); this.GoalFailureString = row.TryGetString(CampaignMissionVO.COLUMN_goalFailString); this.ProgressString = row.TryGetString(CampaignMissionVO.COLUMN_progressString); this.Replayable = row.TryGetBool(CampaignMissionVO.COLUMN_replay); this.Grind = row.TryGetBool(CampaignMissionVO.COLUMN_grind); this.BattleMusic = row.TryGetString(CampaignMissionVO.COLUMN_battleMusic); this.AmbientMusic = row.TryGetString(CampaignMissionVO.COLUMN_ambientMusic); this.CampaignPoints = this.ParseCampaignPoints(row.TryGetString(CampaignMissionVO.COLUMN_campaignPoints)); this.FixedWaves = row.TryGetBool(CampaignMissionVO.COLUMN_fixedWaves); this.RaidDescriptionID = row.TryGetString(CampaignMissionVO.COLUMN_raidDesc); this.RaidBriefingBGTextureName = row.TryGetString(CampaignMissionVO.COLUMN_raidImage); this.TotalLoot = null; ValueObjectController valueObjectController = Service.ValueObjectController; List <StrIntPair> strIntPairs = valueObjectController.GetStrIntPairs(this.Uid, row.TryGetString(CampaignMissionVO.COLUMN_totalLoot)); if (strIntPairs != null) { int num = 6; this.TotalLoot = new int[num]; for (int i = 0; i < num; i++) { this.TotalLoot[i] = -1; } int j = 0; int count = strIntPairs.Count; while (j < count) { StrIntPair strIntPair = strIntPairs[j]; this.TotalLoot[(int)StringUtils.ParseEnum <CurrencyType>(strIntPair.StrKey)] = strIntPair.IntVal; j++; } } StaticDataController staticDataController = Service.StaticDataController; this.Conditions = new List <ConditionVO>(); string[] array = row.TryGetStringArray(CampaignMissionVO.COLUMN_victoryConditions); for (int k = 0; k < array.Length; k++) { this.Conditions.Add(staticDataController.Get <ConditionVO>(array[k])); } if (!string.IsNullOrEmpty(this.CampaignUid)) { CampaignVO optional = staticDataController.GetOptional <CampaignVO>(this.CampaignUid); if (optional != null) { optional.TotalMissions++; optional.TotalMasteryStars += this.MasteryStars; } else { Service.Logger.ErrorFormat("CampaignMissionVO {0} that references a CampaignVO Uid {1} that doesn't exist", new object[] { this.Uid, this.CampaignUid }); } } this.FailureCondition = row.TryGetString(CampaignMissionVO.COLUMN_failureCondition); this.BIChapterId = row.TryGetString(CampaignMissionVO.COLUMN_bi_chap_id); this.BIContext = row.TryGetString(CampaignMissionVO.COLUMN_bi_context); this.BIEnemyTier = row.TryGetInt(CampaignMissionVO.COLUMN_bi_enemy_tier); this.BIMissionId = row.TryGetString(CampaignMissionVO.COLUMN_bi_mission_id); this.BIMissionName = row.TryGetString(CampaignMissionVO.COLUMN_bi_mission_name); }
private List <StrIntPair> ParseBlob(string uid, string blob) { List <StrIntPair> result = null; List <StrIntPair> list = null; StrIntState strIntState = StrIntState.StrStart; int num = -1; string strKey = null; int i = 0; int length = blob.Length; while (i < length) { char c = blob[i]; bool flag = c == '"'; switch (strIntState) { case StrIntState.StrStart: if (flag) { num = i + 1; strIntState++; } else if (c != ',' && !char.IsWhiteSpace(c)) { this.AddError(ref list, "Missing initial quote"); num = i; strIntState++; } break; case StrIntState.StrEnd: if (flag) { if (i == num) { this.AddError(ref list, "Empty string inside"); } strKey = blob.Substring(num, i - num); num = -1; strIntState++; } else if (c == ':') { this.AddError(ref list, "Missing final quote"); strKey = blob.Substring(num, i - num); num = -1; strIntState++; } break; case StrIntState.IntStart: if (char.IsDigit(c) || (num == -1 && c == '-')) { num = i; strIntState++; } else if (c != ':' && !char.IsWhiteSpace(c)) { this.AddError(ref list, "Unsupported delimiter"); } break; case StrIntState.IntEnd: if (!char.IsDigit(c)) { string s = blob.Substring(num, i - num); this.AddPair(ref result, strKey, int.Parse(s)); num = -1; strIntState = StrIntState.StrStart; if (flag) { if (i == length - 1) { this.AddError(ref list, "Extra quote"); } else { this.AddError(ref list, "Missing comma"); num = i + 1; strIntState++; } } } break; } i++; } if (strIntState != StrIntState.StrStart) { if (strIntState != StrIntState.IntEnd) { this.AddError(ref list, "String-int mismatch"); } else { string s2 = blob.Substring(num); this.AddPair(ref result, strKey, int.Parse(s2)); } } if (list != null) { string text = string.Format("Formatting errors in {0} '{1}'", uid, blob); int j = 0; int count = list.Count; while (j < count) { StrIntPair strIntPair = list[j]; text += string.Format("; {0} ({1})", strIntPair.StrKey, strIntPair.IntVal); j++; } Service.Logger.Warn(text); } return(result); }