Ejemplo n.º 1
0
 internal void SendToGraveYard(System.Object c, Zone z)
 {
     if (z == Zone.Hand)
     {
         if (Hand.Contains(c as Cards.Card))
         {
             Hand.Remove(c as Cards.Card);
             MeReadOnly.NumberOfCardsInHand = MeReadOnly.NumberOfCardsInHand - 1;
         }
     }
     else if (z == Zone.Monster)
     {
         if (FaceDownCardsInMonsterZone.Contains(c as MonsterCard))
         {
             FaceDownCardsInMonsterZone.Remove(c as MonsterCard);
             SpellAndTrapCard attachedTo = (c as MonsterCard).EquippedTo;
             if (attachedTo != null)
             {
                 SendToGraveYard(attachedTo, Zone.SpellTrap);
             }
             MeReadOnly.NumberOfFaceDownCardsInMonsterZone = MeReadOnly.NumberOfFaceDownCardsInMonsterZone - 1;
         }
         else if (MeReadOnly.FaceUpMonsters.Contains(c as MonsterCard))
         {
             List <MonsterCard> toRemoveFrom = MeReadOnly.FaceUpMonsters;
             toRemoveFrom.Remove(c as MonsterCard);
             SpellAndTrapCard attachedTo = (c as MonsterCard).EquippedTo;
             if (attachedTo != null)
             {
                 SendToGraveYard(attachedTo, Zone.SpellTrap);
             }
             MeReadOnly.FaceUpMonsters = toRemoveFrom;
         }
     }
     else if (z == Zone.SpellTrap)
     {
         if (FaceDownTraps.Contains(c as SpellAndTrapCard))
         {
             FaceDownTraps.Remove(c as SpellAndTrapCard);
             MeReadOnly.NumberOfFaceDownTraps--;
         }
         else if (MeReadOnly.FaceUpTraps.Contains(c as SpellAndTrapCard))
         {
             List <SpellAndTrapCard> toRemoveFrom = MeReadOnly.FaceUpTraps;
             toRemoveFrom.Remove(c as SpellAndTrapCard);
             MeReadOnly.FaceUpTraps = toRemoveFrom;
         }
     }
     GraveYard.Add(c as Cards.Card);
 }
