//Methods /// <summary> /// Uses the card, each card has a different use function /// </summary> public virtual void Use() { Owner.UsableCards.Remove(this); if (!(this is TileLink)) { ChanceDeck.PlaceUnderDeck(this); } }
private bool ChanceCardWin(Player player = null) { if (ChanceDeck.Count == 0) { ChanceDeck = InitChanceDeck(); } if (player == null) { while (true) { Console.WriteLine("请输入使用机会卡的玩家ID:(Exit 退出)"); string playerId = Console.ReadLine().Trim(); if (string.Equals(playerId, "exit", StringComparison.OrdinalIgnoreCase)) { return(false); } player = Players.FirstOrDefault(p => p.Id == playerId || string.Equals(p.Name, playerId, StringComparison.OrdinalIgnoreCase)); if (player == null) { Console.WriteLine("该玩家不存在。"); continue; } break; } } int cardNumber = PickChanceCard(); Console.WriteLine($"触发的机会卡ID为:{cardNumber}"); if (ChanceDeck.Contains(cardNumber)) { ChanceDeck.Remove(cardNumber); player.ChanceCards.Add(cardNumber); GameLogs chanceCardWinLog = new GameLogs() { ID = GetLogID(), Type = LogEventType.ChanceCardWin, PlayerName = player.Name, ChanceCardWin = cardNumber, Info = "获得机会卡", Round = Round, currentPlayer = currentPlayer }; AddLog(chanceCardWinLog); return(true); } else { return(false); } }
public void ReturnGetOutOfJailFreeCard(Card card) { var sCard = (SpecialCard)card; if (sCard.CardType == SpecialCardType.GetOutOfJailFreeChance) { ChanceDeck.Enqueue(card); } else if (sCard.CardType == SpecialCardType.GetOutOfJailFreeCommunityChest) { CommunityChestDeck.Enqueue(card); } else { throw new ApplicationException("Unknown card return"); } }
public Card GetNextChance() { var card = ChanceDeck.Dequeue(); if (card is SpecialCard) { if (((SpecialCard)card).CardType != SpecialCardType.GetOutOfJailFreeChance) { ChanceDeck.Enqueue(card); } } else { ChanceDeck.Enqueue(card); } return(card); }
public static void EndOfRollOptions() { Tile tile = CurrentPlayer.Position; Property property = tile.GetComponent <Property>(); ChanceTile chance = tile.GetComponent <ChanceTile>(); //FreeParking parking = tile.GetComponent<FreeParking>(); SandLTile sAndL = tile.GetComponent <SandLTile>(); PaymentTile paymentTile = tile.GetComponent <PaymentTile>(); GoToJailTile goToJail = tile.GetComponent <GoToJailTile>(); if (property != null) { //check if the player stepped on an unowned/mortgaged/their own property if (property.Owner == null || property.Owner == CurrentPlayer || (property.Mortgaged && property.Owner != CurrentPlayer)) { MenuManager.SwitchToMenuWithInventory(MenuManager.EndOfTurnOptions); } else { PlayerMustPay(property.PaymentPrice()); } //display current property MenuManager.UpdateCardInfo(CurrentPlayer.Position.GetComponent <Property>()); } else if (chance != null || sAndL != null) { if (chance != null) { _activeCard = ChanceDeck.DrawCard(); } else if (sAndL != null) { if (UnityEngine.Random.Range(0f, 1f) < 0.5f) { _activeCard = new Snake(); } else { _activeCard = new Ladder(); } } //adds card to player's inventory CurrentPlayer.AddCard(ActiveCard); MenuManager.SwitchToMenuWithInventory(MenuManager.CardOptions); //pop up to show which card is drawn MenuManager.UpdateCardInfo(ActiveCard); } else if (paymentTile != null) { MenuManager.SwitchToMenuWithInventory(MenuManager.PaymentTileOptions); } else if (goToJail != null) // if on go to jail tile { //create new card, uses it, deletes it _activeCard = new CardMove("Go to Jail - Go directly to Jail - Do not pass Go, do not collect $200", EnumsForCards.cardMove.goToJail); CurrentPlayer.AddCard(ActiveCard); MenuManager.SwitchToMenuWithInventory(MenuManager.CardOptions); MenuManager.UpdateCardInfo(ActiveCard); ChanceDeck.DeleteLastCard(); } else { MenuManager.SwitchToMenuWithInventory(MenuManager.EndOfTurnOptions); } }