public void DeleteCapture(object sender) { var capture = (Capture)((Button)sender).DataContext; var thumbFile = $@"{Settings.CurrentDirectory}\{capture.Thumbnail}"; var captureFile = $@"{Settings.CurrentDirectory}\{capture.FileName}"; if (File.Exists(thumbFile)) { File.Delete(thumbFile); } if (File.Exists(captureFile)) { File.Delete(captureFile); } using var db = new AppDbContext(); db.Captures.Remove(capture); db.SaveChanges(); Captures.Remove(capture); Pagination.TotalItems -= 1; Pagination.PageSize -= 1; }
public string GetConstructorParameterList() { var deps = Dependencies.Select(x => $"{x.Name} {x.LowerCamelCase}"); var caps = Captures.Select(x => $"{x.InterfaceNameInfo.Name} {x.ParameterName}"); return(deps.Concat(caps).Join(", ")); }
public void RetreatFromBattle() { for (int i = 0; i < Controls.Count; i++) { if (Controls[i].PrisonerUnit.Character.IsMonster == false) { var heroInfo = RaidSceneManager.Raid.RaidParty.HeroInfo.Find(info => info.Hero == Controls[i].PrisonerUnit.Character as Hero); heroInfo.IsAlive = false; heroInfo.DeathRecord = new DeathRecord() { HeroClassIndex = heroInfo.Hero.ClassIndexId, HeroName = heroInfo.Hero.Name, KillerName = Controls[i].ControllUnit.Character.Name, ResolveLevel = heroInfo.Hero.Resolve.Level, Factor = DeathFactor.AttackMonster, }; Controls[i].PrisonerUnit.Formation.DeleteUnit(Controls[i].PrisonerUnit); if (RaidSceneManager.RaidPanel.SelectedUnit == Controls[i].PrisonerUnit) { if (RaidSceneManager.Formations.heroes.party.Units.Count > 0) { RaidSceneManager.Formations.heroes.party.Units[0].OverlaySlot.UnitSelected(); } } } } Controls.Clear(); for (int i = 0; i < Captures.Count; i++) { if (Captures[i].PrisonerUnit.Character.IsMonster == false) { var heroInfo = RaidSceneManager.Raid.RaidParty.HeroInfo.Find(info => info.Hero == Captures[i].PrisonerUnit.Character as Hero); heroInfo.IsAlive = false; heroInfo.DeathRecord = new DeathRecord() { HeroClassIndex = heroInfo.Hero.ClassIndexId, HeroName = heroInfo.Hero.Name, KillerName = Captures[i].CaptorUnit.Character.Name, ResolveLevel = heroInfo.Hero.Resolve.Level, Factor = DeathFactor.CaptorMonster, }; Captures[i].PrisonerUnit.Formation.DeleteUnit(Captures[i].PrisonerUnit); if (RaidSceneManager.RaidPanel.SelectedUnit == Captures[i].PrisonerUnit) { if (RaidSceneManager.Formations.heroes.party.Units.Count > 0) { RaidSceneManager.Formations.heroes.party.Units[0].OverlaySlot.UnitSelected(); } } } } Captures.Clear(); Companions.Clear(); FinishBattle(); Round.HeroAction = HeroTurnAction.Retreat; }
private void AddNew() { var newCap = new CaptureViewModel(); Captures.Add(newCap); SelectedItem = newCap; }
internal Match(ParseStep parseStep, IEnumerator <ParseStep> stepEnumerator, IEnumerable <IList <ParenCapture> > captureSet) : base(0, parseStep.InitialStateIndex, parseStep.MatchedText.Length, parseStep.MatchedText, true) { _stepEnumerator = stepEnumerator; Groups = new GroupCollection(); Groups.Append(this); Captures.Prepend(this); foreach (var parenCaptures in captureSet) { var parenCapture = parenCaptures[0]; var group = new Group(parenCapture.Number, parenCapture.Index, parenCapture.Value.Length, parenCapture.Value, parenCapture.Success); Groups.Append(group); if (parenCapture.Success) { group.Captures.Prepend(group); } if (parenCaptures.Skip(1).All(c => c.Success)) { for (int i = 1; i < parenCaptures.Count; i++) { group.Captures.Prepend(new Capture(parenCaptures[i].Index, parenCaptures[i].Value.Length, parenCaptures[i].Value)); } } } }
public IEnumerable <LexCapture> GetVitalCapture() { return(Captures.Where(c => c.Type.Advancing && !string.IsNullOrEmpty(c.Type.Name)) .Select(c => c)); }
private void AddCaptureToCaptureHistory(LexCapture matchResult) { Captures.Add(matchResult); if (Captures.Count > MaxStack) { throw new InvalidOperationException(); } }
public override async void LoadData() { base.LoadData(); foreach (var item in await App.Database.GetItemsAsync()) { Captures.Add(new CaptureViewModel(item)); } }
public string GetAccessibility() { var accessibilities = Captures.Cast <IAccessibilityClaimer>() .Append(this) .Concat(Resolvers) .Concat(CollectionResolvers) .SelectMany(x => x.Accessibilities); return(accessibilities.Any(x => x != Accessibility.Public) ? "internal" : "public"); }
void DoCapture(Actor self, Captures captures) { var oldOwner = enterActor.Owner; self.World.AddFrameEndTask(w => { // The target died or was already captured during this tick if (enterActor.IsDead || oldOwner != enterActor.Owner) { return; } // Sabotage instead of capture if (captures.Info.SabotageThreshold > 0 && !enterActor.Owner.NonCombatant) { var health = enterActor.Trait <IHealth>(); // Cast to long to avoid overflow when multiplying by the health if (100 * (long)health.HP > captures.Info.SabotageThreshold * (long)health.MaxHP) { var damage = (int)((long)health.MaxHP * captures.Info.SabotageHPRemoval / 100); enterActor.InflictDamage(self, new Damage(damage, captures.Info.SabotageDamageTypes)); if (captures.Info.ConsumedByCapture) { self.Dispose(); } return; } } // Do the capture enterActor.ChangeOwnerSync(self.Owner); foreach (var t in enterActor.TraitsImplementing <INotifyCapture>()) { t.OnCapture(enterActor, self, oldOwner, self.Owner, captures.Info.CaptureTypes); } if (self.Owner.Stances[oldOwner].HasStance(captures.Info.PlayerExperienceStances)) { var exp = self.Owner.PlayerActor.TraitOrDefault <PlayerExperience>(); if (exp != null) { exp.GiveExperience(captures.Info.PlayerExperience); } } if (captures.Info.ConsumedByCapture) { self.Dispose(); } }); }
public void UpdateFromBattleGround(BattleGround battleGround) { RoundNumber = battleGround.Round.RoundNumber; RoundStatus = battleGround.RoundStatus; TurnType = battleGround.Round.TurnType; TurnStatus = battleGround.TurnStatus; HeroAction = battleGround.Round.HeroAction; SelectedUnitId = battleGround.Round.SelectedUnit == null ? -1 : battleGround.Round.SelectedUnit.CombatInfo.CombatId; SelectedTargetId = battleGround.Round.SelectedTarget == null ? -1 : battleGround.Round.SelectedTarget.CombatInfo.CombatId; BattleStatus = battleGround.BattleStatus; SurpriseStatus = battleGround.SurpriseStatus; StallingRoundNumber = battleGround.StallingRoundNumber; OrderedUnitsCombatIds.Clear(); for (int i = 0; i < battleGround.Round.OrderedUnits.Count; i++) { OrderedUnitsCombatIds.Add(battleGround.Round.OrderedUnits[i].CombatInfo.CombatId); } CombatIds.Clear(); CombatIds.AddRange(battleGround.CombatIds); Companions.Clear(); for (int i = 0; i < battleGround.Companions.Count; i++) { Companions.Add(battleGround.Companions[i].GetHashCode()); } Captures.Clear(); RemovedUnits.Clear(); for (int i = 0; i < battleGround.Captures.Count; i++) { Captures.Add(battleGround.Captures[i].GetHashCode()); if (battleGround.Captures[i].RemoveFromParty) { var newRemovedUnitData = new FormationUnitSaveData(); newRemovedUnitData.UpdateFromUnit(battleGround.Captures[i].PrisonerUnit); RemovedUnits.Add(newRemovedUnitData); } } Controls.Clear(); for (int i = 0; i < battleGround.Controls.Count; i++) { Controls.Add(battleGround.Controls[i].GetHashCode()); } BattleLoot = battleGround.BattleLoot; LastDamaged = battleGround.LastDamaged; LastSkillUsed = battleGround.LastSkillUsed == null ? "" : battleGround.LastSkillUsed; MonsterFormation.UpdateFormation(battleGround.MonsterFormation); }
public static Captures LoadCaptures(string Path) { Captures c = new Captures(); System.IO.DirectoryInfo dir =new System.IO.DirectoryInfo(Path); foreach(System.IO.FileInfo cap in dir.GetFiles("*.png")) { Capture newCap = new Capture(cap.FullName); c.Add(newCap); } return c; }
public static Captures LoadCaptures(string Path) { Captures c = new Captures(); System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(Path); foreach (System.IO.FileInfo cap in dir.GetFiles("*.png")) { Capture newCap = new Capture(cap.FullName); c.Add(newCap); } return(c); }
private void FindBtn_Click(object sender, EventArgs e) { try { Captures.Nodes.Clear(); Captures.Visible = true; ResultText.Text = ""; ResultText.Visible = false; Status.Text = ""; Regex r = new Regex(txtFind.Text, Options); MatchCollection matches = r.Matches(Source.Text.Replace("\r\n", "\n")); foreach (Match m in matches) { TreeNode n = Captures.Nodes.Add("{" + ReplaceNewLines(m.Value) + "}"); foreach (Group g in m.Groups) { // TODO: Is there any way to get the name of the group when explicit capture is on? if (g.Captures.Count > 1) { TreeNode nn = n.Nodes.Add("..."); foreach (Capture c in g.Captures) { nn.Nodes.Add("{" + ReplaceNewLines(c.Value) + "}"); } } else if (g.Captures.Count == 1) { n.Nodes.Add(ReplaceNewLines("{" + g.Captures[0].Value) + "}"); } } } if (matches.Count == 0) { Status.Text = "No matches"; } else if (matches.Count == 1) { Status.Text = "1 match found"; } else { Status.Text = matches.Count.ToString() + " matches found"; } Captures.ExpandAll(); } catch (Exception ex) { ErrorHandler(ex); } }
/// <summary> /// Parse according to simple C-like format-specs, %s and %d /// </summary> public static bool IsRxMatch(this string input, string pattern, out Captures matches) { if (IsMatch(input, pattern, out var values)) { matches = new Captures(values); return(true); } else { matches = null; return(false); } }
public static Captures LoadCaptures(string path) { var captures = new Captures(); var dir = new DirectoryInfo(path); foreach (FileInfo cap in GetFiles(dir)) { var newCap = new Capture(cap.FullName); captures.Add(newCap); } return(captures); }
public static Captures LoadCaptures(string path) { var captures = new Captures(); var dir = new DirectoryInfo(path); foreach (FileInfo cap in GetFiles(dir)) { var newCap = new Capture(cap.FullName); captures.Add(newCap); } return captures; }
private void LoadFolder(string Path, TreeNode Parent) { this.listViewFiles.Items.Clear(); Parent.Nodes.Clear(); List <DirectoryInfo> directories = CaptureManager.LoadCaptureFolder(Path); foreach (DirectoryInfo folder in directories) { AddNewDirectoryTreeNode(Parent, folder); } Captures c = CaptureManager.LoadCaptures(Path); foreach (Capture cap in c) { AddNewCaptureListViewItem(cap); } }
public void AddCapturer(ICapturer capturer) { object[] attributes = capturer.GetType().GetCustomAttributes(false); foreach (Object attribute in attributes) { if (attribute is Captures) { Captures cap = (Captures)attribute; CapturerInfo capturableInfo = new CapturerInfo(); capturableInfo.Capturer = capturer; capturableInfo.Capturable = cap.Name; capturableInfo.AddTo(_capturers); break; } } //TODO: Throw exception: [Captures] attribute is missing }
public void ReadBattlegroundData(BinaryReader br) { RoundNumber = br.ReadInt32(); RoundStatus = (RoundStatus)br.ReadInt32(); TurnType = (TurnType)br.ReadInt32(); TurnStatus = (TurnStatus)br.ReadInt32(); HeroAction = (HeroTurnAction)br.ReadInt32(); BattleStatus = (BattleStatus)br.ReadInt32(); SurpriseStatus = (SurpriseStatus)br.ReadInt32(); StallingRoundNumber = br.ReadInt32(); SelectedUnitId = br.ReadInt32(); SelectedTargetId = br.ReadInt32(); LastSkillUsed = br.ReadString(); int orderedUnitsCount = br.ReadInt32(); OrderedUnitsCombatIds.Clear(); for (int i = 0; i < orderedUnitsCount; i++) { OrderedUnitsCombatIds.Add(br.ReadInt32()); } int combatIdsCount = br.ReadInt32(); CombatIds.Clear(); for (int i = 0; i < combatIdsCount; i++) { CombatIds.Add(br.ReadInt32()); } int companionsCount = br.ReadInt32(); Companions.Clear(); for (int i = 0; i < companionsCount; i++) { Companions.Add(br.ReadInt32()); } int capturesCount = br.ReadInt32(); Captures.Clear(); for (int i = 0; i < capturesCount; i++) { Captures.Add(br.ReadInt32()); } int controlsCount = br.ReadInt32(); Controls.Clear(); for (int i = 0; i < controlsCount; i++) { Controls.Add(br.ReadInt32()); } int lastDamagedCount = br.ReadInt32(); LastDamaged.Clear(); for (int i = 0; i < lastDamagedCount; i++) { LastDamaged.Add(br.ReadString()); } int battleLootCount = br.ReadInt32(); BattleLoot.Clear(); for (int i = 0; i < battleLootCount; i++) { var newBattleLoot = new LootDefinition() { Code = br.ReadString(), Count = br.ReadInt32(), }; BattleLoot.Add(newBattleLoot); } int removedUnitsCount = br.ReadInt32(); RemovedUnits.Clear(); for (int i = 0; i < removedUnitsCount; i++) { var newFormationUnitData = new FormationUnitSaveData(); newFormationUnitData.ReadFormationUnitData(br); RemovedUnits.Add(newFormationUnitData); } MonsterFormation.ReadFormationData(br); }
internal void RegexRunnerFinished(RegexRunner sender) { Busy = false; Runner = null; if (sender.Error != null) { Status.Text = "Error encountered during processing"; MessageBox.Show(this, sender.Error.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (string.IsNullOrEmpty(sender.Replace)) // find { foreach (Match m in sender.Matches) { TreeNode n = Captures.Nodes.Add("{" + ReplaceNewLines(m.Value) + "}"); foreach (Group g in m.Groups) { // TODO: Is there any way to get the name of the group when explicit capture is on? if (g.Captures.Count > 1) { TreeNode nn = n.Nodes.Add("..."); foreach (Capture c in g.Captures) { nn.Nodes.Add("{" + ReplaceNewLines(c.Value) + "}"); } } else if (g.Captures.Count == 1) { n.Nodes.Add(ReplaceNewLines("{" + g.Captures[0].Value) + "}"); } } } if (sender.Matches.Count == 0) { Status.Text = "No matches"; } else if (sender.Matches.Count == 1) { Status.Text = "1 match found"; } else { Status.Text = sender.Matches.Count + " matches found"; } Captures.ExpandAll(); } else // replace { ResultText.Text = sender.Result; if (sender.Matches.Count != 1) { Status.Text = sender.Matches.Count + " replacements performed"; } else { Status.Text = "1 replacement performed"; } Captures.Visible = false; ResultText.Visible = true; txtInput.Text = txtInput.Text.Replace("\n", "\r\n"); ResultText.Text = ResultText.Text.Replace("\r\n", "\n"); ResultText.Text = ResultText.Text.Replace("\n", "\r\n"); } }
public CaptureOrderTargeter(Captures captures) : base("CaptureActor", 6, captures.Info.EnterCursor, true, true) { this.captures = captures; }
internal void RegexRunnerFinished(RegexRunner sender) { Busy = false; Runner = null; if (sender.Error != null) { Status.Text = "Error encountered during processing"; MessageBox.Show(this, sender.Error.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // replace may be with nothing (zero length string), so find mode is when replace is null if (sender.Replace == null) // find { Captures.BeginUpdate(); int i = 0; foreach (Match m in sender.Matches) { i++; TreeNode n = Captures.Nodes.Add("{" + ReplaceNewLines(m.Value) + "}"); foreach (Group g in m.Groups) { if (g.Captures.Count > 1) { TreeNode nn = n.Nodes.Add("..."); foreach (Capture c in g.Captures) { nn.Nodes.Add("{" + ReplaceNewLines(c.Value) + "}"); } } else if (g.Captures.Count == 1) { n.Nodes.Add(ReplaceNewLines("{" + g.Captures[0].Value) + "}"); } } // For performance limit tree view to first 500 results if (i > 499) { break; } } switch (sender.Matches.Count) { case 0: Status.Text = "No matches"; break; case 1: Status.Text = "1 match found"; break; default: if (sender.Matches.Count > 500) { Status.Text = sender.Matches.Count + " matches found (showing first 500)"; } else { Status.Text = sender.Matches.Count + " matches found"; } break; } Status.Text += " in " + sender.GetExecutionTime() + " ms"; Captures.ExpandAll(); Captures.EndUpdate(); } else // replace { ResultText.Text = sender.Result; if (sender.Matches.Count != 1) { Status.Text = sender.Matches.Count + " replacements performed"; } else { Status.Text = "1 replacement performed"; } Status.Text += " in " + sender.GetExecutionTime() + " ms"; Captures.Visible = false; ResultText.Visible = true; txtInput.Text = NewLineRegex.Replace(txtInput.Text, "\r\n"); // make user-inserted \n show as a genuine newline ResultText.Text = ResultText.Text.Replace("\\n", "\r\n"); // make any existing newlines in replace text display as newlines ResultText.Text = NewLineRegex.Replace(ResultText.Text, "\r\n"); } }
/// <summary> /// Generates a string where all the variables marked as Capture are printed in an organized fashion. /// </summary> /// <returns>The chained capture string.</returns> public string ToCaptureString() { return(string.Join(" | ", Captures.Select(c => c.Name + " = " + c.ToString()))); }
public void LoadEffects(BattleGroundSaveData battleSaveData) { #region Load Statuses and Immobilize for (int i = 0; i < HeroParty.Units.Count; i++) { if (HeroParty.Units[i].Character[StatusType.Stun].IsApplied) { HeroParty.Units[i].SetHalo("stunned"); } else if (HeroParty.Units[i].CombatInfo.IsSurprised) { HeroParty.Units[i].SetHalo("surprised"); } if (HeroParty.Units[i].CombatInfo.IsImmobilized) { HeroParty.Units[i].SetDefendAnimation(true); } if (HeroParty.Units[i].Character.IsMonster == false) { var hero = HeroParty.Units[i].Character as Hero; if (hero[StatusType.DeathsDoor].IsApplied) { hero.ApplyDeathDoor(); } else if (hero[StatusType.DeathRecovery].IsApplied) { hero.ApplyMortality(); } } } for (int i = 0; i < MonsterParty.Units.Count; i++) { if (MonsterParty.Units[i].Character[StatusType.Stun].IsApplied) { MonsterParty.Units[i].SetHalo("stunned"); } else if (MonsterParty.Units[i].CombatInfo.IsSurprised) { MonsterParty.Units[i].SetHalo("surprised"); } if (MonsterParty.Units[i].CombatInfo.IsImmobilized) { MonsterParty.Units[i].SetDefendAnimation(true); } if (MonsterParty.Units[i].Character.IsMonster == false) { MonsterParty.Units[i].SetCombatAnimation(true); var hero = MonsterParty.Units[i].Character as Hero; if (hero[StatusType.DeathsDoor].IsApplied) { hero.ApplyDeathDoor(); } else if (hero[StatusType.DeathRecovery].IsApplied) { hero.ApplyMortality(); } } } #endregion #region Load Captures for (int i = 0; i < battleSaveData.Captures.Count; i++) { CaptureRecord newCaptureRecord = new CaptureRecord(); int prisonerId = newCaptureRecord.GetHashPrisonerId(battleSaveData.Captures[i]); int captorId = newCaptureRecord.GetHashCaptorId(battleSaveData.Captures[i]); newCaptureRecord.RemoveFromParty = newCaptureRecord.GetHashRemoveFromParty(battleSaveData.Captures[i]); if (newCaptureRecord.RemoveFromParty == false) { FormationUnit prisoner = FindById(prisonerId); FormationUnit captor = FindById(captorId); newCaptureRecord.PrisonerUnit = prisoner; newCaptureRecord.CaptorUnit = captor; prisoner.SetCaptureEffect(captor); Captures.Add(newCaptureRecord); } else { FormationUnit prisoner = loadedRemovedPrisoners.Find(removedUnit => removedUnit.CombatInfo.CombatId == prisonerId); FormationUnit captor = FindById(captorId); prisoner.RectTransform.position = captor.RectTransform.position; newCaptureRecord.PrisonerUnit = prisoner; newCaptureRecord.CaptorUnit = captor; Captures.Add(newCaptureRecord); } } #endregion #region Load Companions for (int i = 0; i < battleSaveData.Companions.Count; i++) { CompanionRecord newCompanionRecord = new CompanionRecord(); int companionId = newCompanionRecord.GetHashCompanionId(battleSaveData.Companions[i]); int targetId = newCompanionRecord.GetHashTargetId(battleSaveData.Companions[i]); FormationUnit companion = FindById(companionId); FormationUnit target = FindById(targetId); newCompanionRecord.CompanionUnit = companion; newCompanionRecord.TargetUnit = target; Companions.Add(newCompanionRecord); } #endregion #region Load Controls for (int i = 0; i < battleSaveData.Controls.Count; i++) { ControlRecord newControlRecord = new ControlRecord(); int prisonerId = newControlRecord.GetHashPrisonerId(battleSaveData.Controls[i]); int controllerId = newControlRecord.GetHashControlId(battleSaveData.Controls[i]); newControlRecord.DurationLeft = newControlRecord.GetHashDurationLeft(battleSaveData.Controls[i]); FormationUnit prisoner = FindById(prisonerId); FormationUnit controller = FindById(controllerId); newControlRecord.PrisonerUnit = prisoner; newControlRecord.ControllUnit = controller; Controls.Add(newControlRecord); } #endregion loadedRemovedPrisoners.Clear(); RaidSceneManager.Formations.HeroOverlay.UpdateOverlay(); RaidSceneManager.Formations.monsters.overlay.UpdateOverlay(); }
internal void RegexRunnerFinished(RegexRunner sender) { Busy = false; Runner = null; if (sender.Error != null) { Status.Text = "Error encountered during processing"; MessageBox.Show(this, sender.Error.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (string.IsNullOrEmpty(sender.Replace)) // find { foreach (Match m in sender.Matches) { TreeNode n = Captures.Nodes.Add("{" + ReplaceNewLines(m.Value) + "}"); foreach (Group g in m.Groups) { if (g.Captures.Count > 1) { TreeNode nn = n.Nodes.Add("..."); foreach (Capture c in g.Captures) { nn.Nodes.Add("{" + ReplaceNewLines(c.Value) + "}"); } } else if (g.Captures.Count == 1) { n.Nodes.Add(ReplaceNewLines("{" + g.Captures[0].Value) + "}"); } } } switch (sender.Matches.Count) { case 0: Status.Text = "No matches"; break; case 1: Status.Text = "1 match found"; break; default: Status.Text = sender.Matches.Count + " matches found"; break; } Status.Text += " in " + sender.GetExecutionTime() + " ms"; Captures.ExpandAll(); } else // replace { ResultText.Text = sender.Result; if (sender.Matches.Count != 1) { Status.Text = sender.Matches.Count + " replacements performed"; } else { Status.Text = "1 replacement performed"; } Status.Text += " in " + sender.GetExecutionTime() + " ms"; Captures.Visible = false; ResultText.Visible = true; txtInput.Text = NewLineRegex.Replace(txtInput.Text, "\r\n"); ResultText.Text = ResultText.Text.Replace("\r\n", "\n"); ResultText.Text = NewLineRegex.Replace(ResultText.Text, "\r\n"); } }