public override void Apply(CardColors colors) { _cardColors = colors; _cardColorSetter = new CardColorSetter(_colors); _cardColorSetter.Initialize(ChangeTracker); _cardColors.AddModifier(_cardColorSetter); }
/// <summary> /// 抽取指定 颜色 及 张数 的牌 /// </summary> /// <param name="colorCardsCount">指定颜色的牌数</param> /// <param name="roomInfo">房间信息(修改手牌和牌库)</param> /// <param name="id">玩家id</param> /// <param name="cardColors">对应牌色</param> public static void DoDeal(int colorCardsCount, RoomInfo roomInfo, int id, CardColors cardColors) { for (int i = 0; i < colorCardsCount; i++) { BaseCard card = roomInfo.cardsLibrary.Find(it => { if (it.CardColor == cardColors)//找到满足条件的牌 { return(true); } else { return(false); } }); int index = roomInfo.member.FindIndex(it => { if (it.id == id) //找到该玩家在成员列表中的下标(索引) { return(true); } else { return(false); } }); roomInfo.cardsLibrary.Remove(card); card.CardBelongTo = (CardBelongTo)(index + 1);//为每个玩家发牌 0是牌库 roomInfo.playersCards.Add(card); } }
public Card(CardParameters p) { Name = p.Name; ManaCost = p.ManaCost; OverrideScore = p.OverrideScore; Text = p.Text; FlavorText = p.FlavorText; Illustration = p.Illustration; MayChooseNotToUntap = p.MayChooseToUntap; MinimalBlockerCount = p.MinimalBlockerCount; ProducableManaColors = p.ManaColorsThisCardCanProduce; _strenght = new Strenght(p.Power, p.Toughness); _level = new Level(p.IsLeveler ? 0 : (int?) null); _counters = new Counters(_strenght); _type = new CardTypeCharacteristic(p.Type); _colors = new CardColors(p.Colors); _protections = new Protections(p.ProtectionsFromColors, p.ProtectionsFromTypes); _simpleAbilities = new SimpleAbilities(p.SimpleAbilities); _triggeredAbilities = new TriggeredAbilities(p.TriggeredAbilities); _activatedAbilities = new ActivatedAbilities(p.ActivatedAbilities); _staticAbilities = new StaticAbilities(p.StaticAbilities); _castRules = new CastRules(p.CastInstructions); _combatRules = new CombatRules(p.CombatRules); _continuousEffects = new ContiniousEffects(p.ContinuousEffects); JoinedBattlefield = new TrackableEvent(this); LeftBattlefield = new TrackableEvent(this); }
public override UnoCard Move(Label currentColor) { UnoCard crd = this.topCard; CardColors colorTmp = crd.Color; if (crd.Color == CardColors.Black) { colorTmp = Helper.ToCardColor(currentColor.BackColor); } var colorsCards = this.Cards.Where(c => c.Color == colorTmp); if (colorsCards.Count() > 0) { return(colorsCards.First()); } var typeCards = this.Cards.Where(t => t.Type == crd.Type); if (typeCards.Count() > 0) { return(typeCards.First()); } var blackCards = this.Cards.Where(t => t.Color == CardColors.Black); if (blackCards.Count() > 0) { return(blackCards.First()); } return(null); }
public Id(Figures figure, CardColors color) { this.isJoker = false; this.image = null; this.color = color; this.figure = figure; this.blocked = false; }
public UnoCard(CardColors cl, CardType ct, Int32 pt, Boolean isHid, Image img) { this.cardColor = cl; // присваиваем цвет карте this.cardType = ct; // присваиваем тип карте this.cardPoints = pt; // присваиваем очки карте this.cardStatus = isHid; // присваиваем статус карте this.hiddenImage = Image.FromFile(@"../../../Resources/SmallCards/Black/02.jpg"); // присваиваем карте её скрытое изображение this.mainImage = img; // // присваиваем карте её открытое изображение }
/// <summary> /// 构造函数 /// 花色,牌权值 设定后不能修改 /// </summary> /// <param name="name">牌名</param> /// <param name="color">花色</param> /// <param name="weight">权重</param> /// /// <param name="belongTo">归属</param> public BaseCard(string name, int id, CardColors color, CardWeight weight, CardBelongTo belongTo, CardDisplay cardDisplay) { this.cardName = name; this.CardId = id; this.cardColor = color; this.cardWeight = weight; this.cardBelongTo = belongTo; this.cardDisplay = cardDisplay; }
/// <summary> /// Returns the respective image path for the specified card color /// </summary> /// <param name="color">The card color</param> /// <returns></returns> public static string GetCardImagePath(CardColors color) { if (!_cardImagesPaths.ContainsKey(color)) { throw new KeyNotFoundException(); } return(_cardImagesPaths[color]); }
public Card(string color, int points) { Color = (CardColors)Enum.Parse(typeof(CardColors), color, true); _faceValue = new FaceValue(points); _isOudler = CheckOudler(); _isFirst = false; _cardScore = CardCountingRules.GetPoints(IsTrumper(), _isOudler, _faceValue.GetPoints()); CheckConsistency(); }
public override void Apply(CardColors color) { if (_colors == null) return; _cardColors = color; _cardColorSetter = new CardColorSetter(_colors); _cardColorSetter.Initialize(ChangeTracker); _cardColors.AddModifier(_cardColorSetter); }
public override void Apply(CardColors color) { if (_colors == null) { return; } _cardColors = color; _cardColorSetter = new CardColorSetter(_colors); _cardColorSetter.Initialize(ChangeTracker); _cardColors.AddModifier(_cardColorSetter); }
/// <summary> /// Returns all available card colors /// </summary> /// <returns></returns> public static CardColors[] GetAllAvailableColors() { var result = new CardColors[] { CardColors.Orange, CardColors.Red, CardColors.Yellow }; if (result.Length < MIN_COUNT_OF_COLORS) { throw new Exception($"There should be at least {MIN_COUNT_OF_COLORS} colors."); } return(result); }
/// <summary> /// 10000元/同花顺子 /// </summary> /// <returns></returns> private static List <Card> GetLotteryNumber4SameColorSequence() { int cardNumbersIndex = int.Parse(GetRandomCardNumbers(1, STRAIGHTCARDNUMBERS)[0]) - 1;//取随机下标 CardColors color = GetRandomCardColor(1, CARDCOLOR)[0]; List <Card> list = new List <Card>(); Card card = new Card(); for (int i = 0; i < 5; i++) { card = new Card() { Number = CARDNUMBERS[cardNumbersIndex + i], Color = color }; list.Add(card); } return(list); }
/// <summary> /// 20000元/皇家同花顺 /// </summary> /// <returns></returns> private static List <Card> GetLotteryNumber4Maximum() { int cardNumbersIndex = 8;//取随机下标 CardColors color = GetRandomCardColor(1, CARDCOLOR)[0]; List <Card> list = new List <Card>(); Card card = new Card(); for (int i = 0; i < 5; i++) { card = new Card() { Number = CARDNUMBERS[cardNumbersIndex + i], Color = color }; list.Add(card); } return(list); }
/// <summary> /// 200元/同花 /// </summary> /// <returns></returns> private static List <Card> GetLotteryNumber4SameColor() { List <string> cardNumbers = GetRandomCardNumbers(5, CARDNUMBERS); CardColors color = GetRandomCardColor(1, CARDCOLOR)[0]; List <Card> list = new List <Card>(); Card card = new Card(); for (int i = 0; i < cardNumbers.Count; i++) { card = new Card() { Number = cardNumbers[i], Color = color }; list.Add(card); } return(list); }
public static Color ToColor(CardColors Clr) // конвертер цвета из CardColors в Color из пространства имен System.Drawing { switch (Clr) { case CardColors.Red: return(Color.Red); case CardColors.Yellow: return(Color.Yellow); case CardColors.Blue: return(Color.Blue); case CardColors.Green: return(Color.Green); } return(Color.Red); }
public static List <Card> CardFactory(int times) { List <Card> cardList = new(); for (; times != 0; times--) { CardColors colorPicker = (CardColors)(new Random().Next(5)); string cardNumber = CARDS[new Random().Next(CARDS.Length)]; bool isSpecial = colorPicker is CardColors.Preto || cardNumber == CARDS[10] || cardNumber == CARDS[11]; cardNumber = colorPicker switch { CardColors.Preto => BLACK_CARDS[new Random().Next(BLACK_CARDS.Length)], _ => cardNumber }; Card cardGenerated = new Card(cardNumber, colorPicker, isSpecial); cardList.Add(cardGenerated); } return(cardList); } }
public ChooseCardForm(List <UnoCard> list, CardType tp, CardColors cl) { InitializeComponent(); Size ImgSize = Helper.CardSize; this.CardReturn = -1; this.CardsList = list; this.TopCardType = tp; this.CurrentColor = cl; for (int i = 0; i < this.CardsList.Count; i++) { Label tmpLb = new Label() { Left = i * (ImgSize.Width / 2), Image = this.CardsList[i].CurrentImage, Size = this.CardsList[i].CurrentImage.Size }; this.playerPanel.Controls.Add(tmpLb); tmpLb.DoubleClick += tmpLb_DoubleClick; tmpLb.MouseMove += tmpLb_MouseMove; tmpLb.MouseLeave += tmpLb_MouseLeave; } this.FormClosing += ChooseCardForm_FormClosing; }
public virtual void Apply(CardColors colors) { }
private Card(string cardNumb, CardColors cardColor, bool isSpecial) { this.cardColor = cardColor; number = cardNumb; this.isSpecial = isSpecial; }
// Возможно не в этой задаче, но в игре в целом конструктор все же понадобится public Card(int rank, CardColors color) { Rank = rank; Color = color; }
public bool TryTellColor(CardColors color, List<int> selectedCardsIndexes) { for (var i = 0; i < cards.Count; i++) { if (selectedCardsIndexes.Contains(i)) { if (!cards[i].TryAddInfoAboutColor(color, null)) return false; } else { if (!cards[i].TryAddInfoAboutColor(null, color)) return false; } } return true; }
public Image GetImageByColorAndId(Figures figure, CardColors cardColor) { Image image = new Image { Source = this.cards[(int) figure, (int) cardColor], Height = this.CardSize, Width = this.CardSize }; return image; }
private string ReplaceCustomMarkupWithHTMLMarkup(string CardContent, List <string> markupContent, HtmlEncoder htmle, CardColors cardColor, Func <string, HtmlEncoder, CardColors, string> AlterCustomMarkupToHTMLMarkup) { foreach (var markup in markupContent) { CardContent = CardContent.Replace(htmle.Encode(markup), markup); } return(AlterCustomMarkupToHTMLMarkup(CardContent, htmle, cardColor)); }
private string AlterCustomBoldWordsToBoldTags(string cardContent, HtmlEncoder htmlEncoder, CardColors cardColor) { var modifiedCardContent = string.Empty; Match matchCollection; try { matchCollection = Regex.Match(cardContent, onScreenWhileEditing_BoldRegex_Pattern, RegexOptions.IgnoreCase | RegexOptions.Compiled, TimeSpan.FromSeconds(1)); if (matchCollection.Success) { modifiedCardContent = cardContent; while (matchCollection.Success) { var boldText_Replacement = matchCollection.Groups["boldText"].Value; boldText_Replacement = boldText_Replacement.Replace("<", htmlEncoder.Encode("<")); boldText_Replacement = boldText_Replacement.Replace(">", htmlEncoder.Encode(">")); boldText_Replacement = String.Concat($"<b style='font-family: ui-sans-serif; font-stretch: expanded; font-size: 125%; color:{nameof(cardColor)};'>", boldText_Replacement, "</b>"); modifiedCardContent = modifiedCardContent.Replace($"[bold]{matchCollection.Groups["boldText"].Value}[/bold]", boldText_Replacement); matchCollection = matchCollection.NextMatch(); } } else { modifiedCardContent = cardContent; } } catch (RegexMatchTimeoutException) { Console.WriteLine("The matching operation timed out."); } return(modifiedCardContent); }
private string AlterCustomLinksToHyperlinks(string cardContent, HtmlEncoder htmlEncoder, CardColors cardColor) { var modifiedCardContent = string.Empty; try { modifiedCardContent = Regex.Replace(cardContent, onScreenWhileEditing_LinkRegex_Pattern, onScreenWhileViewing_MainLinkRegex_Replacement); } catch (RegexMatchTimeoutException) { Console.WriteLine("The matching operation timed out."); } return(modifiedCardContent); }
private void setColor(CardColors clr) { this.lbCurrentColor.BackColor = Helper.ToColor(clr); }
public ColorMap(string value, CardColors colors) { Value = value; CardColors = colors; }
public Card(CardColors color, CardFigures figure) { this.color = color; this.figure = figure; }
/// <summary> /// Creates an instance of a card /// </summary> /// <param name="color">The card color</param> public Card(CardColors color) : base(CellTypes.Card) { Color = color; }
public bool TryAddInfoAboutColor(CardColors? color, CardColors? notColor) { if (color.HasValue) if (color.Value != RealCard.Color) return false; else ColorIsKnown = true; if (notColor.HasValue) if (RealCard.Color == notColor.Value) return false; else NotThisColors.Add(notColor.Value); if (NotThisColors.Count == 4) ColorIsKnown = true; return true; }
public void TellColor(CardColors color, List<int> selectedCardsIndexes) { if (gameIsOver) return; var nextPlayersHand = playersHands[GetNextPlayer()]; if (!nextPlayersHand.TryTellColor(color, selectedCardsIndexes)) gameIsOver = true; }