Exemplo n.º 1
0
 public PieceMovementMessage(IReadOnlyPlayer player, IReadOnlyPiece piece, IntegerVector2 startPosition, IntegerVector2 endPosition)
 {
     Player        = player;
     Piece         = piece;
     StartPosition = startPosition;
     EndPosition   = endPosition;
 }
Exemplo n.º 2
0
 internal VerifiedMove(IReadOnlyPiece movingPiece, IReadOnlyPlayer player, IEnumerable <IntegerVector2> worldPath, IntegerVector2 viaPositionNode)
 {
     MovingPiece     = movingPiece;
     Player          = player;
     WorldPath       = worldPath;
     ViaPositionNode = viaPositionNode;
 }
Exemplo n.º 3
0
        private bool IsSuiteBetterInformation(IReadOnlyPlayer nextPlayer, Card chop)
        {
            var suiteInformationAffectedCards  = nextPlayer.InformationAffectedCards(chop.Suite);
            var numberInformationAffectedCards = nextPlayer.InformationAffectedCards(chop.Number);

            return(suiteInformationAffectedCards.Count() <= numberInformationAffectedCards.Count());

            // TODO SaveNextChop may give the better clue if other tactics, e.g. PlayStandaloneClued does not pick them up eagerly.
        }
Exemplo n.º 4
0
 public PlayerResponse(IReadOnlyPlayer player)
 {
     this.Status             = player.Status;
     this.Id                 = player.PlayerId;
     this.Rating             = player.Rating;
     this.PositiveReputation = player.PositiveReputation;
     this.NegativeReputation = player.NegativeReputation;
     this.Name               = player.Name;
 }
Exemplo n.º 5
0
 private void Info(IReadOnlyPlayer player, int number)
 {
     Write($"Player {number}:");
     foreach (var card in player.Cards)
     {
         Write(" ");
         Info(card);
         Write(InformationText(player.Information[card]));
     }
     WriteLine();
 }
Exemplo n.º 6
0
        bool CheckHandIncrease(IReadOnlyPlayer currentPlayer)
        {
            if (!previousHandsDictionary.ContainsKey(currentPlayer))
            {
                previousHandsDictionary.Add(currentPlayer, Array.Empty <IHand>());
            }

            IEnumerable <IHand> currentHands   = handDatabase.SearchHands(currentPlayer.GetPieceList());
            HandDifference      handDifference = HandDifferenceCalculator.Calculate(previousHandsDictionary[currentPlayer], currentHands);

            if (handDifference.IncreasedDifference.Any() || handDifference.IncreasedDifference.Any())
            {
                previousHandsDictionary[currentPlayer] = currentHands.ToArray();
            }

            return(handDifference.IncreasedDifference.Any());
        }
