void OnGUI() { EditorGUIUtility.labelWidth = 80; EditorGUILayout.Space(); EditorGUILayout.Space(); GUI.SetNextControlName("input"); groupName = EditorGUILayout.TextField("Group Name", groupName); EditorGUILayout.Space(); GUILayout.BeginHorizontal(); GroupCommand window = (GroupCommand)EditorWindow.GetWindow(typeof(GroupCommand)); Event e = Event.current; if (GUILayout.Button("Close", GUILayout.Width(100))) { window.Close(); } if (GUILayout.Button("Create Group", GUILayout.Width(200)) || e.keyCode == KeyCode.Return) { GroupSelected(); window.Close(); } GUILayout.FlexibleSpace(); EditorGUI.FocusTextInControl("input"); }
public IGroupCommand AddGroupCommand(string id) { var cmd = new GroupCommand(); commands.Add(id, cmd); return(cmd); }
private void GroupObject_Click(object sender, EventArgs e) { GroupCommand grouping = new GroupCommand((DiagramToolkit.Api.Shapes.Rectangle)curCanvas.getActiveObject(), curCanvas.getprevActiveObject()); grouping.UnExecute(); undoRedo.InsertCommand(grouping); }
IEnumerable <Task <ICommand> > ApplyRestartPolicy(IEnumerable <IRuntimeModule> modules) { IEnumerable <IRuntimeModule> modulesToBeRestarted = this.restartManager.ApplyRestartPolicy(modules); IEnumerable <Task <ICommand> > restart = modulesToBeRestarted.Select(async module => { ICommand group = new GroupCommand( // restart the module // await this.commandFactory.RestartAsync(module), // TODO: Windows native containers have an outstanding bug where "docker restart" // doesn't work. But a "docker stop" followed by a "docker start" will work. Putting // in a temporary workaround to address this. This should be rolled back when the // Windows bug is fixed. await this.commandFactory.StopAsync(module), await this.commandFactory.StartAsync(module), // Update restart count and last restart time in store await this.commandFactory.WrapAsync( new AddToStoreCommand <ModuleState>(this.store, module.Name, new ModuleState(module.RestartCount + 1, DateTime.UtcNow)) ) ); return(await this.commandFactory.WrapAsync(group)); }); return(restart); }
protected override void InitializeCommands() { CommandManager.BeginUpdate(); base.InitializeCommands(); CommandManager.Add(CommandId.UpdateWeblogStyle, commandUpdateWeblogStyle_Execute); commandViewUseStyles = CommandManager.Add(CommandId.ViewUseStyles, commandViewUseStyles_Execute); commandSemanticHtml = new SemanticHtmlGalleryCommand(CommandId.SemanticHtmlGallery, _postEditingSite, GetPreviewHtml, CommandManager, _currentEditor as IHtmlEditorComponentContext); commandSemanticHtml.ExecuteWithArgs += new ExecuteEventHandler(commandSemanticHtml_ExecuteWithArgs); commandSemanticHtml.ComponentContext = () => _currentEditor as IHtmlEditorComponentContext; CommandManager.Add(commandSemanticHtml); commandInsertablePlugins = new InsertablePluginsGalleryCommand(); commandInsertablePlugins.ExecuteWithArgs += new ExecuteEventHandler(commandInsertablePlugins_ExecuteWithArgs); commandInsertablePlugins.LoadItems(); CommandManager.Add(commandInsertablePlugins); commandInsertWebImage = new Command(CommandId.WebImage); commandInsertWebImage.Execute += new EventHandler(commandInsertWebImage_Execute); CommandManager.Add(commandInsertWebImage); commandInsertExtendedEntry = CommandManager.Add(CommandId.InsertExtendedEntry, commandInsertExtendedEntry_Execute); EditorLoaded += new EventHandler(ContentEditor_EditorHtmlReloaded); // QAT CommandManager.Add(new GalleryCommand <CommandId>(CommandId.QAT)); // Outspace CommandManager.Add(new RecentItemsCommand(_postEditingSite)); CommandManager.Add(new GroupCommand(CommandId.InsertImageSplit, CommandManager.Get(CommandId.InsertPictureFromFile))); // WinLive 181138 - A targetted fix to ensure the InsertVideoSplit command is disabled if we don't support InsertVideo (e.g zh-CN doesn't support video) // The problem is related to Windows 7 #712524 & #758433 and this is a work around for this particular case. // The dropdown commands for this (InsertVideoFromFile etc) are already disabled based on the feature support. We explicitly set the state of // group command here so that it has the right state to begin with (otherwise a switch tab/app is required to refresh). GroupCommand commandInsertVideoSplit = new GroupCommand(CommandId.InsertVideoSplit, CommandManager.Get(CommandId.InsertVideoFromFile)); commandInsertVideoSplit.Enabled = MarketizationOptions.IsFeatureEnabled(MarketizationOptions.Feature.VideoProviders); CommandManager.Add(commandInsertVideoSplit); foreach (CommandId commandId in new CommandId[] { CommandId.SplitNew, CommandId.SplitSave, CommandId.SplitPrint, CommandId.PasteSplit, CommandId.FormatTablePropertiesSplit }) { CommandManager.Add(new Command(commandId)); } _commandClosePreview = CommandManager.Add(CommandId.ClosePreview, commandClosePreview_Execute, false); CommandManager.EndUpdate(); }
protected override void EscapeToCity() { base.EscapeToCity(); StopPlayerAttackMode(); GroupCommand.NoticeEnemiesGroupEnd(); IsGroupLeader = false; }
public override void InitEnemy(UsedInitData InitData) { transform.position = InitData.BasePosition.position; MyType = EnemyType.Middle; EnemyManager.Instance.SetEnemy(this); ChildModelMedium.SetParentTransform(transform); IsGroupLeader = false; ElapsedCheckTime = GroupCheckTime; GroupCommand.GroupInitialize(); }
override protected void Update() { base.Update(); if ((!IsGroupLeader) && CheckGroupFormation()) { IsGroupLeader = true; GroupCommand.NoticeEnemiesGather(); } Debug(); }
public async Task TestCreate( Option <TestPlanRecorder> recorder, List <TestRecordType> moduleExecutionList, List <ICommand> commandList) { var g = new GroupCommand(commandList.ToArray()); var token = default(CancellationToken); await g.ExecuteAsync(token); this.AssertCommands(recorder, commandList, moduleExecutionList); }
public async Task TestUndoAsync( Option <TestPlanRecorder> recorder, List <TestRecordType> moduleExecutionList, List <ICommand> commandList) { ICommand g = new GroupCommand(commandList.ToArray()); var token = new CancellationToken(); await g.UndoAsync(token); this.AssertUndo(recorder, commandList, moduleExecutionList); }
public List <Command> ParseCommands(List <string> lines, long base_line) { List <Command> commands = new List <Command>(), cur_group_cmds = ObjectPool <List <Command> > .Instance.GetObject(); GroupCommand current_group_command = null; foreach (var line in lines) { base_line++; var data_arr = line.Split(','); var is_sub_cmd = data_arr.First().StartsWith(" ") || data_arr.First().StartsWith("__"); foreach (var cmd in CommandParserIntance.Parse(data_arr)) { cmd.RelativeLine = base_line; if (is_sub_cmd) { //如果是子命令的话就要添加到当前Group if (current_group_command != null) { current_group_command.AddSubCommand(cmd); } } else { var prev_group = current_group_command; current_group_command = cmd as GroupCommand; if (current_group_command != prev_group) { prev_group?.UpdateSubCommand(); } commands.Add(cmd); } } } if (current_group_command is GroupCommand loop) { loop.UpdateSubCommand(); } ObjectPool <List <Command> > .Instance.PutObject(cur_group_cmds); return(commands); }
public void TestShow( Option <TestPlanRecorder> recorder, List <TestRecordType> moduleExecutionList, List <ICommand> commandList) { ICommand g = new GroupCommand(commandList.ToArray()); string showString = g.Show(); foreach (ICommand command in commandList) { Assert.True(showString.Contains(command.Show())); } }
public Form1() { InitializeComponent(); commands[Keys.Right.ToString()] = new MoveCommand(s1, this, 10, 0); commands[Keys.Left.ToString()] = new MoveCommand(s1, this, -10, 0); commands[Keys.Up.ToString()] = new MoveCommand(s1, this, 0, -10); commands[Keys.Down.ToString()] = new MoveCommand(s1, this, 0, 10); commands[Keys.Delete.ToString()] = new DeleteCommand(s1, this); commands["Group"] = new GroupCommand(s1, this); commands["Ungroup"] = new UngroupCommand(s1, this); commands["AddShape"] = new AddShapeCommand(s1, this); commands["Select"] = new SelectCommand(s1, this); commands["MouseMove"] = new MouseMoveCommand(s1, this); currFig = 0; }
/// <summary> /// Handles UI buttons and activates the command pattern /// </summary> private async void UserActionClick(object sender, RoutedEventArgs e) { if (sender is AppBarButton button) { IUserActionCommand cmd = null; switch (button.Name) { case "OpenButton": cmd = new OpenFileCommand(this); break; case "SaveButton": cmd = new SaveFileCommand(); break; case "RedoButton": cmd = new RedoCommand(this); break; case "UndoButton": cmd = new UndoCommand(this); break; case "GroupButton": cmd = new GroupCommand(this); break; case "UnGroupButton": cmd = new UnGroupCommand(this); break; case "DeleteButton": cmd = new DeleteItemCommand(this); break; } if (cmd != null) { cmd.RedoStack = _redoStack; cmd.UndoStack = _undoStack; cmd.ShapeList = _shapeList; await _userInvoker.InvokeUserActionAsync(cmd); } } }
void ImportFramesFromImage(object o, EventArgs e) { using (ImportFramesDialog dlg = new ImportFramesDialog()) { DialogResult result = dlg.ShowDialog(); if (result == DialogResult.OK) { Bitmap[] frames = dlg.ImportFrames(); // Build monster command thing GroupCommand cmd = new GroupCommand(); for (int i = 0; i < frames.Length; i++) { cmd.AddCommand(new InsertFrameCommand(document.Frames.Count + i, frames[i])); } document.SendCommand(cmd); } } }
public GroupViewModel(IFaceServiceClient client, IDialogService dialogService) { this.client = client; var fileSelector = new ObservableFileSelector(); var imageSelector = new ImageSelector(fileSelector.SelectFilesCommand); faceDetector = new Detector(client); SelectFilesCommand = fileSelector.SelectFilesCommand; var selectFilesObs = SelectFilesCommand.Publish(); GroupCommand = ReactiveCommand.CreateFromTask(GroupImages, imageSelector.Images.Any()); GroupCommand.ThrownExceptions.Subscribe(async exception => await dialogService.ShowException(exception)); imagesHelper = imageSelector.Images.ToProperty(this, model => model.Images); groupsHelper = GroupCommand.ToProperty(this, model => model.Groups); loadingHelper = GroupCommand.IsExecuting.ToProperty(this, model => model.IsBusy); selectFilesObs.Connect(); }
public async Task TestGroupCommandCancellation() { // Arrange var cts = new CancellationTokenSource(); Mock <ICommand>[] commands = { this.MakeMockCommand("c1"), this.MakeMockCommand("c2", () => cts.Cancel()), this.MakeMockCommand("c3"), }; ICommand groupCommand = new GroupCommand( commands.Select(m => m.Object).ToArray()); // Act await groupCommand.ExecuteAsync(cts.Token); // Assert commands[0].Verify(m => m.ExecuteAsync(cts.Token), Times.Once()); commands[1].Verify(m => m.ExecuteAsync(cts.Token), Times.Once()); commands[2].Verify(m => m.ExecuteAsync(cts.Token), Times.Never()); }
/// <summary> /// 攻撃体勢に入る /// </summary> override protected void AttackPose() { SelectAttackId(); var prefab = GetResource(); MyAttackObj = Instantiate(prefab); MyAttackObj.Initialize(this.gameObject); IsAttacking = true; AnimationAttackPose(); GroupCommand.NoticeEnemiesAttack(); if (ieAttackMode != null) { StopCoroutine(ieAttackMode); } ieAttackMode = AttackStart(0.5f + attackIntervalTime); StartCoroutine(ieAttackMode); StopMove(2f + NextAttackInterval); }
//只会加入必要的组 private void HandleGroupCollection(LineCommand parentCmd, WordGroupCollection coll, bool isTranslate, bool[] enterStatus, bool[] exitStatus) { int i = 0; foreach (var gp in coll) { if ((!enterStatus[i]) && exitStatus[i]) { FlagCommand x; if (commandList.ContainsKey(gp.ActiveTime)) { x = commandList[gp.ActiveTime]; if (x is LineCommand) { throw new Exception("duplicate timeline(crash between line and group)"); } } else { x = new GroupCommand() { ParentLine = parentCmd }; commandList.Add(gp.ActiveTime, x); } (x as GroupCommand).gpList.Add(new GroupInfos() { group = gp, id = i, isTranslate = isTranslate }); } i++; } }
public override float SeekTo(float time) { int newcusor = CurrentCusor; //从中间刻度修正当前状态 void FixMidLine() { LineCommand curLine = commandList.Values[CurrentCusor].GetLineCommand(); bool[] arr = (bool[])curLine.enter_group_status.Clone(); bool[] arr_trans = (bool[])curLine.enter_group_status_translate.Clone(); { //回溯已经激活的组信息 int temp = CurrentCusor; while (commandList.Values[temp] != curLine) { GroupCommand group = (GroupCommand)commandList.Values[temp]; foreach (var gp in group.gpList) { if (gp.isTranslate) { arr_trans[gp.id] = true; } else { arr[gp.id] = true; } } temp--; } OnActiveLyricLine?.Invoke(new LineInfoBundle() { LyricLine = curLine.line, LineNumber = curLine.linecode, GroupActiveInfo = arr, TranslateActiveInfo = arr_trans }); } } if (CurrentCusor < 0 || commandList.Keys[CurrentCusor] < time) { //CorrentCusor++ while (newcusor + 1 < commandList.Count && commandList.Keys[newcusor + 1] <= time) { newcusor++; } if (newcusor > CurrentCusor) { //now turn to newcusor //CurrentCusor may equals -1 if (CurrentCusor != newcusor - 1) { //需要重置状态 while (CurrentCusor + 1 < newcusor) { FlagCommand ncmd = commandList.Values[CurrentCusor + 1]; if (ncmd is LineCommand) { if (CurrentCusor != -1) { //DeActive CurrentCusor as exit status LineCommand lcmd = commandList.Values[CurrentCusor].GetLineCommand(); OnUnActiveLyricLine?.Invoke(new LineInfoBundle() { LyricLine = lcmd.line, LineNumber = lcmd.linecode, GroupActiveInfo = lcmd.exit_group_status, TranslateActiveInfo = lcmd.exit_group_status_translate }); } } CurrentCusor++; }//while(CurrentCusor + 1< newcusor) if (commandList.Values[newcusor] is GroupCommand) { //现在位于行中间,回溯激活当前行 FixMidLine(); } } //现在CurrentCusor == newcusor - 1了,而且状态正常 //下一行是Line,则UnActive当前Line,并Active下一行的Line,下一行是Group,则Active这个Line,并激活Group if (commandList.Values[newcusor] is GroupCommand) { //激活新Group CurrentCusor++; LineCommand curLine = commandList.Values[CurrentCusor].GetLineCommand(); //assert CurrentCusor == newcusor foreach (var x in ((GroupCommand)commandList.Values[CurrentCusor]).gpList) { OnActiveGroup?.Invoke(new GroupInfoBundle() { Group = x.group, GroupId = x.id, IsTranslate = x.isTranslate, LineNumber = curLine.linecode, LyricLine = curLine.line }); } } else {//下面是新的一行(正常换行走这里),UnActive当前行并激活新行 if (CurrentCusor >= 0) { LineCommand lcmd = commandList.Values[CurrentCusor].GetLineCommand(); OnUnActiveLyricLine?.Invoke(new LineInfoBundle() { LyricLine = lcmd.line, LineNumber = lcmd.linecode, GroupActiveInfo = lcmd.exit_group_status, TranslateActiveInfo = lcmd.exit_group_status_translate }); } CurrentCusor++; {//Active new line LineCommand lcmd = (LineCommand)commandList.Values[CurrentCusor]; OnActiveLyricLine?.Invoke(new LineInfoBundle() { LyricLine = lcmd.line, LineNumber = lcmd.linecode, GroupActiveInfo = lcmd.enter_group_status, TranslateActiveInfo = lcmd.enter_group_status_translate }); } } } //CurrentCusor ++ end } else { //CurrentCusor-- or keep while (newcusor >= 0 && commandList.Keys[newcusor] > time) { newcusor--; } if (newcusor < CurrentCusor) { //new turn to newcusor //newcusor may equals -1 while (newcusor < CurrentCusor) { if (commandList.Values[CurrentCusor] is LineCommand) { //UnActinve this line and all group LineCommand lcmd = (LineCommand)commandList.Values[CurrentCusor]; OnUnActiveLyricLine?.Invoke(new LineInfoBundle() { LineNumber = lcmd.linecode, LyricLine = lcmd.line, GroupActiveInfo = null,//传值全false TranslateActiveInfo = null }); } CurrentCusor--; } //回溯当前行 if (CurrentCusor >= 0) { FixMidLine(); } } //CurrentCusor-- end } if (CurrentCusor + 1 < commandList.Count) { return(commandList.Keys[CurrentCusor + 1]); } else { return(float.PositiveInfinity); } }
public GroupCommand <TKey, ReadableTuple <TKey> > Generate <TKey>(ReadableTuple <TKey> item, ReadableTuple <int> tupleSource, AbstractDb <int> mobDb1, AbstractDb <int> mobDb2, AbstractDb <int> pet1, AbstractDb <int> pet2) { var description = item.GetValue <ParameterHolder>(ClientItemAttributes.Parameters).Values[ParameterHolderKeys.Description] ?? ""; description = ParameterHolder.ClearDescription(description); ParameterHolder holder = new ParameterHolder(); GroupCommand <TKey, ReadableTuple <TKey> > commands = GroupCommand <TKey, ReadableTuple <TKey> > .Make(); int numSlotC = _getInt(ClientItemAttributes.NumberOfSlots, item); int numSlotS = _getInt(ServerItemAttributes.NumberOfSlots, tupleSource); if (ProjectConfiguration.AutocompleteViewId) { int viewIdC = _getInt(ClientItemAttributes.ClassNumber, item); int viewIdS = _getInt(ServerItemAttributes.ClassNumber, tupleSource); if (viewIdC != viewIdS) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ClientItemAttributes.ClassNumber, viewIdS)); } } if (ProjectConfiguration.AutocompleteNumberOfSlot) { if (numSlotC != numSlotS) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ClientItemAttributes.NumberOfSlots, numSlotS)); } } if ((TypeType)tupleSource.GetValue <int>(ServerItemAttributes.Type) != TypeType.Card) { if (item.GetValue <bool>(ClientItemAttributes.IsCard)) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ClientItemAttributes.IsCard, false)); } } string idDisplayName = tupleSource.GetValue <string>(ServerItemAttributes.Name); if (_emptyFill(ClientItemAttributes.IdentifiedDisplayName, item) && ProjectConfiguration.AutocompleteIdDisplayName && _isNotNullDifferent(idDisplayName, ClientItemAttributes.IdentifiedDisplayName, item)) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ClientItemAttributes.IdentifiedDisplayName, idDisplayName)); } DbAttribute attribute; TypeType itemType = (TypeType)tupleSource.GetValue <int>(ServerItemAttributes.Type); if (itemType == TypeType.Weapon || itemType == TypeType.Armor) { if (itemType == TypeType.Armor && !ItemParser.IsArmorType(tupleSource)) { if (itemType == TypeType.Armor) { itemType = TypeType.Weapon; } else { itemType = TypeType.Armor; } } } // Weight: //holder = item.GetValue<ParameterHolder>(ClientItemAttributes.Parameters); // //switch (itemType) { // case TypeType.Weapon: // case TypeType.Ammo: // case TypeType.Armor: // case TypeType.Card: // case TypeType.PetEgg: // case TypeType.PetEquip: // case TypeType.UsableItem: // case TypeType.EtcItem: // case TypeType.HealingItem: // case TypeType.ShadowEquip: // case TypeType.UsableWithDelayed: // case TypeType.UsableWithDelayed2: // _autoAddWeight(tupleSource, holder); // break; //} DbAttribute equipLevelAttribute = ServerItemAttributes.EquipLevel; if (tupleSource.GetIntNoThrow(ServerItemAttributes.EquipLevelMin) > tupleSource.GetIntNoThrow(ServerItemAttributes.EquipLevel)) { equipLevelAttribute = ServerItemAttributes.EquipLevelMin; } switch (itemType) { case TypeType.Weapon: string type = _findWeaponType(tupleSource) ?? "Weapon"; holder.Values[ParameterHolderKeys.Class] = type; string unidentifiedResourceName = EncodingService.FromAnyToDisplayEncoding(_findWeaponUnidentifiedResource(tupleSource) ?? ""); attribute = ClientItemAttributes.UnidentifiedResourceName; if (_emptyFill(attribute, item) && ProjectConfiguration.AutocompleteUnResourceName && _isNotNullDifferent(unidentifiedResourceName, attribute, item)) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, attribute, unidentifiedResourceName)); } string identifiedResourceName = item.GetStringValue(ClientItemAttributes.IdentifiedResourceName.Index); attribute = ClientItemAttributes.IdentifiedResourceName; if (String.IsNullOrEmpty(identifiedResourceName) && ProjectConfiguration.AutocompleteIdResourceName && _isNotNullDifferent(unidentifiedResourceName, attribute, item)) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, attribute, unidentifiedResourceName)); } attribute = ClientItemAttributes.UnidentifiedDisplayName; if (_emptyFill(attribute, item) && ProjectConfiguration.AutocompleteUnDisplayName && _isNotNullDifferent(type, attribute, item)) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, attribute, type)); } if (!tupleSource.GetValue <bool>(ServerItemAttributes.Refineable)) { if (!description.Contains("Impossible to refine") && !description.Contains("Cannot be upgraded") && !description.ToLower().Contains("rental item")) { description += "\r\nImpossible to refine this item."; } } if (tupleSource.GetValue <bool>(ServerItemAttributes.Refineable)) { if (description.Contains("Impossible to refine")) { description = description.Replace("Impossible to refine this item.", "").Trim('\r', '\n'); } } _autoAdd(ServerItemAttributes.Attack, ParameterHolderKeys.Attack, tupleSource, holder); _autoAddWeight(tupleSource, holder); _autoAdd(ServerItemAttributes.WeaponLevel, ParameterHolderKeys.WeaponLevel, tupleSource, holder); _autoAddJob(tupleSource, holder, _getInt(equipLevelAttribute, tupleSource)); _autoAddElement(tupleSource, holder); break; case TypeType.Ammo: type = _findAmmoType(tupleSource.GetStringValue(ServerItemAttributes.ApplicableJob.Index)) ?? "Ammunition"; holder.Values[ParameterHolderKeys.Class] = type; _autoAdd(ServerItemAttributes.Attack, ParameterHolderKeys.Attack, tupleSource, holder, -1); _autoAddWeight(tupleSource, holder); _autoAddElement(tupleSource, holder); break; case TypeType.Armor: int location = _getInt(ServerItemAttributes.Location, tupleSource); type = _findArmorType(location) ?? "Armor"; holder.Values[ParameterHolderKeys.Class] = type; unidentifiedResourceName = EncodingService.FromAnyToDisplayEncoding(_findArmorUnidentifiedResource(tupleSource, item) ?? ""); attribute = ClientItemAttributes.UnidentifiedResourceName; if (_emptyFill(attribute, item) && ProjectConfiguration.AutocompleteUnResourceName && _isNotNullDifferent(unidentifiedResourceName, attribute, item)) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, attribute, unidentifiedResourceName)); } else { unidentifiedResourceName = item.GetValue <string>(ClientItemAttributes.UnidentifiedResourceName); } identifiedResourceName = item.GetStringValue(ClientItemAttributes.IdentifiedResourceName.Index); attribute = ClientItemAttributes.IdentifiedResourceName; if (String.IsNullOrEmpty(identifiedResourceName) && ProjectConfiguration.AutocompleteIdResourceName && _isNotNullDifferent(unidentifiedResourceName, attribute, item)) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, attribute, unidentifiedResourceName)); } string unDisplayName = _findArmorUnidentifiedDisplayName(unidentifiedResourceName); attribute = ClientItemAttributes.UnidentifiedDisplayName; if (_emptyFill(attribute, item) && ProjectConfiguration.AutocompleteUnDisplayName && _isNotNullDifferent(unDisplayName, attribute, item)) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, attribute, unDisplayName)); } if ((_getInt(ServerItemAttributes.Location, tupleSource) & 374) != 0) { if (!tupleSource.GetValue <bool>(ServerItemAttributes.Refineable)) { if (!description.Contains("Impossible to refine")) { description += "\r\nImpossible to refine this item."; } } if (tupleSource.GetValue <bool>(ServerItemAttributes.Refineable)) { if (description.Contains("Impossible to refine")) { description = description.Replace("Impossible to refine this item.", "").Trim('\r', '\n'); } } } _autoAdd(ServerItemAttributes.Defense, ParameterHolderKeys.Defense, tupleSource, holder); _autoAddEquippedOn(ServerItemAttributes.Location, ParameterHolderKeys.Location, tupleSource, holder); _autoAddWeight(tupleSource, holder); _autoAddJob(tupleSource, holder, _getInt(equipLevelAttribute, tupleSource)); break; case TypeType.Card: holder.Values[ParameterHolderKeys.Class] = "Card"; _autoAddCompound(ServerItemAttributes.Location, ParameterHolderKeys.CompoundOn, tupleSource, holder); _autoAdd(equipLevelAttribute, ParameterHolderKeys.RequiredLevel, tupleSource, holder, 1); _autoAddWeight(tupleSource, holder); if (!item.GetValue <bool>(ClientItemAttributes.IsCard)) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ClientItemAttributes.IsCard, true)); } if (String.IsNullOrEmpty(item.GetValue <string>(ClientItemAttributes.Illustration))) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ClientItemAttributes.Illustration, "sorry")); } if (String.IsNullOrEmpty(item.GetValue <string>(ClientItemAttributes.Affix))) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ClientItemAttributes.Affix, tupleSource.GetValue <string>(ServerItemAttributes.Name))); } const string CardResource = "À̸§¾ø´ÂÄ«µå"; unDisplayName = tupleSource.GetValue <string>(ServerItemAttributes.Name); attribute = ClientItemAttributes.UnidentifiedDisplayName; if (_emptyFill(attribute, item) && ProjectConfiguration.AutocompleteUnDisplayName && _isNotNullDifferent(unDisplayName, attribute, item)) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, attribute, unDisplayName)); } unidentifiedResourceName = EncodingService.FromAnyToDisplayEncoding(CardResource); attribute = ClientItemAttributes.UnidentifiedResourceName; if (_emptyFill(attribute, item) && ProjectConfiguration.AutocompleteUnResourceName && _isNotNullDifferent(unidentifiedResourceName, attribute, item)) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, attribute, unidentifiedResourceName)); } attribute = ClientItemAttributes.IdentifiedResourceName; if (_emptyFill(attribute, item) && ProjectConfiguration.AutocompleteIdResourceName && _isNotNullDifferent(unidentifiedResourceName, attribute, item)) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, attribute, unidentifiedResourceName)); } break; case TypeType.PetEgg: holder.Values[ParameterHolderKeys.Class] = "Monster Egg"; _autoAddWeight(tupleSource, holder); break; case TypeType.PetEquip: holder.Values[ParameterHolderKeys.Class] = "Cute Pet Armor"; _autoAddWeight(tupleSource, holder); int id = item.GetKey <int>(); List <ReadableTuple <int> > tuples = pet1.Table.Tuples.Where(p => p.Value.GetValue <int>(ServerPetAttributes.EquipId) == id).Select(p => p.Value).Concat( pet2.Table.Tuples.Where(p => p.Value.GetValue <int>(ServerPetAttributes.EquipId) == id).Select(p => p.Value) ).ToList(); if (tuples.Count > 0) { // Try to retrieve the names List <string> values = new List <string>(); foreach (ReadableTuple <int> tuple in tuples) { var pid = tuple.GetKey <int>(); var pTuple = mobDb2.Table.TryGetTuple(pid) ?? mobDb1.Table.TryGetTuple(pid); if (pTuple != null) { values.Add(pTuple.GetValue <string>(ServerMobAttributes.KRoName)); } } if (values.Count > 0) { holder.Values[ParameterHolderKeys.ApplicablePet] = String.Join(", ", values.ToArray()); } } break; case TypeType.UsableItem: _autoAddPet(tupleSource, holder); _autoAddWeight(tupleSource, holder); _autoAddJobIfRestricted(tupleSource, holder); break; case TypeType.EtcItem: case TypeType.HealingItem: case TypeType.ShadowEquip: case TypeType.UsableWithDelayed: case TypeType.UsableWithDelayed2: _autoAddWeight(tupleSource, holder); _autoAddJobIfRestricted(tupleSource, holder); break; } _autoAdd(equipLevelAttribute, ParameterHolderKeys.RequiredLevel, tupleSource, holder, 1); holder.Values[ParameterHolderKeys.Description] = description == "" ? ProjectConfiguration.AutocompleteDescNotSet : description; var idDescription = holder.GenerateDescription(); if (ProjectConfiguration.AutocompleteIdDescription) { if (idDescription != item.GetValue <string>(ClientItemAttributes.IdentifiedDescription)) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ClientItemAttributes.IdentifiedDescription, idDescription)); } } var unDescription = item.GetValue <string>(ClientItemAttributes.UnidentifiedDescription); // unidentified switch (tupleSource.GetValue <TypeType>(ServerItemAttributes.Type)) { case TypeType.Ammo: case TypeType.EtcItem: case TypeType.HealingItem: case TypeType.PetEgg: case TypeType.UsableItem: case TypeType.UsableWithDelayed: case TypeType.UsableWithDelayed2: if (ProjectConfiguration.AutocompleteUnDescription && unDescription != idDescription) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ClientItemAttributes.UnidentifiedDescription, idDescription)); } string unDisplayName = tupleSource.GetValue <string>(ServerItemAttributes.Name); attribute = ClientItemAttributes.UnidentifiedDisplayName; if (_emptyFill(attribute, item) && ProjectConfiguration.AutocompleteUnDisplayName && _isNotNullDifferent(unDisplayName, attribute, item)) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, attribute, unDisplayName)); } string unidentifiedResourceName = item.GetValue <string>(ClientItemAttributes.IdentifiedResourceName); if (String.IsNullOrEmpty(unidentifiedResourceName)) { unidentifiedResourceName = EncodingService.FromAnyToDisplayEncoding("Á¶°¢ÄÉÀÌÅ©"); // Cake } attribute = ClientItemAttributes.UnidentifiedResourceName; if (_emptyFill(attribute, item) && ProjectConfiguration.AutocompleteUnResourceName && _isNotNullDifferent(unidentifiedResourceName, attribute, item)) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, attribute, unidentifiedResourceName)); } attribute = ClientItemAttributes.IdentifiedResourceName; if (_emptyFill(attribute, item) && ProjectConfiguration.AutocompleteIdResourceName && _isNotNullDifferent(unidentifiedResourceName, attribute, item)) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, attribute, unidentifiedResourceName)); } break; case TypeType.Card: if (ProjectConfiguration.AutocompleteUnDescription && unDescription != idDescription) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ClientItemAttributes.UnidentifiedDescription, idDescription)); } break; default: if (ProjectConfiguration.AutocompleteUnDescription && unDescription != ProjectConfiguration.AutocompleteUnDescriptionFormat) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ClientItemAttributes.UnidentifiedDescription, ProjectConfiguration.AutocompleteUnDescriptionFormat)); } break; } if (commands.Commands.Count == 0) { return(null); } return(commands); }
static void Main(string[] args) { // ------------------------ FIRST TABLE -------------------------------------- Cell c1 = new Cell(2011); Cell c2 = new Cell(2012); Cell c3 = new Cell(2013); Cell s1 = new Cell("Kraków"); Cell s2 = new Cell("Kraków"); Cell s3 = new Cell("Gdańsk"); Cell s4 = new Cell("Gdańsk"); Cell s5 = new Cell("Wrocław"); Cell s6 = new Cell("Poznań"); Cell s7 = new Cell("Wawa"); Cell s8 = new Cell("Gdańsk"); Cell s9 = new Cell("Rzym"); Cell l1 = new Cell((int)15); Cell l2 = new Cell((int)20); Cell l3 = new Cell((int)20); Cell l4 = new Cell((int)30); Cell l5 = new Cell((int)40); Cell l6 = new Cell((int)50); Cell l7 = new Cell((int)60); Cell l8 = new Cell((int)80); Cell l9 = new Cell((int)11); Cell p1 = new Cell(2); Column c = new Column("Rok", DataType.StringDimension); c.AddCell(c1); c.AddCell(c1); c.AddCell(c2); c.AddCell(c3); c.AddCell(c2); c.AddCell(c3); c.AddCell(c1); c.AddCell(c1); Column s = new Column("Miasto", DataType.StringDimension); s.AddCell(s1); s.AddCell(s2); s.AddCell(s3); s.AddCell(s4); s.AddCell(s5); s.AddCell(s6); s.AddCell(s7); s.AddCell(s8); Column l = new Column("Sprzedaż", DataType.FloatFact); l.AddCell(l1); l.AddCell(l2); l.AddCell(l3); l.AddCell(l4); l.AddCell(l5); l.AddCell(l6); l.AddCell(l7); l.AddCell(l8); Column p = new Column("Coś", DataType.IntegerFact); p.AddCell(p1); p.AddCell(p1); p.AddCell(p1); p.AddCell(p1); p.AddCell(p1); p.AddCell(p1); p.AddCell(p1); p.AddCell(p1); List<Column> mylist = new List<Column>(); //mylist.Add(c); mylist.Add(s); mylist.Add(l); mylist.Add(p); Table first_table = new Table("Dane1", null, mylist); //Console.WriteLine(first_table); first_table.print(); // ------------------------ SECOND TABLE -------------------------------------- Cell s11 = new Cell("Berlin"); Cell s21 = new Cell("Kolonia"); Cell s31 = new Cell("Hamburg"); Cell l11 = new Cell(70.5); Cell l21 = new Cell(65); Cell l31 = new Cell((double)15); Column ss = new Column("Miasto", DataType.StringDimension); ss.AddCell(s11); ss.AddCell(s21); ss.AddCell(s31); Column ll = new Column("Sprzedaż", DataType.FloatFact); ll.AddCell(l11); ll.AddCell(l21); ll.AddCell(l31); Column pp = new Column("Coś", DataType.IntegerFact); pp.AddCell(p1); pp.AddCell(p1); pp.AddCell(p1); List<Column> mylist1 = new List<Column>(); mylist1.Add(ss); mylist1.Add(ll); mylist1.Add(pp); Table second_table = new Table("Dane2", null, mylist1); // ------------------------ TABLE -------------------------------------------- mylist = new List<Column>(); mylist.Add(c); mylist.Add(s); mylist.Add(l); mylist.Add(p); Table second = new Table("Tabeleczka", null, mylist); //Console.WriteLine(second); second.print(); // ------------------------ GROUP COMMAND ----------------------------------- Dictionary<Column, Aggregation> dict = new Dictionary<Column, Aggregation>(); dict.Add(l, new AverageAggregation()); dict.Add(p, new SumAggregation()); Command cmd = new GroupCommand(new List<Column> { s }, dict); first_table.Execute(cmd).print(); //Console.WriteLine(first_table.Execute(cmd)); dict[l] = new CountAggregation(); //Console.WriteLine(first_table.Execute(cmd)); first_table.Execute(cmd).print(); dict = new Dictionary<Column, Aggregation>(); dict.Add(l, new AverageAggregation()); dict.Add(p, new SumAggregation()); cmd = new GroupCommand(new List<Column> { c, s }, dict); //Console.WriteLine(second.Execute(cmd)); second.Execute(cmd).print(); //------------------------- OTHER COMMANDS ----------------------------------- first_table.Execute(new SelectCommand(new List<int> { 0 })).print(); first_table.Execute(new SelectCommand(new List<int> { 1 })).print(); first_table.Execute(new FilterCommand(first_table.Columns[1], cellContent => (double)cellContent > 20)).print(); first_table.Execute(new ComputationOfTwoColumnsCommand(first_table.Columns[1], first_table.Columns[2], (cellContent, cell2Content) => (double)cellContent + (double)cell2Content)).print(); Table result = first_table.Execute(new ComputationOfOneColumnCommand(first_table.Columns[1], cellContent => (double)cellContent * 2)); Table modified = new Table(result.Name, first_table, result.Columns); modified.print(); modified.Undo().print(); first_table.Execute(new VerticalJoinCommand(second_table)).print(); // ------------------------ AGGREGATION TESTS --------------------------------------- List<Cell> cells = new List<Cell>(); cells.Add(l11); cells.Add(l21); cells.Add(l31); Console.WriteLine((double)(new SumAggregation()).GetAggregatedValue(cells)); Console.WriteLine((double)(new MaxAggregation()).GetAggregatedValue(cells)); Console.WriteLine((int)(new CountAggregation()).GetAggregatedValue(cells)); Console.WriteLine((double)(new MinAggregation()).GetAggregatedValue(cells)); Console.WriteLine((double)(new AverageAggregation()).GetAggregatedValue(cells)); Console.ReadKey(); }
public void ExecuteTest() { var cell1 = new Mock<Cell>(); var cell2 = new Mock<Cell>(); var cell3 = new Mock<Cell>(); cell1.Setup(foo => foo.Content).Returns("2011"); cell2.Setup(foo => foo.Content).Returns("2011"); cell3.Setup(foo => foo.Content).Returns("2012"); var cell4 = new Mock<Cell>(); var cell5 = new Mock<Cell>(); var cell6 = new Mock<Cell>(); cell4.Setup(foo => foo.Content).Returns(7); cell5.Setup(foo => foo.Content).Returns(8); cell6.Setup(foo => foo.Content).Returns(9); List<Cell> cells1 = new List<Cell>(); List<Cell> cells2 = new List<Cell>(); cells1.Add(cell1.Object); cells1.Add(cell2.Object); cells1.Add(cell3.Object); cells2.Add(cell4.Object); cells2.Add(cell5.Object); cells2.Add(cell6.Object); var column1 = new Mock<Column>(); var column2 = new Mock<Column>(); column1.Setup(foo => foo.Cells).Returns(cells1); column1.Setup(foo => foo.Type).Returns(DataType.DateDimension); column2.Setup(foo => foo.Cells).Returns(cells2); column2.Setup(foo => foo.Type).Returns(DataType.FloatFact); List<Column> columns = new List<Column>(); columns.Add(column1.Object); columns.Add(column2.Object); var table = new Mock<Table>(); table.Setup(foo => foo.Columns).Returns(columns); var agg = new Mock<Aggregation>(); agg.Setup(foo => foo.GetAggregatedValue(It.IsAny<List<Cell>>())).Returns(5.0); Dictionary<Column, Aggregation> dict = new Dictionary<Column, Aggregation>(); dict.Add(column2.Object, agg.Object); List<Column> gColumn = new List<Column>(); gColumn.Add(column1.Object); Command cmd = new GroupCommand(gColumn, dict); var result = cmd.Execute(table.Object); //czego oczekujemy var column3 = new Mock<Column>(); var column4 = new Mock<Column>(); List<Cell> cells3 = new List<Cell>(); cells3.Add(cell1.Object); cells3.Add(cell3.Object); var cellAgg = new Mock<Cell>(); cellAgg.Setup(foo => foo.Content).Returns(5.0); List<Cell> cells4 = new List<Cell>(); cells4.Add(cellAgg.Object); cells4.Add(cellAgg.Object); column3.Setup(foo => foo.Cells).Returns(cells3); column4.Setup(foo => foo.Cells).Returns(cells4); List<Column> columns3 = new List<Column>(); columns3.Add(column3.Object); columns3.Add(column4.Object); var expected = new Mock<Table>(); expected.Setup(foo => foo.Columns).Returns(columns3); //czy takie same int n = expected.Object.Columns.Count; int m = result.Columns.Count; Assert.AreEqual(n, m); for (int i = 0; i < n; i++) { int k = result.Columns[i].Cells.Count; int l = expected.Object.Columns[i].Cells.Count; Assert.AreEqual(k, l); for (int j = 0; j < k; j++) { Assert.AreEqual(expected.Object.Columns[i].Cells[j].Content, result.Columns[i].Cells[j].Content); } } }
public static GroupCommand <TKey, ReadableTuple <TKey> > Generate <TKey>(ReadableTuple <TKey> item, bool execute) { GroupCommand <TKey, ReadableTuple <TKey> > commands = GroupCommand <TKey, ReadableTuple <TKey> > .Make(); WebClient client = new WebClient(); byte[] data; try { data = client.DownloadData("https://www.divine-pride.net/database/monster/" + item.Key); } catch { return(null); } string content = Encoding.Default.GetString(data); int index = content.IndexOf("Drop chance", 0, System.StringComparison.Ordinal); if (index < 0) { return(null); } HashSet <int> used = new HashSet <int>(); var legentRestart = content.IndexOf("<legend>RE:Start</legend>", 0); while (true) { index = content.IndexOf(" ", index); if (index < -1) { break; } if (legentRestart > -1 && index > legentRestart) { break; } int start = index + " ".Length; int end = content.IndexOf("\r", start); index = end; string numberString = content.Substring(start, end - start); int nameid = 0; if (Int32.TryParse(numberString, out nameid)) { // find drop rate int spanStart = content.IndexOf("<span>", end) + "<span>".Length; int spanEnd = content.IndexOf("%", spanStart); string chanceString = content.Substring(spanStart, spanEnd - spanStart); decimal value = (decimal)FormatConverters.SingleConverter(chanceString); if (value > 0) { int chance = (int)((decimal)value * 100); bool found = false; int free = -1; for (int i = ServerMobAttributes.Drop1ID.Index; i <= ServerMobAttributes.DropCardid.Index; i += 2) { if (used.Contains(i)) { continue; } int nameidSource = item.GetValue <int>(i); int chanceSource = item.GetValue <int>(i + 1); if (nameidSource == 0 && free == -1) { free = i; } if (nameidSource != nameid) { continue; } found = true; used.Add(i); if (chanceSource == chance) { break; } commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ServerMobAttributes.AttributeList.Attributes[i + 1], chance)); break; } if (!found) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ServerMobAttributes.AttributeList.Attributes[free], nameid)); commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ServerMobAttributes.AttributeList.Attributes[free + 1], chance)); used.Add(free); } } } else { break; } } { //string content = Encoding.Default.GetString(data); int start = 0; int end = 0; int atk1 = 0; int atk2 = 0; int matk1 = 0; int matk2 = 0; int level = item.GetValue <int>(ServerMobAttributes.Lv); int strStat = item.GetValue <int>(ServerMobAttributes.Str); int intStat = item.GetValue <int>(ServerMobAttributes.Int); if (!MoveTo(content, "<td class=\"right\">", ref start, ref end)) // mob id { return(null); } MoveForward(ref start, ref end); try { if (MoveTo(content, "<td class=\"right\">", ref start, ref end)) { // mob level level = ReadInteger(content, ref end); commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ServerMobAttributes.Lv, level)); } MoveForward(ref start, ref end); if (MoveTo(content, "<td class=\"right\">", ref start, ref end)) { // HP //commands.Add(new ChangeTupleProperty<TKey, ReadableTuple<TKey>>(item, ServerMobAttributes.Lv, ReadInteger(content, ref end))); } MoveForward(ref start, ref end); if (MoveTo(content, "<td class=\"right\">", ref start, ref end)) { // Attack string span = ReadSpan(content, ref start, ref end); span = span.Replace(",", "").Replace(" ", ""); string[] dataAtk = span.Split('-'); atk1 = Int32.Parse(dataAtk[0]); atk2 = Int32.Parse(dataAtk[1]); } MoveForward(ref start, ref end); if (MoveTo(content, "<td class=\"right\">", ref start, ref end)) { // Magic attack string span = ReadSpan(content, ref start, ref end); span = span.Replace(",", "").Replace(" ", ""); string[] dataAtk = span.Split('-'); matk1 = Int32.Parse(dataAtk[0]); matk2 = Int32.Parse(dataAtk[1]); } MoveForward(ref start, ref end); if (MoveTo(content, "<td class=\"right\">", ref start, ref end)) { // Speed } MoveForward(ref start, ref end); if (MoveTo(content, "<td class=\"right\">", ref start, ref end)) { // Range } MoveForward(ref start, ref end); if (MoveTo(content, "<td class=\"right\">", ref start, ref end)) { // Hit } MoveForward(ref start, ref end); if (MoveTo(content, "<td class=\"right\">", ref start, ref end)) { // Flee } MoveForward(ref start, ref end); if (MoveTo(content, "<td class=\"right\">", ref start, ref end)) { // Def commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ServerMobAttributes.Def, ReadInteger(content, ref end))); } MoveForward(ref start, ref end); if (MoveTo(content, "<td class=\"right\">", ref start, ref end)) { // Mdef commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ServerMobAttributes.Mdef, ReadInteger(content, ref end))); } MoveForward(ref start, ref end); if (MoveTo(content, "<td class=\"right\">", ref start, ref end)) { // Str strStat = ReadInteger(content, ref end); commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ServerMobAttributes.Str, strStat)); } MoveForward(ref start, ref end); if (MoveTo(content, "<td class=\"right\">", ref start, ref end)) { // Agi commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ServerMobAttributes.Agi, ReadInteger(content, ref end))); } MoveForward(ref start, ref end); if (MoveTo(content, "<td class=\"right\">", ref start, ref end)) { // Vit commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ServerMobAttributes.Vit, ReadInteger(content, ref end))); } MoveForward(ref start, ref end); if (MoveTo(content, "<td class=\"right\">", ref start, ref end)) { // Int intStat = ReadInteger(content, ref end); commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ServerMobAttributes.Int, intStat)); } MoveForward(ref start, ref end); if (MoveTo(content, "<td class=\"right\">", ref start, ref end)) { // Dex commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ServerMobAttributes.Dex, ReadInteger(content, ref end))); } MoveForward(ref start, ref end); if (MoveTo(content, "<td class=\"right\">", ref start, ref end)) { // Luk commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ServerMobAttributes.Luk, ReadInteger(content, ref end))); } MoveForward(ref start, ref end); atk1 = (atk2 + atk1) / 2 - strStat - level; matk1 = (matk1 + matk2) / 2 - intStat - level; int v1 = Math.Abs(item.GetValue <int>(ServerMobAttributes.Atk1) - atk1); int v2 = Math.Abs((item.GetValue <int>(ServerMobAttributes.Atk2) - item.GetValue <int>(ServerMobAttributes.Atk1)) - matk1); if (!execute) { if (v1 > 1 || v2 > 1) { Console.WriteLine("Invalid atk/matk for " + item.Key); } return(null); } if (level > 0) { // Look up experience start = content.IndexOf("id=\"experience\"", System.StringComparison.Ordinal); int tbStart = content.IndexOf("<tbody>", index); int tbEnd = content.IndexOf("</tbody>", tbStart); while (end < tbEnd) { if (MoveTo(content, "<td class=\"right\">", ref start, ref end)) { int lv = ReadInteger(content, ref end); MoveForward(ref start, ref end); if (lv == level) { MoveTo(content, "<td class=\"right\">", ref start, ref end); MoveForward(ref start, ref end); MoveTo(content, "<td class=\"right\">", ref start, ref end); int baseExp = ReadInteger(content, ref end); MoveForward(ref start, ref end); MoveTo(content, "<td class=\"right\">", ref start, ref end); int jobExp = ReadInteger(content, ref end); MoveForward(ref start, ref end); commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ServerMobAttributes.Exp, baseExp)); commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ServerMobAttributes.JExp, jobExp)); break; } else { MoveTo(content, "<td class=\"right\">", ref start, ref end); MoveForward(ref start, ref end); MoveTo(content, "<td class=\"right\">", ref start, ref end); MoveForward(ref start, ref end); MoveTo(content, "<td class=\"right\">", ref start, ref end); MoveForward(ref start, ref end); } } else { MoveForward(ref start, ref end); } } } commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ServerMobAttributes.Atk1, atk1)); commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ServerMobAttributes.Atk2, atk1 + matk1)); } catch { return(null); } } //while (true) { // index = content.IndexOf(" ", index); // // if (index < -1) // break; // // int start = index + " ".Length; // int end = content.IndexOf("\r", start); // index = end; // // string numberString = content.Substring(start, end - start); // // int nameid = 0; // // if (Int32.TryParse(numberString, out nameid)) { // // find drop rate // int spanStart = content.IndexOf("<span>", end) + "<span>".Length; // int spanEnd = content.IndexOf("%", spanStart); // // string chanceString = content.Substring(spanStart, spanEnd - spanStart); // // decimal value = (decimal)FormatConverters.SingleConverter(chanceString); // // if (value > 0) { // int chance = (int)((decimal)value * 100); // bool found = false; // int free = -1; // // for (int i = ServerMobAttributes.Drop1ID.Index; i <= ServerMobAttributes.DropCardid.Index; i += 2) { // if (used.Contains(i)) // continue; // // int nameidSource = item.GetValue<int>(i); // int chanceSource = item.GetValue<int>(i + 1); // // if (nameidSource == 0 && free == -1) { // free = i; // } // // if (nameidSource != nameid) // continue; // // found = true; // used.Add(i); // // if (chanceSource == chance) // break; // // commands.Add(new ChangeTupleProperty<TKey, ReadableTuple<TKey>>(item, ServerMobAttributes.AttributeList.Attributes[i + 1], chance)); // break; // } // // if (!found) { // commands.Add(new ChangeTupleProperty<TKey, ReadableTuple<TKey>>(item, ServerMobAttributes.AttributeList.Attributes[free], nameid)); // commands.Add(new ChangeTupleProperty<TKey, ReadableTuple<TKey>>(item, ServerMobAttributes.AttributeList.Attributes[free + 1], chance)); // } // } // } // else { // break; // } //} if (commands.Commands.Count == 0) { return(null); } return(commands); }
void OnGroupBy(GroupCommand c) { lastGroupCommand = c; Fill (); }
public static GroupCommand <TKey, ReadableTuple <TKey> > GeneratekRO <TKey>(ReadableTuple <TKey> item) { GroupCommand <TKey, ReadableTuple <TKey> > commands = GroupCommand <TKey, ReadableTuple <TKey> > .Make(); WebClient client = new WebClient(); byte[] data; try { string sprite = item.GetValue <string>(ServerMobAttributes.AegisName); if (String.IsNullOrEmpty(sprite)) { sprite = item.GetValue <string>(ServerMobAttributes.ClientSprite); } data = client.DownloadData("http://ro.gnjoy.com/guide/runemidgarts/popup/monsterview.asp?monsterID=" + sprite); } catch { return(null); } string content = EncodingService.Ansi.GetString(data); int index = content.IndexOf("몬스터 ìƒì„¸", 0, System.StringComparison.Ordinal); if (index < 0) { return(null); } string value; if ((value = _fetch(content, "ê³µê²©ë ¥")) != null) { value = value.Replace(",", "").Replace(" ", ""); string[] minmax = value.Split('~'); commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ServerMobAttributes.Atk1, minmax[0])); commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ServerMobAttributes.Atk2, minmax[1])); } if ((value = _fetch(content, "ë ˆë²¨")) != null) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ServerMobAttributes.Lv, Int32.Parse(value))); } if ((value = _fetch(content, "ë°©ì–´ë ¥")) != null) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ServerMobAttributes.Def, Int32.Parse(value.Replace(",", "")))); } if ((value = _fetch(content, "ë§ˆë²•ë°©ì–´ë ¥")) != null) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ServerMobAttributes.Mdef, Int32.Parse(value.Replace(",", "")))); } if ((value = _fetch(content, "STR")) != null) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ServerMobAttributes.Str, Int32.Parse(value.Replace(",", "")))); } if ((value = _fetch(content, "DEX")) != null) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ServerMobAttributes.Dex, Int32.Parse(value.Replace(",", "")))); } if ((value = _fetch(content, "AGI")) != null) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ServerMobAttributes.Agi, Int32.Parse(value.Replace(",", "")))); } if ((value = _fetch(content, "VIT")) != null) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ServerMobAttributes.Vit, Int32.Parse(value.Replace(",", "")))); } if ((value = _fetch(content, "INT")) != null) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ServerMobAttributes.Int, Int32.Parse(value.Replace(",", "")))); } if ((value = _fetch(content, "LUK")) != null) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ServerMobAttributes.Luk, Int32.Parse(value.Replace(",", "")))); } if ((value = _fetch(content, "경험치")) != null) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ServerMobAttributes.Exp, Int32.Parse(value.Replace(",", "")))); } if ((value = _fetch(content, "JOB 경험치")) != null) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ServerMobAttributes.JExp, Int32.Parse(value.Replace(",", "")))); } if (commands.Commands.Count == 0) { return(null); } return(commands); }
public override void KeyDown(object sender, KeyEventArgs e, Panel panel1) { //System.Diagnostics.Debug.WriteLine(e.KeyCode.ToString() + " Pencet."); if (e.KeyCode == Keys.Delete && objectSelected != null) { DeleteCommand deleteCommand = new DeleteCommand(objectSelected); deleteCommand.ParentForm = ParentForm; ParentForm.Add_Command(deleteCommand); ParentForm.Remove_Object(objectSelected); objectSelected = null; //System.Diagnostics.Debug.WriteLine(e.KeyCode.ToString() + " Oke."); } else if (e.Control && e.KeyCode == Keys.G && ObjectGroup.Any() && banyakObject() > 1) { GroupObject groupObject = new GroupObject(); groupObject.setGraphics(panel1.CreateGraphics()); groupObject.AddChild(ObjectGroup); GroupCommand groupCommand = new GroupCommand(groupObject); groupCommand.ObjectGroup = ObjectGroup; groupCommand.ParentForm = ParentForm; ParentForm.Add_Command(groupCommand); foreach (AObject aObject in ObjectGroup) { aObject.Deselect(); ParentForm.Remove_Object(aObject); } groupObject.Deselect(); ParentForm.Add_Object(groupObject); ObjectGroup = new LinkedList <AObject>(); controlClick = false; //groupObject.Draw(); //panel1.Invalidate(); //panel1.Refresh(); } else if (e.Control && e.Shift && e.KeyCode == Keys.G && objectSelected != null) { LinkedList <AObject> child = objectSelected.RemoveChild(); UngroupCommand ungroupCommand = new UngroupCommand(objectSelected); ungroupCommand.ObjectGroup = child; ungroupCommand.ParentForm = ParentForm; ParentForm.Add_Command(ungroupCommand); ParentForm.Remove_Object(objectSelected); foreach (AObject aObject in child) { ParentForm.Add_Object(aObject); } objectSelected = null; panel1.Refresh(); panel1.Invalidate(); } else if (e.Control) { //System.Diagnostics.Debug.WriteLine(e.KeyCode.ToString() + " Control Saja."); controlClick = true; } }
private void RefreshCommands() { GroupCommand.Refresh(); UnGroupCommand.Refresh(); }
void OnGroupBy(GroupCommand c) { lastGroupCommand = c; Fill(); }
protected override void AttackEnd() { base.AttackEnd(); GroupCommand.NoticeEnemiesGroupEnd(); }
static void Init() { GroupCommand window = (GroupCommand)EditorWindow.GetWindow(typeof(GroupCommand)); window.Show(); }
public static GroupCommand <TKey, ReadableTuple <TKey> > Generate <TKey>(ReadableTuple <TKey> clientTuple, ReadableTuple <int> serverTuple, bool autoComplete = false) { GroupCommand <TKey, ReadableTuple <TKey> > commands = GroupCommand <TKey, ReadableTuple <TKey> > .Make(); if (autoComplete || ProjectConfiguration.AutocompleteRewardId) { int idC = clientTuple.GetValue <int>(ClientCheevoAttributes.RewardId); int idS = serverTuple.GetValue <int>(ServerCheevoAttributes.RewardId); if (idC != idS) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(clientTuple, ClientCheevoAttributes.RewardId, idS)); } } if (autoComplete || ProjectConfiguration.AutocompleteTitleId) { int idC = clientTuple.GetValue <int>(ClientCheevoAttributes.RewardTitleId); int idS = serverTuple.GetValue <int>(ServerCheevoAttributes.RewardTitleId); if (idC != idS) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(clientTuple, ClientCheevoAttributes.RewardTitleId, idS)); } } if (autoComplete || ProjectConfiguration.AutocompleteScore) { int idC = clientTuple.GetValue <int>(ClientCheevoAttributes.Score); int idS = serverTuple.GetValue <int>(ServerCheevoAttributes.Score); if (idC != idS) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(clientTuple, ClientCheevoAttributes.Score, idS)); } } if (autoComplete || ProjectConfiguration.AutocompleteName) { string idC = clientTuple.GetValue <string>(ClientCheevoAttributes.Name); string idS = serverTuple.GetValue <string>(ServerCheevoAttributes.Name); if (idC != idS) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(clientTuple, ClientCheevoAttributes.Name, idS)); } } if (autoComplete) { string idC = clientTuple.GetValue <string>(ClientCheevoAttributes.GroupId); string idS = serverTuple.GetValue <string>(ServerCheevoAttributes.GroupId); if (idC != idS) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(clientTuple, ClientCheevoAttributes.GroupId, idS.Replace("AG_", ""))); } } if (autoComplete) { string name = serverTuple.GetValue <string>(ServerCheevoAttributes.Name); commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(clientTuple, ClientCheevoAttributes.Summary, name)); commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(clientTuple, ClientCheevoAttributes.Details, name)); commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(clientTuple, ClientCheevoAttributes.Major, "0")); commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(clientTuple, ClientCheevoAttributes.Minor, "0")); int total = 0; for (int i = 0; i < 5; i++) { total += serverTuple.GetValue <int>(ServerCheevoAttributes.TargetCount1.Index + 2 * i); } if (total > 0) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(clientTuple, ClientCheevoAttributes.UiType, "1")); CheevoResource resource = new CheevoResource(""); for (int i = 0; i < 5; i++) { int count = serverTuple.GetValue <int>(ServerCheevoAttributes.TargetCount1.Index + 2 * i); int targetId = serverTuple.GetValue <int>(ServerCheevoAttributes.TargetId1.Index + 2 * i); if (count > 0) { string text = "Task " + (i + 1); if (targetId > 0) { var table = SdeEditor.Instance.ProjectDatabase.GetMetaTable <int>(ServerDbs.Mobs); var tuple = table.TryGetTuple(targetId); if (tuple != null) { string mobName = tuple.GetValue <string>(ServerMobAttributes.IRoName); text = "Defeat " + mobName + " " + (count == 1 ? "once!" : count + " times!"); } } resource.Items.Add(new CheevoResourceItem { Id = i + 1, Count = count, Text = text }); } } commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(clientTuple, ClientCheevoAttributes.Resources, resource.GetData())); } } if (autoComplete) { } else if (ProjectConfiguration.AutocompleteCount) { int uiType = clientTuple.GetValue <int>(ClientCheevoAttributes.UiType); string group = serverTuple.GetValue <string>(ServerCheevoAttributes.GroupId); if (uiType == 1 && group != "AG_SPEND_ZENY") { string oldData = clientTuple.GetValue <string>(ClientCheevoAttributes.Resources); CheevoResource resource = new CheevoResource(oldData); for (int i = 0; i < 5; i++) { int targetCount = serverTuple.GetValue <int>(ServerCheevoAttributes.TargetCount1.Index + 2 * i); if (i < resource.Items.Count && targetCount != resource.Items[i].Count) { if (resource.Items[i].Text.Contains(resource.Items[i].Count.ToString(CultureInfo.InvariantCulture))) { resource.Items[i].Text = resource.Items[i].Text.Replace(resource.Items[i].Count.ToString(CultureInfo.InvariantCulture), targetCount.ToString(CultureInfo.InvariantCulture)); } resource.Items[i].Count = targetCount; } } if (oldData != resource.ToString()) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(clientTuple, ClientCheevoAttributes.Resources, resource.GetData())); } } } //if (ProjectConfiguration.AutocompleteBuff) { // int rewardIdC = clientTuple.GetValue<int>(ClientCheevoAttributes.RewardId); // int rewardIdS = serverTuple.GetValue<int>(ServerCheevoAttributes.RewardId); // // if (rewardIdC != rewardIdS) { // commands.Add(new ChangeTupleProperty<TKey, ReadableTuple<TKey>>(clientTuple, ClientItemAttributes.NumberOfSlots, rewardIdS)); // } //} if (commands.Commands.Count == 0) { return(null); } return(commands); }