public DrawResponse OnDraw(VisibleBoard board, Tile tile, DrawActions suggestedActions) { if (suggestedActions.HasFlag(DrawActions.Tsumo)) { return(DrawResponse.Tsumo()); } if (suggestedActions.HasFlag(DrawActions.Riichi)) { var tileTypeId = board.Watashi.Hand.GetHighestUkeIreDiscard(); var discard = board.Watashi.ConcealedTiles.First(i => i.TileType.TileTypeId == tileTypeId); return(DrawResponse.Riichi(discard)); } if (suggestedActions.HasFlag(DrawActions.KyuushuKyuuhai) && (board.Watashi.Hand.Shanten > 2 || board.Seats.Any(s => s.DeclaredRiichi))) { return(DrawResponse.KyuushuKyuuhai()); } { var tileTypeId = board.Watashi.Hand.GetHighestUkeIreDiscard(); // Prefer tsumogiri if (tile.TileType.TileTypeId == tileTypeId) { return(DrawResponse.Discard(tile)); } var discard = board.Watashi.ConcealedTiles.First(i => i.TileType.TileTypeId == tileTypeId); return(DrawResponse.Discard(discard)); } }
public DrawResponse OnDraw(VisibleBoard board, Tile tile, DrawActions suggestedActions) { if ((suggestedActions & DrawActions.Tsumo) != 0) { return(DrawResponse.Tsumo()); } if ((suggestedActions & DrawActions.KyuushuKyuuhai) != 0) { return(DrawResponse.KyuushuKyuuhai()); } if ((suggestedActions & DrawActions.Kan) != 0) { var ankanTileType = board.Watashi.ConcealedTiles.GroupBy(t => t.TileType).FirstOrDefault(t => t.Count() == 4)?.Key; if (ankanTileType != null) { return(DrawResponse.Ankan(ankanTileType)); } var shouminkanTile = board.Watashi.ConcealedTiles.FirstOrDefault(t => board.Watashi.Melds.Any(m => m.MeldType == MeldType.Koutsu && m.LowestTile.TileType == t.TileType)); if (shouminkanTile != null) { return(DrawResponse.Shouminkan(tile)); } } return(DrawResponse.Discard(FindDiscard(board))); }
internal override bool CanExecute(VisibleBoard board, DrawActions possibleActions) { return(possibleActions.HasFlag(DrawActions.Kan) && !board.Watashi.DeclaredRiichi && HasTile(board, _tile) && board.Watashi.Melds.Any(m => m.MeldType == MeldType.Koutsu && m.LowestTile.TileType == _tile.TileType)); }
internal override bool CanExecute(VisibleBoard board, DrawActions possibleActions) { if (!possibleActions.HasFlag(DrawActions.Kan) || board.Watashi.ConcealedTiles.Count(t => t.TileType == _tileType) != 4 || board.Watashi.CurrentDraw == null) { return(false); } return(!board.Watashi.DeclaredRiichi || !board.Watashi.Hand.IsUkeIreChangedByAnkan(board.Watashi.CurrentDraw.TileType, _tileType)); }
public void DrawTextNoBackground(int ichBase, IVwGraphics _vg, Rect rcSrc, Rect rcDst, out int dxdWidth) { if (DrawActions == null) { DrawActions = new List <object>(); } DrawActions.Add(new DrawTextNoBackgroundAction() { Segment = this, IchBase = ichBase, Vg = _vg, RcSrc = rcSrc, RcDst = rcDst }); dxdWidth = Width; }
public void DrawRectangle(int xLeft, int yTop, int xRight, int yBottom) { RectanglesDrawn.Add(new Rectangle(xLeft, yTop, xRight - xLeft, yBottom - yTop)); RectColorsDrawn.Add(BackColor); if (DrawActions == null) { DrawActions = new List <object>(); } DrawActions.Add(new DrawRectangleAction() { Left = xLeft, Top = yTop, Right = xRight, Bottom = yBottom, Bgr = BackColor }); }
public void DrawHorzLine(int xLeft, int xRight, int y, int dyHeight, int cdx, int[] rgdx, ref int dxStart) { Assert.That(cdx, Is.EqualTo(rgdx.Length)); if (DrawActions == null) { DrawActions = new List <object>(); } DrawActions.Add(new DrawHorzLineAction() { Left = xLeft, Right = xRight, Y = y, Height = dyHeight, Rgdx = rgdx, DxStart = dxStart }); }
public async Task <DrawResponse> OnDraw(DrawActions actions, int seatIndex) { var player = _players[seatIndex]; var boardView = _boardViews[seatIndex]; var tile = boardView.Watashi.CurrentDraw !; var decider = Task.Run(() => player.OnDraw(boardView, tile, actions)); var r = await Task.WhenAny(decider, Task.Delay(DecisionTimeout)); if (r.IsCompletedSuccessfully && r is Task <DrawResponse> { IsCompletedSuccessfully : true } t&& t.Result.CanExecute(boardView, actions)) { return(t.Result); } return(DrawResponse.Discard(tile)); }
public DrawResponse OnDraw(VisibleBoard board, Tile tile, DrawActions suggestedActions) { Delay(50); return(_player.OnDraw(board, tile, suggestedActions)); }
public void DrawDot(decimal Value, decimal Count) { DrawActions.Add(new Action(() => buffer.Graphics.DrawEllipse(Pens.Yellow, new Rectangle(ValueToX(Value) - 2, CountToY(Count) - 2, 4, 4)))); }
internal override bool CanExecute(VisibleBoard board, DrawActions possibleActions) { return(HasTile(board, _tile)); }
internal abstract bool CanExecute(VisibleBoard board, DrawActions possibleActions);
internal override bool CanExecute(VisibleBoard board, DrawActions possibleActions) { return(possibleActions.HasFlag(DrawActions.KyuushuKyuuhai)); }
internal override bool CanExecute(VisibleBoard board, DrawActions possibleActions) { return(possibleActions.HasFlag(DrawActions.Riichi) && HasTile(board, _tile) && board.Watashi.Hand.ShantenAfterDiscard(_tile.TileType) == 0); }