Ejemplo n.º 1
0
        public void Update(int gameStatus, Piece piece = null)
        {
            if (piece != null)
            {
                OurPieces.Remove(piece);
            }

            if (gameStatus != -1)
            {
                int nPlayerTurn;
                if ((gameStatus & 4) != 0)
                {
                    nPlayerTurn = 2;
                }
                else
                {
                    nPlayerTurn = 1;
                }
                if (nSessionPlayer == nPlayerTurn)
                {
                    bOurTurn = true;
                }
                else
                {
                    bOurTurn = false;
                }
            }
            StateHasChanged();
        }
Ejemplo n.º 2
0
        public void Update(int gameStatus, Piece piece = null)
        {
            // if a piece has been placed on our board
            if (piece != null)
            {
                OurPieces.Add(piece);
            }

            // is it this player's turn?
            int nPlayerTurn;

            if ((gameStatus & 4) != 0)
            {
                nPlayerTurn = 2;
            }
            else
            {
                nPlayerTurn = 1;
            }
            if (nPlayer == nPlayerTurn)
            {
                bOurTurn = true;
            }
            else
            {
                bOurTurn = false;
            }

            StateHasChanged();
        }
Ejemplo n.º 3
0
        protected async void HarvestClick(MouseEventArgs eventArgs)
        {
            if (!bOurTurn)
            {
                return;
            }
            if (bHarvest)
            {
                bHarvest = false;
                if (harvestList.Count() > 0)
                {
                    var harvestCompanionList = new List <int>();
                    foreach (Piece piece in harvestList)
                    {
                        bHighlightState[piece.NPosition] = false;
                        harvestIdList.Add(piece.NPosition + (nPlayer - 1) * 25 + 5);

                        // check for companions
                        for (int i = 0; i < 4; i++)
                        {
                            int pos = piece.NPosition + companion[i];
                            if (pos >= 0 && pos < 25)
                            {
                                Piece companionPiece = OurPieces.Find(p => p.NPosition == pos);
                                if (companionPiece != null)
                                {
                                    ePieceType companionType = companionPiece.GetPieceType();
                                    if (companionPiece.GetPieceType() == ePieceType.pepper_red ||
                                        companionPiece.GetPieceType() == ePieceType.pepper_yellow)
                                    {
                                        companionType = ePieceType.pepper_green;
                                    }
                                    if (companionType == piece.GetCompanionType())
                                    {
                                        harvestCompanionList.Add(pos);
                                    }
                                }
                            }
                        }
                    }

                    // filter companion list for distinct items
                    var distinctCompanionSet = harvestCompanionList.Distinct();

                    // set bonus points for companions
                    companionBonus = distinctCompanionSet.Count();

                    NotifyChange(new Status(nPlayer, true));
                }
            }
            else
            {
                harvestList.Clear();
                harvestIdList.Clear();
                bHarvest = true;
            }
            StateHasChanged();
        }
Ejemplo n.º 4
0
        protected string GetImageFilePath(int id)
        {
            var result = OurPieces.Find(p => p.NPosition == id);

            if (result == null)
            {
                return("");
            }
            return(result.GetImageFileName());
        }
Ejemplo n.º 5
0
        public void ConfirmHarvest(List <Piece> pieces = null)
        {
            if (pieces == null)
            {
                pieces = harvestList;
            }

            foreach (Piece piece in pieces)
            {
                OurPieces.Remove(piece);
            }
        }
Ejemplo n.º 6
0
        protected string GetImageFilePath(int id)
        {
            // 7 = number of items on the truck
            // 35 = number of items in a player's garden
            id = id - (nPlayer - 1) * 25 - 5;

            // Get piece image so long as it's status is not "in hand"
            var result = OurPieces.Find(p => p.NPosition == id && (p.NPieceStatus & 1) == 0);

            if (result == null)
            {
                return("");
            }

            return(result.GetImageFileName());
        }
Ejemplo n.º 7
0
        protected async void TruckGridClick(MouseEventArgs eventArgs, int buttonId)
        {
            // is it the session player's turn?
            if (!bOurTurn)
            {
                return;
            }

            // is there a vege in the plot?
            Piece piece = OurPieces.Find(p => p.NPosition == buttonId);

            if (piece == null)
            {
                return;
            }

            ClearHighlighting();

            bHighlightState[buttonId] = true;

            NotifyChange(new Status(0, buttonId, piece));
        }
Ejemplo n.º 8
0
        protected async void PlayerGridClick(MouseEventArgs eventArgs, int buttonId)
        {
            // Are we the host
            if (!bHost)
            {
                return;
            }

            // is it our turn?
            if (!bOurTurn)
            {
                return;
            }

            // Get position from buttonId
            int position = buttonId - (nPlayer - 1) * 25 - 5;

            // is there a vege in the plot?
            Piece piece = OurPieces.Find(p => p.NPosition == position);

            if (bHarvest && piece != null)
            {
                // only allow same piece types to be harvested
                if (harvestList.Count() > 0)
                {
                    if (harvestList[0].NPieceType == (int)ePieceType.pepper_green ||
                        harvestList[0].NPieceType == (int)ePieceType.pepper_red ||
                        harvestList[0].NPieceType == (int)ePieceType.pepper_yellow)
                    {
                        if (piece.NPieceType != (int)ePieceType.pepper_green &&
                            piece.NPieceType != (int)ePieceType.pepper_red &&
                            piece.NPieceType != (int)ePieceType.pepper_yellow)
                        {
                            return;
                        }
                    }
                    else
                    if (piece.NPieceType != harvestList[0].NPieceType)
                    {
                        return;
                    }
                }

                // remove the piece if clicked twice
                if (harvestList.Contains(piece))
                {
                    harvestList.Remove(piece);
                    bHighlightState[position] = false;
                }
                else
                {
                    harvestList.Add(piece);
                    bHighlightState[position] = true;
                }
                StateHasChanged();
            }

            if (piece != null)
            {
                return; // yes
            }
            NotifyChange(new Status(nPlayer, buttonId));
        }
Ejemplo n.º 9
0
 public void AddVeg(Piece piece)
 {
     OurPieces.Add(piece);
     StateHasChanged();
 }