public NoteRequest(PossibleActions action, Guid guid) : base(action, guid) { }
public DrinkerRequest(PossibleActions action, Guid guid) : base(action, guid) { }
public NoteCollectionRequest(PossibleActions action, Guid noteTakerGuid) : base(action, noteTakerGuid) { }
public BaseRequest(PossibleActions action, Guid noteTakerGuid) { _possibleAction = action; NoteTakerGuid = noteTakerGuid; }
public ExpenseRequest ConvertToNoteRequest(Guid userGuid, Guid collectionGuid, PossibleActions action, IEnumerable <ExpenseModel> notes) { return(new ExpenseRequest(action, userGuid) { Expenses = ConvertAllToNoteEntity(notes), ExpenseCollectionGuid = collectionGuid }); }
public DrinkerCycleRequest(PossibleActions action, Guid userGuid) : base(action, userGuid) { }
private async Task<bool> MakeRequest(string name, Guid userGuid, PossibleActions actionName, Guid? authGuid = null) { try { var res = await _dataService.PostDrinkerCycle(RequestConverter.Instance.ConvertToDrinkerCycleRequest(userGuid, actionName, name, authGuid)); return res.Response && res.IsSuccessfull; } catch (Exception ex) { LogHelper.Instance.LogException(ex, this); } return false; }
public static void PrintTileDirections(this PossibleActions action, string tile) { bool isRightSelected = false; bool isUpSelected = false; bool isLeftSelected = false; bool isDownSelected = false; string result = string.Empty; foreach (Action nextAction in action.PossibleMoveActions) { if (string.Compare(nextAction.Direction, MoveEnum.Right.ToString()) == 0) { isRightSelected = true; } if (string.Compare(nextAction.Direction, MoveEnum.Up.ToString()) == 0) { isUpSelected = true; } if (string.Compare(nextAction.Direction, MoveEnum.Left.ToString()) == 0) { isLeftSelected = true; } if (string.Compare(nextAction.Direction, MoveEnum.Down.ToString()) == 0) { isDownSelected = true; } } if (isUpSelected) { result += " |\n"; } if (isLeftSelected && isRightSelected) { result += $"-{tile}-\n"; } if (isLeftSelected && !isRightSelected) { result += $"-{tile}\n"; } if (!isLeftSelected && isRightSelected) { result += $" {tile}-\n"; } if (!isLeftSelected && !isRightSelected) { result += $" {tile}\n"; } if (isDownSelected) { result += " |\n"; } Console.WriteLine(result); }
private static async Task <int> PlayMaze(Maze maze) { int countCalls = 0; string tile; bool isCollected = false, isCollecting = false, isExiting = false; List <string> paths = new List <string>(), roadMap = new List <string>(); List <List <string> > pathsToExit = new List <List <string> >(); List <List <string> > pathsToCollect = new List <List <string> >(); PossibleActions action = await apiCall.EnterMaze(maze.Name);; if (action != null && action.PossibleMoveActions.Count == 0) { Console.WriteLine($"Error: cannot enter maze: {maze.Name}"); return(-1); } countCalls++; tile = TileEnum.S.ToString(); //action.PrintTileDirections(tile); paths.Add(tile); while (true) { if (action.CanCollectScoreHere && action.CurrentScoreInHand > 0 && action.CurrentScoreInHand == maze.PotentialReward) { isCollected = true; bool isCollectedInCall = await apiCall.CollectScore(); if (!isCollectedInCall) { Console.WriteLine($"Error: cannot collect score " + $"in maze {maze.Name}"); break; } countCalls++; } if (action.CanExitMazeHere && action.CurrentScoreInBag == maze.PotentialReward) { bool isExit = await apiCall.ExitMaze(); if (!isExit) { Console.WriteLine($"Error: cannot exit maze {maze.Name}"); } countCalls++; break; } List <string> temp = CheckCollectOrExit(maze, action, pathsToCollect, pathsToExit, isCollected, ref paths, ref isCollecting, ref isExiting); if ((isCollecting || isExiting) && temp.Count > 0) { roadMap = temp; } GetNextMove(action, paths, roadMap, out string move, out tile, out DirectionEnum direction); //Console.WriteLine($"\nmove: {move}\n"); //Console.WriteLine(string.Join(",", paths)); //action.PrintTileDirections(tile); if (direction.CompareTo(DirectionEnum.Down) == 0 && !isCollected) { AddCollectOrExit(paths, tile, pathsToCollect, pathsToExit); } if (direction.CompareTo(DirectionEnum.Up) == 0) { paths.RemoveAt(paths.Count - 1); paths.RemoveAt(paths.Count - 1); } action = await apiCall.NextMove(move); if (action.PossibleMoveActions.Count == 0) { Console.WriteLine($"Error: cannot move in maze"); break; } countCalls++; //Thread.Sleep(2000); } return(countCalls); }
private static void GetNextMove(PossibleActions action, List <string> paths, List <string> roadMap, out string move, out string tile, out DirectionEnum direction) { string tileRight = string.Empty, tileUp = string.Empty, tileLeft = string.Empty, tileDown = string.Empty; bool isRightAvailable = false, isUpAvailable = false, isLeftAvailable = false, isDownAvailable = false; bool hasRightReward = false, hasUpReward = false, hasLeftReward = false, hasDownReward = false; move = string.Empty; tile = string.Empty; if (roadMap.Count > 2) { direction = DirectionEnum.Collect; move = roadMap[1]; tile = roadMap[2]; roadMap.RemoveAt(0); roadMap.RemoveAt(0); return; } foreach (Action nextAction in action.PossibleMoveActions) { if (string.Compare(nextAction.Direction, MoveEnum.Right.ToString()) == 0 && !nextAction.HasBeenVisited) { isRightAvailable = true; tileRight = GetTile(nextAction); hasRightReward = nextAction.RewardOnDestination > 0; } if (string.Compare(nextAction.Direction, MoveEnum.Up.ToString()) == 0 && !nextAction.HasBeenVisited) { isUpAvailable = true; tileUp = GetTile(nextAction); hasUpReward = nextAction.RewardOnDestination > 0; } if (string.Compare(nextAction.Direction, MoveEnum.Left.ToString()) == 0 && !nextAction.HasBeenVisited) { isLeftAvailable = true; tileLeft = GetTile(nextAction); hasLeftReward = nextAction.RewardOnDestination > 0; } if (string.Compare(nextAction.Direction, MoveEnum.Down.ToString()) == 0 && !nextAction.HasBeenVisited) { isDownAvailable = true; tileDown = GetTile(nextAction); hasDownReward = nextAction.RewardOnDestination > 0; } } if (isRightAvailable || isUpAvailable || isLeftAvailable || isDownAvailable) { direction = DirectionEnum.Down; if (isRightAvailable && hasRightReward) { move = MoveEnum.Right.ToString(); tile = tileRight; } else if (isUpAvailable && hasUpReward) { move = MoveEnum.Up.ToString(); tile = tileUp; } else if (isLeftAvailable && hasLeftReward) { move = MoveEnum.Left.ToString(); tile = tileLeft; } else if (isDownAvailable && hasDownReward) { move = MoveEnum.Down.ToString(); tile = tileDown; } else if (isRightAvailable) { move = MoveEnum.Right.ToString(); tile = tileRight; } else if (isUpAvailable) { move = MoveEnum.Up.ToString(); tile = tileUp; } else if (isLeftAvailable) { move = MoveEnum.Left.ToString(); tile = tileLeft; } else if (isDownAvailable) { move = MoveEnum.Down.ToString(); tile = tileDown; } paths.Add(move); paths.Add(tile); } else { direction = DirectionEnum.Up; string tileTemp = paths[paths.Count - 1]; string moveTemp = paths[paths.Count - 2]; paths.RemoveAt(paths.Count - 1); paths.RemoveAt(paths.Count - 1); string changedPath = ChangeDirection(moveTemp); paths.Add(changedPath); paths.Add(tileTemp); tile = paths[paths.Count - 1]; move = paths[paths.Count - 2]; } }
public void UserActionChanged (PossibleActions newAction) { HiveController[] hives = GameObject.FindObjectsOfType<HiveController> (); HiveController.Pheromones currentPheromones = HiveController.Pheromones.DANGER; switch (newAction) { case PossibleActions.NOTHING: cost = 0; currentAction = newAction; priceType = PriceType.CONSTANT; if (unitToFollow != null) { unitToFollow = null; unitPanel.UnitUnselected (); } Debug.Log ("Action Changed " + newAction); return; break; case PossibleActions.PATHFORWORK: currentPheromones = HiveController.Pheromones.USEFUL; cost = 5; break; case PossibleActions.PATHFORATTACK: currentPheromones = HiveController.Pheromones.ATTACK; cost = 10; break; case PossibleActions.PATHFORSCOUT: currentPheromones = HiveController.Pheromones.SCOUT; cost = 1; break; } foreach (HiveController hive in hives) { if (hive.hiveFraction == currentPlayerHive.GetComponent<HiveController> ().hiveFraction) { hive.RemoveFlag (currentPheromones); } } currentAction = newAction; priceType = PriceType.CONSTANT; if (unitToFollow != null) { unitToFollow = null; unitPanel.UnitUnselected (); } Debug.Log ("Action Changed " + newAction); }
public BaseRequest(PossibleActions action, Guid guid) { _possibleAction = action; _guid = guid; }