// Process a move generated either over network or locally and resolve it's events // This function will not perform anything if the move is invalid public void ProcessMove(Move nextMove) { if (nextMove.Selected == OPP_CONCEDE) { PlayerTwo.Health = 0; return; } else if (nextMove.Selected == TURN_PASS) { SwitchTurns(); return; } else if (nextMove.Selected == CARD_DRAW) { ActivePlayer.ManualDrawCard(); return; } BaseCard Selected = nextMove.Selected.AsCard(); BaseCard Targeted = nextMove.Targeted.AsCard(); if (IsP1Turn && !Selected.IsPlayable(nextMove)) { return; } this.LastMove = nextMove; Selected.Owner.Hand.Remove(Selected); Selected.Play(); ResolveActions(); }
// Gives a card am ID and adds it to the list of registered cards. public static uint NextId(BaseCard newCard) { if (CurrMaxId == uint.MaxValue) { throw new OverflowException(); } ExistingCards.Add(CurrMaxId, newCard); CurrMaxId += 1; return(CurrMaxId - 1); }
private void PassButton_Click(object sender, EventArgs e) { HideNotif(); if (!Game.IsP1Turn) { return; } SelectedCard = null; Game.ProcessMove(new Move(GameState.TURN_PASS, 0)); Net.Send(new Move(GameState.TURN_PASS, 0)); RenderState(Game); }
public PlayerBox(BaseCard card) : base(card) { Height = Width; Controls.Clear(); Click += (_s, _e) => { GameBox Box = (Parent as GameBox); if (Box.SelectedCard == null) { return; } Move NextMove = new Move(Box.SelectedCard.Id, card.Game.PlayerTwo.PlayerCard.Id); if (Box.SelectedCard.IsPlayable(NextMove)) { Box.Game.ProcessMove(NextMove); Box.Net.Send(NextMove); } Box.SelectedCard = null; Box.RenderState(Box.Game); }; HealthLabel = new Label(); Controls.Add(HealthLabel); }
private void ResetButton_Click(object sender, EventArgs e) { HideNotif(); SelectedCard = null; RenderState(Game); }
public CardBox(BaseCard card) : base() { CardReferenced = card; Size = new Size(GameBox.CARD_WIDTH, GameBox.CARD_HEIGHT); BackgroundImage = Properties.Resources.CardBody; CardArt = new PictureBox() { // Determined by measuring ratios on a standard screen size Size = new Size(74, 74), Location = new Point(13, 13), }; if (CardReferenced.Art != null) { CardArt.Image = CardReferenced.Art; } CardName = new Label() { Text = card.Name, Location = new Point(5, 13 + 74 + 13), Size = new Size(90, 25), TextAlign = ContentAlignment.MiddleCenter, BackColor = CARD_COLOR, ForeColor = Color.White, Font = GameBox.CFont.GetFont(12), }; CardInfo = new TextBox() { TextAlign = HorizontalAlignment.Center, Multiline = true, ReadOnly = true, Location = new Point(5, 13 + 74 + 13 + 25 + 7), Size = new Size(90, 65), Lines = new string[] { card.Description }, BackColor = CARD_COLOR, BorderStyle = BorderStyle.None, ForeColor = Color.White, Cursor = Cursors.Arrow, Font = GameBox.CFont.GetFont(9), }; CardCost = new Label() { Text = CardReferenced.ManaCost.ToString(), Size = new Size(22, 22), Top = GameBox.CARD_HEIGHT - 22 - 4, Left = 4, Font = GameBox.CFont.GetFont(12), ForeColor = Color.White, TextAlign = ContentAlignment.MiddleCenter, Image = Properties.Resources.ManaBox, }; CardHidden = new PictureBox() { Image = Properties.Resources.CardFlipped, Visible = CardReferenced.Owner == CardReferenced.Game.PlayerTwo && (!(CardReferenced is MinionCard m) || !m.OnBoard) && CardReferenced.Game.CurrentPower as BaseCard != CardReferenced, Left = 0, Top = 0, Height = GameBox.CARD_HEIGHT, Width = GameBox.CARD_WIDTH, }; Controls.Add(CardHidden); CardPlayableIndicator = new Control() { Size = new Size(6, 6), Top = GameBox.CARD_HEIGHT - 6 - 12, // Centred between CardCost and CardHealth Left = 36, ForeColor = Color.White, BackColor = card.ManaCost <= card.Game.PlayerOne.Mana && card.Game.IsP1Turn ? GREEN_IND : RED_IND, }; Controls.Add(CardPlayableIndicator); CardPlayableIndicator.BringToFront(); Controls.Add(CardArt); Controls.Add(CardInfo); Controls.Add(CardName); Controls.Add(CardCost); CardCost.BringToFront(); // Different visual effects for minion cards if (card is MinionCard minion) { CardAttack = new Label() { Text = minion.Attack.ToString(), Size = new Size(22, 22), Top = GameBox.CARD_HEIGHT - 22 - 4, Left = GameBox.CARD_WIDTH - 4 - 22 - 22, Font = GameBox.CFont.GetFont(12), ForeColor = Color.White, TextAlign = ContentAlignment.MiddleCenter, Image = Properties.Resources.AttackBox, }; Controls.Add(CardAttack); CardAttack.BringToFront(); CardHealth = new Label() { Text = minion.Health.ToString(), Size = new Size(22, 22), Top = GameBox.CARD_HEIGHT - 22 - 4, Left = GameBox.CARD_WIDTH - 4 - 22, Font = GameBox.CFont.GetFont(12), ForeColor = Color.White, TextAlign = ContentAlignment.MiddleCenter, Image = Properties.Resources.HealthBox, }; Controls.Add(CardHealth); CardHealth.BringToFront(); if (minion.OnBoard) { CardPlayableIndicator.BackColor = minion.CanAttack ? GREEN_IND : RED_IND; } if (minion.Owner == minion.Game.PlayerTwo) { CardPlayableIndicator.Visible = false; } //CardAttack.Text = (CardReferenced as MinionCard).Attack.ToString(); } CardHidden.BringToFront(); // Ensures clicking anywhere on the card counts as a click foreach (Control c in Controls) { c.Click += (_s, _e) => { CardClicked(this); } } ; this.Click += (_s, _e) => { CardClicked(this); }; }