Ejemplo n.º 2
0
 internal void SendToHand(System.Object c, Zone z)
 {
     if (z == Zone.Graveyard)
     {
         if (GraveYard.Contains(c as Cards.Card))
         {
             GraveYard.Remove(c as Cards.Card);
         }
     }
     else if (z == Zone.Monster)
     {
         if (FaceDownCardsInMonsterZone.Contains(c as MonsterCard))
         {
             FaceDownCardsInMonsterZone.Remove(c as MonsterCard);
             MeReadOnly.NumberOfFaceDownCardsInMonsterZone = MeReadOnly.NumberOfFaceDownCardsInMonsterZone - 1;
         }
         else if (MeReadOnly.FaceUpMonsters.Contains(c as MonsterCard))
         {
             List <MonsterCard> toRemoveFrom = MeReadOnly.FaceUpMonsters;
             toRemoveFrom.Remove(c as MonsterCard);
             MeReadOnly.FaceUpMonsters = toRemoveFrom;
         }
     }
     else if (z == Zone.SpellTrap)
     {
         if (FaceDownTraps.Contains(c as SpellAndTrapCard))
         {
             FaceDownTraps.Remove(c as SpellAndTrapCard);
             MeReadOnly.NumberOfFaceDownTraps--;
         }
         else if (MeReadOnly.FaceUpTraps.Contains(c as SpellAndTrapCard))
         {
             List <SpellAndTrapCard> toRemoveFrom = MeReadOnly.FaceUpTraps;
             toRemoveFrom.Remove(c as SpellAndTrapCard);
             MeReadOnly.FaceUpTraps = toRemoveFrom;
         }
     }
     Hand.Add(c as Cards.Card);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// A request to cast spell or set trap is given to the game class. If allowable, it will be used.
 /// </summary>
 /// <param name="spellOrTrapToPlay">A SpellAndTrapCard to play.</param>
 /// <returns>"" if successful. Error string if failed.</returns>
 public string CastSpellOrTrap(System.Object spellOrTrapToPlay)
 {
     if (spellOrTrapToPlay is SpellAndTrapCard && Hand.Contains(spellOrTrapToPlay as Cards.Card))
     {
         SpellAndTrapCard stc = spellOrTrapToPlay as SpellAndTrapCard;
         Result           amIAllowedToSummon;
         if (stc.CardName.Equals("Dark Hole"))
         {
             amIAllowedToSummon = MyCurrentGame.RequestDarkHole(id);
             if (amIAllowedToSummon == Result.Success)
             {
                 SendToGraveYard(spellOrTrapToPlay, Zone.Hand);
             }
         }
         else if (stc.CardName.Equals("Red Medicine"))
         {
             amIAllowedToSummon = MyCurrentGame.RequestRedMedicine(id);
             if (amIAllowedToSummon == Result.Success)
             {
                 SendToGraveYard(spellOrTrapToPlay, Zone.Hand);
             }
         }
         else if (stc.CardName.Equals("Sparks"))
         {
             amIAllowedToSummon = MyCurrentGame.RequestSparks(id);
             if (amIAllowedToSummon == Result.Success)
             {
                 SendToGraveYard(spellOrTrapToPlay, Zone.Hand);
             }
         }
         else if (stc.CardName.Equals("Fissure"))
         {
             amIAllowedToSummon = MyCurrentGame.RequestFissure(id);
             if (amIAllowedToSummon == Result.Success)
             {
                 SendToGraveYard(spellOrTrapToPlay, Zone.Hand);
             }
         }
         else if (stc.CardName.Equals("Trap Hole"))
         {
             amIAllowedToSummon = MyCurrentGame.RequestTrapHole(id);
             if (amIAllowedToSummon == Result.Success)
             {
                 FaceDownTraps.Add(spellOrTrapToPlay as SpellAndTrapCard);
                 MeReadOnly.NumberOfFaceDownTraps = FaceDownTraps.Count;
                 Hand.Remove(spellOrTrapToPlay as Cards.Card);
                 MeReadOnly.NumberOfCardsInHand--;
             }
         }
         else if (stc.CardName.Equals("Two-Pronged Attack"))
         {
             MonsterCard myOne = myGm.PromptForOneOfMyMonstersOnField();
             MonsterCard myTwo = myGm.PromptForOneOfMyMonstersOnField();
             MonsterCard possibleTheirsCard  = null;
             int         possibleTheirsIndex = -1;
             myGm.PromptForOneOfOpponentsMonstersOnField(out possibleTheirsCard, out possibleTheirsIndex);
             if (myOne != myTwo && myOne != null && myTwo != null && possibleTheirsCard != null)
             {
                 amIAllowedToSummon = MyCurrentGame.RequestTwoProngedAttack(id, myOne, myTwo, possibleTheirsCard);
                 if (amIAllowedToSummon == Result.Success)
                 {
                     SendToGraveYard(spellOrTrapToPlay, Zone.Hand);
                 }
             }
             else
             {
                 amIAllowedToSummon = Result.InvalidMove;
             }
         }
         else if (stc.CardName.Equals("De-Spell"))
         {
             SpellAndTrapCard possibleTheirsCard = null;
             int possibleTheirsIndex             = -1;
             myGm.PromptForOneOfOpponentsSpellsOrTrapsOnField(out possibleTheirsCard, out possibleTheirsIndex);
             if (possibleTheirsCard != null)
             {
                 amIAllowedToSummon = MyCurrentGame.RequestDeSpell(id, possibleTheirsCard);
             }
             else if (possibleTheirsIndex != -1)
             {
                 amIAllowedToSummon = MyCurrentGame.RequestDeSpell(id, possibleTheirsIndex);
             }
             else
             {
                 amIAllowedToSummon = Result.InvalidMove;
             }
         }
         else
         {
             amIAllowedToSummon = Result.InvalidMove;
         }
         if (amIAllowedToSummon.ToString().Equals("Success"))
         {
             return("");
         }
         else
         {
             return(amIAllowedToSummon.ToString());
         }
     }
     else
     {
         return("Either Card is not a monster or the card is not in your hand!");
     }
 }