public override BaseCard CreateCopy() { SampleMinionCard result = new SampleMinionCard(); this.CopyValuesTo(result); return(result); }
private static string ApplyCardsToLine(SampleMatch match, bool isBorderLine, int row, string orgline, int cardrow) { int numCards = match.GetNumberOfCards(row); if (numCards == 0) { return(orgline); } int startX = GetFirstCardPositionX(match, row); string line = "+"; string emptyLine = "|"; for (int j = 0; j < numCards; j++) { line += "=====+"; SampleMinionCard card = match.Playfield[j, row] as SampleMinionCard; if (card != null) { switch (cardrow) { case 1: if (card.IsSleeping) { emptyLine += " Zzz |"; } else { emptyLine += " " + card.CurrentMovesPerRound + " |"; } break; case 2: emptyLine += "A" + card.Attack.ToString("D3") + " |"; break; case 3: emptyLine += "L" + card.CurrentHealth.ToString("D3") + " |"; break; default: emptyLine += " |"; break; } } else { emptyLine += " |"; } } string lineToUse = isBorderLine ? line : emptyLine; return(orgline.Remove(startX, lineToUse.Length).Insert(startX, lineToUse)); }
public void InitCollection() { // Create minions with more attack than health for (int i = 0; i < 10; i++) { SampleMinionCard card = new SampleMinionCard(); card.Attack = (i + 1); card.MaxHealth = (i + 2); card.Cost = (i + 1); card.MaxMovesPerRound = 1; CardCollection.Add(card); } // Create minions with more health than attack for (int i = 0; i < 10; i++) { SampleMinionCard card = new SampleMinionCard(); card.Attack = (i + 2); card.MaxHealth = (i + 1); card.Cost = (i + 1); card.MaxMovesPerRound = 1; CardCollection.Add(card); } // Create damage spells for (int i = 0; i < 10; i++) { SampleSpellCard card = new SampleSpellCard(); card.SpellPower = -(i + 1); card.Cost = (i + 1); CardCollection.Add(card); } // Create heal spells for (int i = 0; i < 10; i++) { SampleSpellCard card = new SampleSpellCard(); card.SpellPower = (i + 1); card.Cost = (i + 1); CardCollection.Add(card); } Console.WriteLine("Card collection:"); foreach (var card in CardCollection) { Console.WriteLine(card.ToString()); } }
/// <summary> /// Returns a list of minions who can still perform some action in this round. /// </summary> private SampleMinionCard[] GetUsableMinions() { List <SampleMinionCard> result = new List <SampleMinionCard>(); SampleBaseCard[] cardsOnPlayfield = ActiveSampleMatch.GetCardsForPlayer(this); for (int i = 0; i < cardsOnPlayfield.Length; i++) { SampleMinionCard card = (SampleMinionCard)cardsOnPlayfield[i]; if (card.CurrentMovesPerRound > 0) { result.Add(card); } } return(result.ToArray()); }
private void AttackEnemyWithCards(SampleBaseCard[] cards, SampleMinionCard victimMinion) { int victimRow = 0; int victimIndex = 0; if (victimMinion != null) { if (ActiveSampleMatch.GetPlayfieldPositionForCard(victimMinion, out victimRow, out victimIndex) == false) { return; } } else { victimRow = ActiveSampleMatch.GetRowForPlayer(ActiveSampleMatch.InactiveSamplePlayer); victimIndex = -1; } for (int i = 0; i < cards.Length; i++) { if (cards[i].CardType == SampleCardType.Minion) { SampleMinionCard minion = (SampleMinionCard)cards[i]; int row = 0; int index = 0; if (ActiveSampleMatch.GetPlayfieldPositionForCard(minion, out row, out index) == true) { Logger.Log("[AI] Attacking '" + (victimMinion != null ? victimMinion.ToString() : "enemy hero") + "' with minion '" + minion + "' at position " + index + "."); ActiveSampleMatch.AttackWithCardUsingIndexes(row, index, victimRow, victimIndex); return; } } else if (cards[i].CardType == SampleCardType.Spell) { SampleSpellCard spell = (SampleSpellCard)cards[i]; Logger.Log("[AI] Casting damage spell '" + spell + "' on victim '" + (victimMinion != null ? victimMinion.ToString() : "enemy hero") + "'."); PlayCardFromHand(spell, victimIndex, victimRow); return; } } }
protected override void ActivatePlayer(BasePlayer player) { base.ActivatePlayer(player); if (player != null) { int row = GetRowForPlayer(player as SamplePlayer); if (row >= 0) { for (int i = 0; i < PlayfieldWidth; i++) { SampleMinionCard card = Playfield[i, row] as SampleMinionCard; if (card != null) { card.ApplyStartOfRoundEffect(player); } } } } }
public bool PlayMinionCard(SampleMinionCard card, SamplePlayer player, int x, int y) { if (CanPlayCard(card, player, x, y) == false) { return(false); } int row = GetRowForPlayer(player); if (row == -1) { return(false); } InsertCard(card, x, row); card.ApplyPlayEffect(); return(true); }
private SampleMinionCard[] GetOwnDamagedMinions() { List <SampleMinionCard> result = new List <SampleMinionCard>(); SampleBaseCard[] minons = ActiveSampleMatch.GetCardsForPlayer(this); for (int i = 0; i < minons.Length; i++) { if (minons[i].CardType == SampleCardType.Minion) { SampleMinionCard minion = (SampleMinionCard)minons[i]; if (minion.CurrentHealth < minion.MaxHealth) { result.Add(minion); } } } return(result.ToArray()); }
public bool CanPlayMinionCard(SampleMinionCard card, SamplePlayer player, int x, int y) { int row = GetRowForPlayer(player); if (row == -1) { return(false); } int numCardsOnPlayfield = GetNumberOfCards(row); if (numCardsOnPlayfield >= PlayfieldWidth) { return(false); } if (x > numCardsOnPlayfield) { return(false); } return(true); }
public bool AttackWithCardUsingIndexes(int attackerRow, int attackerIndex, int victimRow, int victimIndex) { if (attackerIndex == -1) { // Hero attack is not supported return(false); } SampleMinionCard minion = Playfield[attackerIndex, attackerRow] as SampleMinionCard; if (minion == null) { return(false); } if (victimIndex == -1) { if (minion.ApplyPreActionEffect() == false) { Logger.Log("AttackWithCardUsingIndexes of card '" + minion + "' was aborted by PreAction trigger"); return(false); } // Target is hero SamplePlayer pl = playerList[victimRow] as SamplePlayer; pl.ReceiveHealth(-minion.Attack); if (pl.CurrentHealth < 0) { DeclareLoser(pl); } minion.ApplyPostActionEffect(); return(true); } SampleMinionCard targetMinion = Playfield[victimIndex, victimRow] as SampleMinionCard; if (targetMinion == null) { return(false); } if (minion.ApplyPreActionEffect() == false) { Logger.Log("AttackWithCardUsingIndexes of card '" + minion + "' was aborted by PreAction trigger"); return(false); } if (targetMinion.ApplyPreAttackedEffect(minion) == false) { Logger.Log("AttackWithCardUsingIndexes of card '" + minion + "' was aborted by PreAttack trigger of target card '" + targetMinion + "'"); return(false); } if (minion.ApplyPreAttackedEffect(targetMinion) == false) { Logger.Log("AttackWithCardUsingIndexes of card '" + minion + "' was aborted by PreAttack trigger of source card '" + minion + "'"); return(false); } targetMinion.CurrentHealth -= minion.Attack; minion.CurrentHealth -= targetMinion.Attack; targetMinion.ApplyPostAttackedEffect(minion); minion.ApplyPostAttackedEffect(targetMinion); if (minion.CurrentHealth <= 0) { minion.ApplyDeathEffect(); RemoveCard(attackerIndex, attackerRow); } if (targetMinion.CurrentHealth <= 0) { targetMinion.ApplyDeathEffect(); RemoveCard(victimIndex, victimRow); } minion.ApplyPostActionEffect(); return(true); }
public bool PlaySpellCard(SampleSpellCard card, SamplePlayer player, int x, int y) { if (CanPlaySpellCard(card, player, x, y) == false) { return(false); } if (x == -1) { if (card.ApplyPreActionEffect() == false) { Logger.Log("PlaySpellCard of card '" + card + "' was aborted by PreAction trigger"); return(false); } // Target is hero SamplePlayer pl = playerList[y] as SamplePlayer; pl.ReceiveHealth(card.SpellPower); if (pl.CurrentHealth < 0) { DeclareLoser(pl); } card.ApplyPostActionEffect(); return(true); } SampleMinionCard targetCard = Playfield[x, y] as SampleMinionCard; if (targetCard == null) { return(false); } if (card.ApplyPreActionEffect() == false) { Logger.Log("PlaySpellCard of card '" + card + "' was aborted by PreAction trigger"); return(false); } if (targetCard.ApplyPreTargetEffect(card) == false) { Logger.Log("PlaySpellCard of card '" + card + "' was aborted by PreTarget trigger of target card '" + targetCard + "'"); return(false); } targetCard.CurrentHealth += card.SpellPower; targetCard.ApplyPostTargetEffect(card); if (targetCard.CurrentHealth <= 0) { targetCard.ApplyDeathEffect(); RemoveCard(x, y); } if (targetCard.CurrentHealth > targetCard.MaxHealth) { targetCard.CurrentHealth = targetCard.MaxHealth; } card.ApplyPostActionEffect(); return(true); }