public void new_chapter(List <string> previous_chapters, string chapter_id, Dictionary <string, string> previous_chapter_ids) { Previous_Chapters.Clear(); Previous_Chapters.AddRange(previous_chapters); Chapter_Id = chapter_id; PreviousChapterIds = previous_chapter_ids; Chapter_Turn = 0; Chapter_Exp_Gain = 0; Chapter_Damage_Taken = 0; Chapter_Deaths = 0; Chapter_Completion = 0; Chapter_Play_Time = 0; Chapter_Start_Time = DateTime.UtcNow; GameplayStartTime = Chapter_Start_Time; Deployed_Unit_Count = -1; Deployed_Unit_Avg_Level = -1; if (Global.save_file == null) { Rankings = new PastRankings(); } else { Rankings = Global.save_file.past_rankings(chapter_id, previous_chapter_ids); } }
public void CopyTo(PastRankings target) { foreach (var pair in Data) { target.SetRanking(pair.Key, pair.Value); } }
public static PastRankings read(BinaryReader reader, Difficulty_Modes difficulty) { PastRankings result = new PastRankings(); result.Data.read(reader); // If this save predates storing difficulty in the ranking object if (Global.LOADED_VERSION.older_than(0, 6, 1, 1)) { foreach (var key in result.Data.Keys.ToList()) { result.Data[key] = new Game_Ranking(result.Data[key], difficulty); } } return(result); }
public void reset() { Instant_Move = false; Selected_Unit_Id = -1; //Rng = new List<int>(); reset_rng(); Preset_Rng = new List <int>(); Saved_Rns = new List <int>(); Saving_Rns = false; Preparations = false; Home_Base = false; Menu_Canto = Canto_Records.None; Battler_1_Id = -1; Battler_2_Id = -1; Aoe_Targets = new List <int>(); Staff_User_Id = -1; Staff_Target_Id = -1; Staff_Target_Loc = new Vector2(-1, -1); Rescuer_Id = -1; Rescuee_Id = -1; Item_User = -1; Item_Used = -1; Item_Inventory_Target = -1; ItemPromotionId = -1; ItemTargetLoc = new Vector2(-1, -1); Visitor_Id = -1; Visit_Loc = new Vector2(-1, -1); Shopper_Id = -1; Shop_Loc = new Vector2(-1, -1); SecretShop = false; In_Arena = false; Wager = -1; Arena_Distance = -1; Arena_Round = -1; Arena_Retreat = false; Stolen_Item = -1; Discarder_Id = -1; SupportGainId = -1; SupportGainTargets = new List <int>(); Battle_Mode = Constants.Animation_Modes.Map; Status_Page = 0; Unit_Page = 0; Unit_Sort = 0; Unit_Sort_Up = true; DataPage = 0; Supply_Item_Type = 0; Objective_Text = ""; Victory_Text = ""; Loss_Text = ""; Objective_Mode = new int[] { 0, 0 }; Loss_On_Death = new HashSet <int>(); Ally_Loss_On_Death = new List <int>(); Difficulty_Mode = Difficulty_Modes.Normal; Style = Global.save_file == null ? Mode_Styles.Standard : Global.save_file.Style; Previous_Chapters = new List <string>(); Rankings = new PastRankings(); Total_Play_Time = 0; Chapter_Save_Progression_Keys = new string[0]; Victory = false; Failure = false; clear_events(); }
public void read(BinaryReader reader, Version loadedVersion) { Instant_Move = reader.ReadBoolean(); Character_Anim_Count = reader.ReadInt32(); Selected_Unit_Id = reader.ReadInt32(); if (loadedVersion.older_than(0, 4, 3, 2)) { List <int> rand = new List <int>(); rand.read(reader); reset_rng(); } else { Rand = Rng.read(reader, loadedVersion); } //reset_rng(); //Debug Preset_Rng.read(reader); Preparations = reader.ReadBoolean(); if (!loadedVersion.older_than(0, 4, 3, 6)) { Home_Base = reader.ReadBoolean(); } Menu_Canto = (Canto_Records)reader.ReadInt32(); Battler_1_Id = reader.ReadInt32(); Battler_2_Id = reader.ReadInt32(); Aoe_Targets.read(reader); Staff_User_Id = reader.ReadInt32(); Staff_Target_Id = reader.ReadInt32(); Staff_Target_Loc = Staff_Target_Loc.read(reader); Rescuer_Id = reader.ReadInt32(); Rescuee_Id = reader.ReadInt32(); Item_User = reader.ReadInt32(); Item_Used = reader.ReadInt32(); if (!loadedVersion.older_than(0, 4, 6, 1)) { Item_Inventory_Target = reader.ReadInt32(); } if (!loadedVersion.older_than(0, 6, 6, 0)) { ItemPromotionId = reader.ReadInt32(); } if (!loadedVersion.older_than(0, 6, 4, 1)) { ItemTargetLoc = ItemTargetLoc.read(reader); } Shopper_Id = reader.ReadInt32(); Shop_Loc = Shop_Loc.read(reader); if (!loadedVersion.older_than(0, 5, 0, 5)) { SecretShop = reader.ReadBoolean(); } In_Arena = reader.ReadBoolean(); Wager = reader.ReadInt32(); Arena_Distance = reader.ReadInt32(); Arena_Round = reader.ReadInt32(); Stolen_Item = reader.ReadInt32(); Dance_Item = reader.ReadInt32(); Discarder_Id = reader.ReadInt32(); if (!loadedVersion.older_than(0, 5, 5, 4)) { SupportGainId = reader.ReadInt32(); SupportGainTargets.read(reader); } Battle_Mode = (Constants.Animation_Modes)reader.ReadInt32(); Objective_Text = reader.ReadString(); Victory_Text = reader.ReadString(); Loss_Text = reader.ReadString(); Objective_Mode = Objective_Mode.read(reader); Loss_On_Death.read(reader); Ally_Loss_On_Death.read(reader); if (loadedVersion.older_than(0, 4, 2, 0)) { Difficulty_Mode = reader.ReadBoolean() ? Difficulty_Modes.Hard: Difficulty_Modes.Normal; } else { Difficulty_Mode = (Difficulty_Modes)reader.ReadInt32(); } Style = (Mode_Styles)reader.ReadInt32(); if (!loadedVersion.older_than(0, 4, 0, 4)) { Previous_Chapters.read(reader); } if (!loadedVersion.older_than(0, 4, 4, 0)) { Chapter_Id = reader.ReadString(); if (!loadedVersion.older_than(0, 5, 6, 3)) { PreviousChapterIds.read(reader); } else { PreviousChapterIds.Clear(); string previous_chapter = reader.ReadString(); if (!string.IsNullOrEmpty(previous_chapter)) { if (!Global.data_chapters.ContainsKey(Chapter_Id)) { throw new KeyNotFoundException(string.Format("Problem loading save, cannot find chapter {0}", Chapter_Id)); } else if (!Global.data_chapters.ContainsKey(previous_chapter)) { throw new KeyNotFoundException(string.Format("Problem loading save, cannot find chapter {0}", previous_chapter)); } else { string progression_id; if (!Global.data_chapters[Chapter_Id].Prior_Chapters .Intersect(Global.data_chapters[previous_chapter].Progression_Ids) .Any()) { #if DEBUG //throw new KeyNotFoundException(string.Format( // "Chapter {0}'s prior chapters do not match chapter {1}'s progression ids", // Chapter_Id, previous_chapter)); #endif // Incorrect but eh @Debug progression_id = Global.data_chapters[Chapter_Id].Prior_Chapters.First(); } else { progression_id = Global.data_chapters[Chapter_Id].Prior_Chapters .Intersect(Global.data_chapters[previous_chapter].Progression_Ids) .First(); } PreviousChapterIds.Add(progression_id, previous_chapter); } } } } if (!loadedVersion.older_than(0, 6, 7, 0)) { Rankings = PastRankings.read(reader, Difficulty_Mode); } else { Rankings = new PastRankings(); } Total_Play_Time = reader.ReadInt32(); Chapter_Play_Time = reader.ReadInt32(); if (!loadedVersion.older_than(0, 4, 6, 3)) { Chapter_Start_Time = DateTime.FromBinary(reader.ReadInt64()); if (!loadedVersion.older_than(0, 6, 3, 1)) { GameplayStartTime = DateTime.FromBinary(reader.ReadInt64()); } else { GameplayStartTime = Chapter_Start_Time; } Deployed_Unit_Count = reader.ReadInt32(); Deployed_Unit_Avg_Level = reader.ReadInt32(); } Chapter_Turn = reader.ReadInt32(); Chapter_Exp_Gain = reader.ReadInt32(); Chapter_Damage_Taken = reader.ReadInt32(); Chapter_Deaths = reader.ReadInt32(); Chapter_Completion = reader.ReadInt32(); if (!loadedVersion.older_than(0, 4, 4, 3)) { Home_Base_Background = reader.ReadString(); } SWITCHES = Event_Variable_Data <bool> .read(reader, Config.EVENT_DATA_LENGTH); VARIABLES = Event_Variable_Data <int> .read(reader, Config.EVENT_DATA_LENGTH); //Event_Processor.read_data(reader); //Debug }
public PastRankings(PastRankings source) { Data = source.Data.ToDictionary(p => p.Key, p => new Game_Ranking(p.Value)); }