public static List <HanabiCard> OrderedPlays(HanabiGame game, HanabiPlayer player) { return(player.Hand.Where(card => game.IsPlayable(card)) .OrderBy(card => card.Number) .ThenBy(card => IsDangerCard(game, card)) .ThenByDescending(card => player.Hand.IndexOf(card)).ToList()); }
public HanabiAction EvaluateHand(HanabiGame game) { var preferredplay = Hand.Where(c => game.IsPlayable(c)) .OrderBy(c => c.Number == 5) .ThenBy(c => c.Number) .ThenBy(c => Hand.IndexOf(c)).ToArray(); if (preferredplay.Length != 0) { return(new HanabiAction(HanabiActionType.Play, preferredplay[0], Hand.IndexOf(preferredplay[0]))); } var preferreddiscard = Hand.OrderByDescending(c => game.PlayedCards.ContainsCard(c)) .ThenBy(c => Logic.IsDangerCard(game, c)) .ThenByDescending(c => c.Number) .ThenBy(c => Hand.IndexOf(c)).ToArray(); return(new HanabiAction(HanabiActionType.Discard, preferreddiscard[0], Hand.IndexOf(preferreddiscard[0]))); }
public bool SeesCollision(ref HanabiGame game, int forwardplayers = 2) { var nextplayer = game.NextPlayer as Mod8HanabiPlayer; var nextnextplayer = game.Players[(game.PlayerTurn + 2) % game.PlayerCount] as Mod8HanabiPlayer; if (nextplayer.NextAction.Type == HanabiActionType.Play) { if (!game.IsPlayable(nextplayer.NextAction.Card)) { return(true); } } if (nextplayer.NextAction.Type == HanabiActionType.Play && nextnextplayer.NextAction.Type == HanabiActionType.Play) { if (nextplayer.NextAction.Card.Number == nextnextplayer.NextAction.Card.Number && nextplayer.NextAction.Card.Color == nextnextplayer.NextAction.Card.Color) { return(true); } } return(false); }
public IEnumerable <HanabiCard> GetPlayableCards(HanabiGame game) { return(Hand.Where(c => game.IsPlayable(c))); }