public bool PlayCardFromHand(SampleBaseCard card, int arenaX, int arenaY) { if (card == null) { return(false); } if (CanPlayCard(card, arenaX, arenaY) == false) { return(false); } if (Hand.RemoveCard(card) == false) { return(false); } if (PlayCard(card, arenaX, arenaY) == false) { return(false); } this.CurrentMana -= card.Cost; return(true); }
private bool CheckIfAnyActionIsPossible() { if (ActiveSampleMatch.IsRunning == false) { // Match is over, so no action is possible return(false); } bool canPlayAtLeastOneCard = false; for (int i = 0; i < Hand.Cards.Count; i++) { SampleBaseCard card = (SampleBaseCard)Hand.Cards[i]; if (CurrentMana >= card.Cost) { canPlayAtLeastOneCard = true; break; } } SampleMinionCard[] minions = GetUsableMinions(); bool canDoAtLeastOneMove = minions.Length > 0; return(canDoAtLeastOneMove || canPlayAtLeastOneCard); }
/// <summary> /// Gets maximum amount of spell damage, that can be dealt in this round, with the current hand and remaining mana. /// </summary> /// <returns>The cards necessary to deal the damage</returns> /// <param name="totalDamage">Total damage. Will be negative values</param> private SampleSpellCard[] GetSpellDamage(out int totalDamage) { totalDamage = 0; int currentMana = CurrentMana; List <SampleSpellCard> cards = new List <SampleSpellCard>(); for (int i = 0; i < Hand.Cards.Count; i++) { SampleBaseCard card = (SampleBaseCard)Hand.Cards[i]; if (card.CardType == SampleCardType.Spell) { SampleSpellCard spell = (SampleSpellCard)card; if (spell.SpellPower < 0 && spell.Cost <= currentMana) { // It's a damage spell totalDamage += -spell.SpellPower; cards.Add(spell); currentMana -= spell.Cost; } } } return(cards.ToArray()); }
private void InsertCard(SampleBaseCard card, int position, int row) { for (int i = PlayfieldWidth - 1; i > position; i--) { Playfield[i, row] = Playfield[i - 1, row]; } Playfield[position, row] = card; }
private bool PlayCard(SampleBaseCard card, int arenaX, int arenaY) { if (ActiveSampleMatch != null) { if (ActiveSampleMatch.PlayCard(card, this, arenaX, arenaY) == false) { return(false); } } return(true); }
public bool PlayCard(SampleBaseCard card, SamplePlayer player, int x, int y) { if (card.CardType == SampleCardType.Minion) { return(PlayMinionCard(card as SampleMinionCard, player, x, y)); } else if (card.CardType == SampleCardType.Spell) { return(PlaySpellCard(card as SampleSpellCard, player, x, y)); } return(false); }
private bool CanPlayCard(SampleBaseCard card, int arenaX, int arenaY) { if (CurrentMana < card.Cost) { return(false); } if (ActiveSampleMatch != null) { if (ActiveSampleMatch.CanPlayCard(card, this, arenaX, arenaY) == false) { return(false); } } return(true); }
private SampleSpellCard[] GetHealingSpells() { List <SampleSpellCard> result = new List <SampleSpellCard>(); for (int i = 0; i < Hand.Cards.Count; i++) { SampleBaseCard card = (SampleBaseCard)Hand.Cards[i]; if (card.CardType == SampleCardType.Spell) { SampleSpellCard spell = (SampleSpellCard)card; if (spell.SpellPower > 0) { result.Add(spell); } } } return(result.ToArray()); }
/// <summary> /// Gets the playfield position for card. /// </summary> /// <returns><c>true</c>, if playfield position for card was gotten, <c>false</c> if the card is not on the playfield.</returns> /// <param name="card">Card.</param> /// <param name="row">Row.</param> /// <param name="index">Index.</param> public bool GetPlayfieldPositionForCard(SampleBaseCard card, out int row, out int index) { row = -1; index = -1; for (int y = 0; y < PlayfieldHeight; y++) { for (int x = 0; x < PlayfieldWidth; x++) { if (Playfield[x, y] == card) { row = y; index = x; return(true); } } } return(false); }
private bool TryPlayMinion() { Logger.Log("[AI] Checking TryPlayMinion"); List <SampleMinionCard> minions = new List <SampleMinionCard>(); for (int i = 0; i < Hand.Cards.Count; i++) { SampleBaseCard card = (SampleBaseCard)Hand.Cards[i]; if (card.CardType == SampleCardType.Minion) { minions.Add(card as SampleMinionCard); } } if (minions.Count == 0) { Logger.Log("[AI] Got zero minions on hand. Not possible to play one."); return(false); } for (int i = 0; i < minions.Count; i++) { if (minions[i].Cost <= CurrentMana) { if (PlayCardFromHand(minions[i], 0, ActiveSampleMatch.GetRowForPlayer(this)) == true) { Logger.Log("[AI] Played minion '" + minions[i] + "' to playfield."); return(true); } } } Logger.Log("[AI] Got some minions on hand, but can't play any."); return(false); }