Exemplo n.º 7
0
        public VerifiedMove VerifyMove(IReadOnlyPlayer player, IntegerVector2 startPosition, IntegerVector2 viaPosition, IntegerVector2 endPosition)
        {
            Assert.IsTrue(IsOnBoard(startPosition));
            Assert.IsTrue(IsOnBoard(viaPosition) || viaPosition == new IntegerVector2(-1, -1));
            Assert.IsTrue(IsOnBoard(endPosition));

            //経路計算前の合法性チェック
            bool           areViaAndLastSame      = viaPosition == endPosition;
            IReadOnlyPiece movingPiece            = pieces.Read(startPosition);
            IReadOnlyPiece viaPiece               = pieces.Read(viaPosition);
            IReadOnlyPiece originalPiece          = pieces.Read(endPosition); //元からある駒の意味で使っているが, 英語があってるか不明.
            bool           isTargetNull           = movingPiece == null;
            bool           isViaPieceNull         = viaPiece == null;         //
            bool           isOwner                = !isTargetNull && movingPiece.IsOwner(player);
            bool           isSameOwner            = !isTargetNull && originalPiece != null && originalPiece.Owner == movingPiece.Owner;
            PieceMovement  start2ViaPieceMovement = PieceMovement.Default;
            PieceMovement  via2EndPieceMovement   = PieceMovement.Default;
            bool           isMoveableToVia        = !isTargetNull && movingPiece.TryToGetPieceMovement(viaPosition, out start2ViaPieceMovement);                                                    //
            bool           isMoveableToLast       = !isTargetNull && (areViaAndLastSame || movingPiece.TryToGetPieceMovement(startPosition + endPosition - viaPosition, out via2EndPieceMovement)); //

            if (isTargetNull || (!areViaAndLastSame && isViaPieceNull) || !isOwner || isSameOwner || !isMoveableToVia || !isMoveableToLast)                                                         //
            {
                return(VerifiedMove.InvalidMove);
            }

            //経路計算
            //worldPathに開始地点は含まれない
            var worldPath       = WorldPathCalculator.CalculatePath(startPosition, viaPosition, endPosition, pieces, start2ViaPieceMovement, via2EndPieceMovement);
            var viaPositionNode = worldPath.First(value => value == viaPosition);  //経由点を通過するのが1回だけだということは保証されている.

            //経路の合法性チェック
            var surmountLimit = via2EndPieceMovement.Surmountable ? 1 : 0;
            var noPieceOnPath = worldPath.Where(node => node != viaPosition).Where(node => node != endPosition)
                                .Select(node => pieces.Read(node)).Where(piece => piece != null)
                                .Count() <= surmountLimit;

            if (!noPieceOnPath)
            {
                return(VerifiedMove.InvalidMove);
            }

            return(new VerifiedMove(movingPiece, player, worldPath, viaPositionNode));
        }
Exemplo n.º 8
0
 public static int CardNumber(this IReadOnlyPlayer player, Card card)
 {
     return(player.Cards.IndexOf(card) + 1);
 }
Exemplo n.º 9
0
 private bool IsCluable(IReadOnlyPlayer player, Card card)
 {
     return(!Utils.IsKnownCard(player, card));
 }
Exemplo n.º 10
0
 private Card?Chop(IReadOnlyPlayer player)
 {
     return(player.Cards
            .Reverse()
            .FirstOrDefault(c => Utils.IsUnknownCard(player, c)));
 }
Exemplo n.º 11
0
 private bool HasUnknownCards(IReadOnlyPlayer player)
 => RightmostUnknownCard(player) != null;
 public bool IsOwner(IReadOnlyPlayer player) => throw new System.NotImplementedException();
Exemplo n.º 13
0
 public static int PlayerNumber(this IGameState gameState, IReadOnlyPlayer player)
 {
     return(gameState.Players.IndexOf(player) + 1);
 }
Exemplo n.º 14
0
 public override bool IsOwner(IReadOnlyPlayer player) => true;
Exemplo n.º 15
0
 public SetPieceMessage(IReadOnlyPlayer player, IReadOnlyPiece piece, IntegerVector2 setPosition)
 {
     Player      = player;
     Piece       = piece;
     SetPosition = setPosition;
 }
Exemplo n.º 16
0
 public bool CanGiveInformation(IReadOnlyPlayer otherPlayer, Number number)
 {
     return((Table.InformationTokens.Amount > 0) &&
            otherPlayer.InformationAffectedCards(number).Any());
 }
Exemplo n.º 17
0
 public virtual bool IsOwner(IReadOnlyPlayer player)
 {
     return(Owner == player);
 }
Exemplo n.º 18
0
 public PlayerReputationUpdateResponse(IReadOnlyPlayer player, int oldPositiveReputation, int oldNegativeReputation) : base(player)
 {
     this.OldPositiveReputation = oldPositiveReputation;
     this.OldNegativeReputation = oldNegativeReputation;
 }
Exemplo n.º 19
0
 public PlayerRatingUpdateResponse(IReadOnlyPlayer player, uint oldRating) : base(player)
 {
     this.OldRating = oldRating;
 }
Exemplo n.º 20
0
 public static bool IsKnownCard(IReadOnlyPlayer player, Card card)
 => IsKnown(player.Information[card]);