/// <summary> /// Начать ход. /// </summary> public void StartTurn() { var turn = new Turn(Turns.Count + 1); turn.Start(); Turns.Add(turn); }
public void SetNewTurn(DateTime dateRangeStart, DateTime dateRangeEnd, string clientName) { //if (!IsAvailable(dateRangeStart)) throw new Exception("No disponible"); var dateAssign = GetDateAvailable(dateRangeStart); Turns.Add(new Turn(Id, dateAssign, clientName, Turns.Select(t => t.Number).ToList())); }
public void RemoveSticks(string playerName, int qtd) { if (qtd > QtdSticks) { throw new InvalidOperationException("You can not remove sticks anymore!"); } var player = Players.FirstOrDefault(a => a.Name == playerName); if (player == null) { throw new KeyNotFoundException("Player not found!"); } var playerIndex = TurnsOrder.IndexOf(player.Name); var nextPlayerIndex = GetNextPlayerIndex(); if (playerIndex != nextPlayerIndex) { throw new InvalidOperationException(); } QtdSticks = QtdSticks - qtd; Turns.Add(player.Name); player.Score += POINTS_BY_STICK * qtd; }
private ImmutableList <Turn> AddThrowIntoTurns(ThrowResult result) { if (!Turns.Any() || Turns.Last().Finished) { return(Turns .Add(new Turn(Score).WithAdditionalThrow(result))); } return(Turns .RemoveAt(Turns.Count - 1) .Add(Turns.Last().WithAdditionalThrow(result))); }
internal void ExecuteTurn(bool yieldSuccess, int roll) { int attacker = NextAttacker.Id; int reciever = attacker == Gladiator.Id ? Opponent.Id : Gladiator.Id; Turn nextTurn = new Turn(this, attacker, reciever); nextTurn.Yielded = true; nextTurn.Roll = roll; nextTurn.Final = yieldSuccess; Turns.Add(nextTurn); NextAttackerID = reciever; }
public void ExecuteTurn(int damage, int roll, bool lethal) { int attacker = NextAttacker.Id; int reciever = attacker == Gladiator.Id ? Opponent.Id : Gladiator.Id; Turn nextTurn = new Turn(this, attacker, reciever); nextTurn.Damage = damage; nextTurn.Roll = roll; nextTurn.Final = lethal; Turns.Add(nextTurn); NextAttackerID = reciever; }
public void AddTurn() { lock (_syncObject) { var last = Turns.LastOrDefault(); var lastNo = last != null ? last.No : 0; var turn = new TurnInfo() { No = lastNo + 1, TurnTime = DateTime.Now }; Turns.Add(turn); } }
private Choice StartNewTurn(Guid activePlayer, Guid nonActivePlayer) { if (ExtraTurns.Any()) { Turns.Add(ExtraTurns.Dequeue()); } else { Turns.Add(new Turn { ActivePlayer = activePlayer, NonActivePlayer = nonActivePlayer }); } return(Turns.Last().Start(this, Turns.Count)); }
public void StartTurn() { foreach (var ai in Players.Select(x => x.AI)) { ai.OnDayEnding(); } var i = Turns.Keys.Any() ? Turns.Keys.Max() + 1 : 1; var t = new Turn() { Id = i, NightInstructions = new List <NightInstruction>(), DayInstructions = new List <DayInstruction>() }; Turns.Add(i, t); Hub.SendStartNight(this, CurrentTurn().Id); GetNightInstructionsFromAIs(); }
private void EndCurrentTurn() { if (Status != GameStatus.InProgress) { throw new InvalidOperationException(); } CurrentTurn.End(); if (GetWinningTeam() is Team winningTeam) { AddPublicEvent(GameEvent.TeamWon(winningTeam, DateTime.Now)); } else { Turns.Add(new Turn(CurrentTurn.Team.GetOpposingTeam(), CurrentTurn.TurnNumber + 1)); } }
/// <summary> /// Сделать ход /// </summary> /// <param name="clicked"></param> /// <returns></returns> public virtual bool DoTurn(ref Button clicked) { int x = clicked.Name[6] - '0'; int y = clicked.Name[8] - '0'; var newCell = new Cell(x, y, _markType); if (CorrectTurn(clicked)) { Field.Cells[x, y] = newCell; Turns.Add(newCell); clicked.Content = (char)_markType; return(true); } else { MessageBox.Show("This is incorrect. Try again."); return(false); } }
/// <summary> /// Ends the turn and records the necessary stats. /// </summary> /// <param name="log">The logger to log to if there's an error.</param> /// <param name="moveTime">The time that the AI took to make a move.</param> internal void EndTurn(Logger.LogCallback log, TimeSpan moveTime) { if (IsEnabled) { if ((TagNames == null) || TagNames.Length == 0) { log(this.AIColor.ToString() + ": To use the profiler, you must set Profiler.MethodNames to a list of enum names that you used with the integer keys"); } if (Depth != 0) { MoveDepths.Add(this.Depth); } MoveTimes.Add(moveTime); Turns.Add(Profile); FxTurns.Add(FxProfile); FxProfile = new int[_numFrameworkMethods]; Profile = new int[MaxProfilerTags]; } }
//реализация полиморфизма /// <summary> /// Сделать ход /// </summary> /// <param name="clicked"></param> /// <returns></returns> public override bool DoTurn(ref Button clicked) { if (!CheckTie()) { return(true); } int x, y; var buttons = Container.Children.Cast <Button>().ToList(); do { x = _rand.Next(Field.Size); y = _rand.Next(Field.Size); } while (!CorrectTurn(buttons[x * Field.Size + y])); Cell newCell = new Cell(x, y); Field.Cells[x, y] = newCell; Turns.Add(newCell); buttons[x * Field.Size + y].Content = (char)_markType; return(true); }
public static void Load(string folder, XElement xml) { Clear(); XML = xml; if (XML.Element("VSwap") != null) { VSwap = VSwap.Load(folder, XML); } if (XML.Element("Maps") != null) { Maps = GameMap.Load(folder, XML); } if (XML.Element("Audio") != null) { AudioT = AudioT.Load(folder, XML); } if (XML.Element("VgaGraph") != null) { VgaGraph = VgaGraph.Load(folder, XML); } Walls = XML.Element("VSwap")?.Element("Walls")?.Elements("Wall").Select(e => ushort.Parse(e.Attribute("Number").Value)).ToArray(); Doors = XML.Element("VSwap")?.Element("Walls")?.Elements("Door")?.Select(e => ushort.Parse(e.Attribute("Number").Value))?.ToArray(); Elevators = XML.Element("VSwap")?.Element("Walls")?.Elements("Elevator")?.Select(e => ushort.Parse(e.Attribute("Number").Value))?.ToArray(); PushWalls = PushWall?.Select(e => ushort.Parse(e.Attribute("Number").Value))?.ToArray(); States.Clear(); foreach (XElement xState in XML?.Element("VSwap")?.Element("Objects")?.Elements("State") ?? Enumerable.Empty <XElement>()) { States.Add(xState.Attribute("Name").Value, new State(xState)); } foreach (State state in States.Values) { if (state.XML.Attribute("Next")?.Value is string next) { state.Next = States[next]; } } Turns.Clear(); foreach (XElement xTurn in XML?.Element("VSwap")?.Element("Objects")?.Elements("Turn") ?? Enumerable.Empty <XElement>()) { Turns.Add((ushort)(int)xTurn.Attribute("Number"), Direction8.From(xTurn.Attribute("Direction"))); } EndStrings = XML?.Element("VgaGraph")?.Element("Menus")?.Elements("EndString")?.Select(a => a.Value)?.ToArray() ?? new string[] { "Sure you want to quit? Y/N" }; if (ushort.TryParse(XML?.Element("VSwap")?.Element("Walls")?.Attribute("FloorCodeFirst")?.Value, out ushort floorCodeFirst)) { FloorCodeFirst = floorCodeFirst; } if (ushort.TryParse(XML?.Element("VSwap")?.Element("Walls")?.Attribute("FloorCodeLast")?.Value, out ushort floorCodeLast)) { FloorCodes = (ushort)(1 + floorCodeLast - FloorCodeFirst); } // Load "extra" IMF/WLF files not included in AudioT Godot.File file = new Godot.File(); foreach (XElement songXML in XML.Element("Audio").Elements("Imf")?.Where(e => e.Attribute("File") is XAttribute)) { if (file.Open(songXML.Attribute("File").Value, Godot.File.ModeFlags.Read) == Godot.Error.Ok && file.IsOpen()) { byte[] bytes = file.GetBuffer((int)file.GetLen()); file.Close(); AudioT.Songs.Add(songXML?.Attribute("Name")?.Value, new Song() { Name = songXML?.Attribute("Name")?.Value, Bytes = bytes, Imf = Imf.ReadImf(new MemoryStream(bytes)), }); } } }
public void AddTurn(PlayerTurn turn) { Turns.Add(turn); currentTurn = turn; }
public void NewTurn(Player currentPlayer) { Turns.Add(new Turn(currentPlayer)); }