private void OnChoiceDate() { ActionHistory.Add(new LeisureAction { Kind = LeisureKind.Date, Turn = Turn }); Update(); }
private void OnChoiceWiseFailer() { ActionHistory.Add(new TrainingAction { Kind = TrainingKind.Wise, Turn = Turn, Result = TrainingResult.Failed, IsFriendlyTag = false }); Update(); }
private void OnChoiceHoliday() { ActionHistory.Add(new LeisureAction { Kind = LeisureKind.Holiday, Turn = Turn }); Update(); }
private void OnChoiceGutsSuccess() { ActionHistory.Add(new TrainingAction { Kind = TrainingKind.Guts, Turn = Turn, Result = TrainingResult.Success, IsFriendlyTag = false }); Update(); }
private void OnChoiceWiseFriendly() { ActionHistory.Add(new TrainingAction { Kind = TrainingKind.Wise, Turn = Turn, Result = TrainingResult.Success, IsFriendlyTag = true }); Update(); }
private void OnChoiceDebut() { ActionHistory.Add(new RaceAction { RaceGrade = RaceGrade.Debut, Turn = Turn }); Update(); }
private void OnChoiceOpen() { ActionHistory.Add(new RaceAction { RaceGrade = RaceGrade.Open, Turn = Turn }); Update(); }
private void OnChoiceURA() { ActionHistory.Add(new RaceAction { RaceGrade = RaceGrade.URA, Turn = Turn }); Update(); }
private void OnChoiceInfirmary() { ActionHistory.Add(new LeisureAction { Kind = LeisureKind.Infirmary, Turn = Turn }); Update(); }
public void SpawnChaser() { GameObject chaser = Instantiate(chaserObject, spawnPosition, Quaternion.identity) as GameObject; chaser.transform.parent = gameObject.transform.parent; ChaserMovement chaserMovement = chaser.GetComponent <ChaserMovement>(); if (chaserMovement == null) { return; } if (actionHistory == null) { Movement movement = gameObject.GetComponent <Movement>(); if (movement != null) { actionHistory = movement.actionHistory; } } //#! if (chaserMovement is MonkeyMovement) { (chaserMovement as MonkeyMovement).target = gameObject; } else { chaserMovement.targetActions = actionHistory.GetEnumaration(); } }
public static void Main(string[] args) { var gameOutput = new ConsoleOutput(); var playerInput = new ConsoleInput(gameOutput); var random = new Random(); var actionHistory = new ActionHistory(); gameOutput.ShowMessage("Welcome to the Console Battle System!"); var playAgain = true; while (playAgain) { new TurnBasedBattle( new MoveProcessor(), actionHistory, gameOutput, CreateCharacters(random, actionHistory, playerInput) ).Start(); var playAgainChoice = playerInput.SelectChoice("Play again? [y/n]", "y", "n"); playAgain = playAgainChoice == "y"; } playerInput.Confirm("Thanks for playing! Press any key to exit."); }
public static void PuzzleInit(int size = 3, int puzzleNumber = 0) { InitIconSets(); if (Puzzle == null) { History = new ActionHistory(); PuzzleSize = size; Puzzle = new LogicMatrix.Puzzle(puzzleNumber, PuzzleSize, 1); // Choose icon sets string[] puzzleIconSets = new string[PuzzleSize]; List <string> availableSets = new List <string>(IconSets); for (int i = 0; i < PuzzleSize; i++) { int selection = Random.Range(0, availableSets.Count); puzzleIconSets[i] = availableSets[selection]; availableSets.RemoveAt(selection); } // Load icon sets PuzzleIcons = new Sprite[PuzzleSize][]; for (int i = 0; i < PuzzleSize; i++) { PuzzleIcons[i] = Resources.LoadAll <Sprite>(puzzleIconSets[i]); } } }
private List <Book> localBookDB; // for tracking changes public MainViewModel() { history = new ActionHistory(); NewBookCommand = new Command(NewBook); EditBookCommand = new Command(EditBook); DuplicateCommand = new Command <Book>(DuplicateBook, CanDuplicate); DeleteCommand = new Command(DeleteBook); RefreshCommand = new Command(RefreshList); LeaseCommand = new Command(LeaseBook, CanLease); SearchCommand = new Command(FilterBooks); UndoCommand = new Command(Undo, history.CanUndo); RedoCommand = new Command(Redo, history.CanRedo); using (var c = new WaitCursor()) { books = Session.Current.LibraryProxy.GetBooks(); localBookDB = new List <Book>(books); CollectionViewSource itemSourceList = new CollectionViewSource() { Source = books }; BookList = itemSourceList.View; } }
public void ExecuteAction() { if (_firstTriggered != null && (DateTime.UtcNow - TriggerPeriod) > _firstTriggered) { // make sure no recent action was taken on this foreach (var actionItem in ActionHistory) { if (actionItem.TriggerItem.Application.Properties.ApplicationName == _triggeringItem.Application.Properties.ApplicationName && actionItem.TriggerItem.Service.Properties.ServiceName == _triggeringItem.Service.Properties.ServiceName && (DateTime.UtcNow - ActionGracePeriod) < actionItem.TimeTriggeredUtc) { // we should do any new action yet - we have a grace period return; } } TriggerAction.Execute(_triggeringItem); WatchdogEventSource.Current.ActionFired(TriggerAction.GetType().FullName, this.ToString(_triggeringItem), _triggeringItem.ToString()); ActionHistory.Add(new RuleActionItem() { TimeTriggeredUtc = DateTime.UtcNow, TriggerItem = _triggeringItem, TriggerAction = TriggerAction }); } }
public void GetMoveConsecutiveSuccessCount_WithFailure_ReturnsCount() { // Arrange var user = TestHelpers.CreateBasicCharacter(); var move = TestHelpers.CreateMove(); var actionHistory = new ActionHistory(); var successMoveUse = new MoveUse { User = user, Move = move, Result = MoveUseResult.Success, }; var failureMoveUse = new MoveUse { User = user, Move = move, Result = MoveUseResult.Failure, }; actionHistory.AddMoveUse(successMoveUse); actionHistory.AddMoveUse(failureMoveUse); actionHistory.AddMoveUse(successMoveUse); actionHistory.AddMoveUse(successMoveUse); // Act var count = actionHistory.GetMoveConsecutiveSuccessCount(move, user); // Assert Assert.That(count, Is.EqualTo(2)); }
/* Helper methods */ void AddGhost(int turnDelay) { ActionHistory actionHistory = player.GetComponent <Movement>().actionHistory.Clone(); Vector3 spawnPoint = playerSpawns.Current; ghostData.Add(new GhostInfo(turnDelay, spawnPoint, actionHistory)); }
// Chart should be part of the current song public void LoadChart(Chart chart) { actionHistory = new ActionHistory(); Stop(); currentChart = chart; songObjectPoolManager.NewChartReset(); }
private void PushCommandToHistory(IHistoryCommand command) { ActionHistory.Push(command); //command.Do(); //commandStack[currentCommand] = (command); //currentCommand++; //commandRedoStack.Clear(); }
public void AddAction_ItemSource_AddsAction() { // Arrange var result = new DamageActionResult <Item>(); var actionHistory = new ActionHistory(); // Act actionHistory.AddAction(result); // Assert Assert.That(actionHistory.ItemActions, Contains.Item((0, result))); }
public async Task <Resource> ExecuteRecipe(string recipeName) { var recipe = await _recipeRepository.GetRecipeByName(recipeName); ActionHistory history = new ActionHistory { Description = "Ein Fehler", CreationDate = DateTime.Now }; if (recipe == null) { throw new Exception("Recipe not found: " + recipe); } foreach (var incrediant in recipe.Incrediants) { var resource = await _resourceRepository.GetResourceByProductName(incrediant.ProductName); if (resource == null) { throw new Exception("resource of product not found: " + incrediant.ProductName); } if (resource.Amount - incrediant.Amount < 0) { throw new Exception("To little amount of: " + resource.ProductName); } resource.Amount -= incrediant.Amount; history = new ActionHistory { Description = "Execute Recipe: " + recipeName, CreationDate = DateTime.Now }; resource.ActionHistories.Add(history); await _resourceRepository.UpdateEntity(resource); } var toUpdateResource = await _resourceRepository.GetResourceByProductName(recipe.Endproduct.Name); if (toUpdateResource == null) { throw new Exception("Resource of Endproduct not found: " + recipe.Endproduct.Name); } toUpdateResource.Amount += 1; await _historyRepository.AddEntity(history); return(await _resourceRepository.UpdateEntity(toUpdateResource)); }
public void AddAction_OtherSource_AddsAction() { // Arrange var actionHistory = new ActionHistory(); // Act var result = new DamageActionResult <Move>(); actionHistory.AddAction(result); // Assert Assert.That(actionHistory.ItemActions, new NotConstraint(Contains.Item(result))); }
private void OnLoad() { var openFileDialog = new OpenFileDialog(); openFileDialog.Multiselect = false; if (openFileDialog.ShowDialog() ?? false) { using (var ofs = new StreamReader(openFileDialog.FileName, Encoding.UTF8)) { var json = ofs.ReadToEnd(); ActionHistory.LoadFromJsonSting(json); Update(); } } }
public async Task <IActionResult> Update(ActionHistory update) { // for a real app it would be a good idea to configure model validation to remove long ifs like this if (string.IsNullOrWhiteSpace(update.Description)) { return(BadRequest()); } using var transaction = await this._transactionProvider.BeginTransaction(); var entity = await this._service.UpdateEntity(update); await transaction.CommitAsync(); return(CreatedAtAction(nameof(GetById), new { id = entity.Id.ToString() }, entity)); }
/// <summary> /// Is the foe in cooldown ? /// </summary> /// <param name="lastAction">The last action done</param> /// <param name="gameSpeed">the game speed</param> /// <returns>true if in cooldown, false otherwise</returns> private static bool IsInCooldown(ActionHistory lastAction, int gameSpeed) { switch (lastAction.Action.Name) { case HIT: case THRUST: case HEAL: return((lastAction.Action.CoolDown * gameSpeed) - lastAction.Age <= 0); case SHIELD: return(lastAction.Age < 500); default: return(false); } }
private void OnSave() { var saveFileDialog = new SaveFileDialog(); saveFileDialog.FileName = $@"{DateTime.Now.ToString("yyyyMMdd")}"; saveFileDialog.AddExtension = true; saveFileDialog.DefaultExt = "json"; saveFileDialog.Filter = "JSONファイル|*.json"; saveFileDialog.InitialDirectory = Directory.GetParent(Assembly.GetExecutingAssembly().Location).ToString(); if (saveFileDialog.ShowDialog() ?? false) { using (var ofs = new StreamWriter(saveFileDialog.FileName, false, Encoding.UTF8)) { ofs.Write(ActionHistory.GetJson()); } } }
private void MenuItemShowProperties_Click(object sender, RoutedEventArgs e) { //MessageBox.Show("Not implemented!", "Notice", MessageBoxButton.OK, MessageBoxImage.Asterisk); var window = new TablePropertiesWindow(); window.SetTarget(this); window.RowCount = RowCount; window.RowHeight = RowHeight; GridLength col0Width = TableGrid.ColumnDefinitions[0].Width, col1Width = TableGrid.ColumnDefinitions[1].Width, col2Width = TableGrid.ColumnDefinitions[2].Width; if (window.ShowDialog() == true) { ActionHistory.Push(new TablePropertiesCommand(this)); Canvas.SetLeft(this, window.Vector2DPosition.ValueInPixel.X); Canvas.SetTop(this, window.Vector2DPosition.ValueInPixel.Y); //SpanContent.Text = window.TextCaption; RowCount = window.RowCount; RowHeight = window.RowHeight; XlsColumn = (string)window.XLSColumn.XLSColumsList.SelectedValue; SpanFontFamily = window.FontChooser.SelectedFontFamily; SpanFontSize = Helper.ToEmSize(window.FontChooser.SelectedFontSize, MainWindow.DpiY); SpanFontWeight = window.FontChooser.SelectedFontWeight; SpanFontStyle = window.FontChooser.SelectedFontStyle; TextFontFamily = window.FontChooser2.SelectedFontFamily; TextFontSize = Helper.ToEmSize(window.FontChooser2.SelectedFontSize, MainWindow.DpiY); TextFontWeight = window.FontChooser2.SelectedFontWeight; TextFontStyle = window.FontChooser2.SelectedFontStyle; TableGrid.Children.Clear(); TableGrid.ColumnDefinitions.Clear(); TableGrid.RowDefinitions.Clear(); UpdateTableDefinition(window.RowCount, window.RowHeight, col0Width, col1Width, col2Width); FillTable(); if (LayoutWindow.instance != null) { LayoutWindow.instance.IsChanged = true; } } }
private void DisableButton() { ActionHistory_Manage manage = new ActionHistory_Manage(); List <ActionHistory> lData = new List <ActionHistory>(); lData = manage.ListActionHistory(hdfEmployeeID.Value.Trim(), DateTime.Now.Year); if (lData != null && lData.Count > 0) { ActionHistory data = lData.Where(c => c.Responsibility == "Creator").FirstOrDefault(); lblCreator.Text = string.IsNullOrEmpty(data.CreatedBy) ? "(Creator)" : data.CreatedBy + " (Creator)"; btnSubmit.Visible = false; } else { lblCreator.Text = "(Creator)"; btnSubmit.Visible = true; } }
public void GetMoveActionConsecutiveSuccessCount_NoFailures_ReturnsCount() { // Arrange var user = TestHelpers.CreateBasicCharacter(); var action = TestHelpers.CreateDamageAction(); var actionHistory = new ActionHistory(); actionHistory.AddMoveUse(CreateMoveUse(action, user, true)); actionHistory.AddMoveUse(CreateMoveUse(action, user, true)); // Act var count = actionHistory.GetMoveActionConsecutiveSuccessCount(action, user); // Assert Assert.That(count, Is.EqualTo(2)); }
/// <summary> /// Sets up the editor when entering /// </summary> public void OnEnterEditor() { // Clear old stuff in the world foreach (Node node in world.GetChildren()) { node.Free(); } // Let go of old resources hoverHexes = new List <MeshInstance>(); hoverOrganelles = new List <SceneDisplayer>(); history = new ActionHistory <EditorAction>(); // Create new hover hexes. See the TODO comment in _Process // This seems really cluttered, there must be a better way. for (int i = 0; i < Constants.MAX_HOVER_HEXES; ++i) { hoverHexes.Add(CreateEditorHex()); } for (int i = 0; i < Constants.MAX_SYMMETRY; ++i) { hoverOrganelles.Add(CreateEditorOrganelle()); } // Start a new game if no game has been started if (CurrentGame == null) { if (ReturnToStage != null) { throw new Exception("stage to return to should have set our current game"); } GD.Print("Starting a new game for the microbe editor"); CurrentGame = GameProperties.StartNewMicrobeGame(); } InitEditor(); StartMusic(); }
public ActionHistory GetActionHistoryData(string EmployeeID) { ActionHistory retDet = new ActionHistory(); try { using (PerformanceAppraisalEntities entity = new PerformanceAppraisalEntities()) { var getData = (from r in entity.ActionHistories select r).Where(t => t.EmployeeID == EmployeeID).FirstOrDefault(); retDet = getData; } } catch (Exception ex) { logger.Error(ex.Message); logger.Error(ex.StackTrace); } return(retDet); }