コード例 #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);
 }
コード例 #2
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!");
     }
 }
コード例 #3
0
 ///<summary>
 ///Returns either a face up Spell/Trap card air tapped by user from his/her opponent's Spell/Trap zone
 ///OR the index of a face down Spell/Trap card air tapped by user from his/her opponent's Spell/Trap zone
 ///</summary>
 public void PromptForOneOfOpponentsSpellsOrTrapsOnField(out SpellAndTrapCard faceUpSpellOrTrap, out int faceDownSpellOrTrapIndex)
 {
     //TODO CODE
     faceUpSpellOrTrap        = null;
     faceDownSpellOrTrapIndex = -1;
 }
コード例 #4
0
        private void LoadAllPossibleCards()
        {
            try
            {
                TextAsset database = Resources.Load("CardMaster") as TextAsset;
                string    allLines = database.text;
                Debug.Log("Loaded CardMaster Text Asset");
                string[] splitIntoIndividualLines = allLines.Split('\n');
                Debug.Log("Number of Lines: " + splitIntoIndividualLines.Length);
                for (int i = 1; i < splitIntoIndividualLines.Length; i++)
                {
                    string[] split = splitIntoIndividualLines[i].Split(',');
                    Debug.Log("Line starting with " + split[0] + " has length " + split.Length);
                    Assets.Scripts.BattleHandler.Cards.Card c = new Assets.Scripts.BattleHandler.Cards.Card();
                    string imageName = split[14].Substring(0, split[14].IndexOf("."));
                    Debug.Log("Found Image Name: " + imageName);
                    Texture bi = Resources.Load(imageName) as Texture;
                    if (split[2] == "Spell")
                    {
                        if (split[3] == "Continuous")
                        {
                            c = new SpellAndTrapCard(split[0], CardAttributeOrType.Spell, Icon.Continuous, split[6], long.Parse(split[7]), bi);
                        }
                        else if (split[3] == "Counter")
                        {
                            c = new SpellAndTrapCard(split[0], CardAttributeOrType.Spell, Icon.Counter, split[6], long.Parse(split[7]), bi);
                        }
                        else if (split[3] == "Equip")
                        {
                            //string s = split[0];
                            //string s1 = split[6];
                            //string s2 = split[7];
                            c = new SpellAndTrapCard(split[0], CardAttributeOrType.Spell, Icon.Equip, split[6], long.Parse(split[7]), bi);
                        }
                        else if (split[3] == "Field")
                        {
                            c = new SpellAndTrapCard(split[0], CardAttributeOrType.Spell, Icon.Field, split[6], long.Parse(split[7]), bi);
                        }
                        else if (split[3] == "QuickPlay")
                        {
                            c = new SpellAndTrapCard(split[0], CardAttributeOrType.Spell, Icon.QuickPlay, split[6], long.Parse(split[7]), bi);
                        }
                        else if (split[3] == "Ritual")
                        {
                            c = new SpellAndTrapCard(split[0], CardAttributeOrType.Spell, Icon.Ritual, split[6], long.Parse(split[7]), bi);
                        }
                        else
                        {
                            c = new SpellAndTrapCard(split[0], CardAttributeOrType.Spell, Icon.Normal, split[6], long.Parse(split[7]), bi);
                        }
                    }
                    else if (split[2] == "Trap")
                    {
                        if (split[3] == "Continuous")
                        {
                            c = new SpellAndTrapCard(split[0], CardAttributeOrType.Trap, Icon.Continuous, split[6], long.Parse(split[7]), bi);
                        }
                        else if (split[3] == "Counter")
                        {
                            c = new SpellAndTrapCard(split[0], CardAttributeOrType.Trap, Icon.Counter, split[6], long.Parse(split[7]), bi);
                        }
                        else if (split[3] == "Equip")
                        {
                            c = new SpellAndTrapCard(split[0], CardAttributeOrType.Trap, Icon.Equip, split[6], long.Parse(split[7]), bi);
                        }
                        else if (split[3] == "Field")
                        {
                            c = new SpellAndTrapCard(split[0], CardAttributeOrType.Trap, Icon.Field, split[6], long.Parse(split[7]), bi);
                        }
                        else if (split[3] == "QuickPlay")
                        {
                            c = new SpellAndTrapCard(split[0], CardAttributeOrType.Trap, Icon.QuickPlay, split[6], long.Parse(split[7]), bi);
                        }
                        else if (split[3] == "Ritual")
                        {
                            c = new SpellAndTrapCard(split[0], CardAttributeOrType.Trap, Icon.Ritual, split[6], long.Parse(split[7]), bi);
                        }
                        else
                        {
                            c = new SpellAndTrapCard(split[0], CardAttributeOrType.Trap, Icon.Normal, split[6], long.Parse(split[7]), bi);
                        }
                    }
                    else if (split[2] == "Dark")
                    {
                        bool isPendulum     = false;
                        bool isXyz          = false;
                        bool isSynchro      = false;
                        bool isSynchroTuner = false;
                        bool isFusion       = false;
                        bool isRitual       = false;

                        if (split[8].ToUpper() == "Y")
                        {
                            isPendulum = true;
                        }
                        if (split[9].ToUpper() == "Y")
                        {
                            isXyz = true;
                            Debug.Log("Cannot have XYZ Monsters in Main Deck.");
                            //return false;
                        }
                        if (split[10].ToUpper() == "Y")
                        {
                            isSynchro = true;
                            Debug.Log("Cannot have Synchro Monsters in Main Deck.");
                            //return false;
                        }
                        if (split[11].ToUpper() == "Y")
                        {
                            isSynchroTuner = true;
                        }
                        if (split[12].ToUpper() == "Y")
                        {
                            isFusion = true;
                            Debug.Log("Cannot have Fusion Monsters in Main Deck.");
                            //return false;
                        }
                        if (split[13].ToUpper() == "Y")
                        {
                            isRitual = true;
                        }

                        c = new MonsterCard(split[0], int.Parse(split[1]), CardAttributeOrType.Dark, split[3], int.Parse(split[4]), int.Parse(split[5]), split[6], long.Parse(split[7]), isPendulum, isXyz, isSynchro, isSynchroTuner, isFusion, isRitual, bi);
                    }
                    else if (split[2] == "Earth")
                    {
                        bool isPendulum     = false;
                        bool isXyz          = false;
                        bool isSynchro      = false;
                        bool isSynchroTuner = false;
                        bool isFusion       = false;
                        bool isRitual       = false;

                        if (split[8].ToUpper() == "Y")
                        {
                            isPendulum = true;
                        }
                        if (split[9].ToUpper() == "Y")
                        {
                            isXyz = true;
                            Debug.Log("Cannot have XYZ Monsters in Main Deck.");
                            //return false;
                        }
                        if (split[10].ToUpper() == "Y")
                        {
                            isSynchro = true;
                            Debug.Log("Cannot have Synchro Monsters in Main Deck.");
                            //return false;
                        }
                        if (split[11].ToUpper() == "Y")
                        {
                            isSynchroTuner = true;
                        }
                        if (split[12].ToUpper() == "Y")
                        {
                            isFusion = true;
                            Debug.Log("Cannot have Fusion Monsters in Main Deck.");
                            //return false;
                        }
                        if (split[13].ToUpper() == "Y")
                        {
                            isRitual = true;
                        }

                        c = new MonsterCard(split[0], int.Parse(split[1]), CardAttributeOrType.Earth, split[3], int.Parse(split[4]), int.Parse(split[5]), split[6], long.Parse(split[7]), isPendulum, isXyz, isSynchro, isSynchroTuner, isFusion, isRitual, bi);
                    }
                    else if (split[2] == "Fight")
                    {
                        bool isPendulum     = false;
                        bool isXyz          = false;
                        bool isSynchro      = false;
                        bool isSynchroTuner = false;
                        bool isFusion       = false;
                        bool isRitual       = false;

                        if (split[8].ToUpper() == "Y")
                        {
                            isPendulum = true;
                        }
                        if (split[9].ToUpper() == "Y")
                        {
                            isXyz = true;
                            Debug.Log("Cannot have XYZ Monsters in Main Deck.");
                            // return false;
                        }
                        if (split[10].ToUpper() == "Y")
                        {
                            isSynchro = true;
                            Debug.Log("Cannot have Synchro Monsters in Main Deck.");
                            // return false;
                        }
                        if (split[11].ToUpper() == "Y")
                        {
                            isSynchroTuner = true;
                        }
                        if (split[12].ToUpper() == "Y")
                        {
                            isFusion = true;
                            Debug.Log("Cannot have Fusion Monsters in Main Deck.");
                            //  return false;
                        }
                        if (split[13].ToUpper() == "Y")
                        {
                            isRitual = true;
                        }

                        c = new MonsterCard(split[0], int.Parse(split[1]), CardAttributeOrType.Fight, split[3], int.Parse(split[4]), int.Parse(split[5]), split[6], long.Parse(split[7]), isPendulum, isXyz, isSynchro, isSynchroTuner, isFusion, isRitual, bi);
                    }
                    else if (split[2] == "Fire")
                    {
                        bool isPendulum     = false;
                        bool isXyz          = false;
                        bool isSynchro      = false;
                        bool isSynchroTuner = false;
                        bool isFusion       = false;
                        bool isRitual       = false;

                        if (split[8].ToUpper() == "Y")
                        {
                            isPendulum = true;
                        }
                        if (split[9].ToUpper() == "Y")
                        {
                            isXyz = true;
                            Debug.Log("Cannot have XYZ Monsters in Main Deck.");
                            //  return false;
                        }
                        if (split[10].ToUpper() == "Y")
                        {
                            isSynchro = true;
                            Debug.Log("Cannot have Synchro Monsters in Main Deck.");
                            //  return false;
                        }
                        if (split[11].ToUpper() == "Y")
                        {
                            isSynchroTuner = true;
                        }
                        if (split[12].ToUpper() == "Y")
                        {
                            isFusion = true;
                            Debug.Log("Cannot have Fusion Monsters in Main Deck.");
                            //  return false;
                        }
                        if (split[13].ToUpper() == "Y")
                        {
                            isRitual = true;
                        }

                        c = new MonsterCard(split[0], int.Parse(split[1]), CardAttributeOrType.Fire, split[3], int.Parse(split[4]), int.Parse(split[5]), split[6], long.Parse(split[7]), isPendulum, isXyz, isSynchro, isSynchroTuner, isFusion, isRitual, bi);
                    }
                    else if (split[2] == "Water")
                    {
                        bool isPendulum     = false;
                        bool isXyz          = false;
                        bool isSynchro      = false;
                        bool isSynchroTuner = false;
                        bool isFusion       = false;
                        bool isRitual       = false;

                        if (split[8].ToUpper() == "Y")
                        {
                            isPendulum = true;
                        }
                        if (split[9].ToUpper() == "Y")
                        {
                            isXyz = true;
                            Debug.Log("Cannot have XYZ Monsters in Main Deck.");
                            //return false;
                        }
                        if (split[10].ToUpper() == "Y")
                        {
                            isSynchro = true;
                            Debug.Log("Cannot have Synchro Monsters in Main Deck.");
                            //  return false;
                        }
                        if (split[11].ToUpper() == "Y")
                        {
                            isSynchroTuner = true;
                        }
                        if (split[12].ToUpper() == "Y")
                        {
                            isFusion = true;
                            Debug.Log("Cannot have Fusion Monsters in Main Deck.");
                            //  return false;
                        }
                        if (split[13].ToUpper() == "Y")
                        {
                            isRitual = true;
                        }

                        c = new MonsterCard(split[0], int.Parse(split[1]), CardAttributeOrType.Water, split[3], int.Parse(split[4]), int.Parse(split[5]), split[6], long.Parse(split[7]), isPendulum, isXyz, isSynchro, isSynchroTuner, isFusion, isRitual, bi);
                    }
                    else if (split[2] == "Wind")
                    {
                        bool isPendulum     = false;
                        bool isXyz          = false;
                        bool isSynchro      = false;
                        bool isSynchroTuner = false;
                        bool isFusion       = false;
                        bool isRitual       = false;

                        if (split[8].ToUpper() == "Y")
                        {
                            isPendulum = true;
                        }
                        if (split[9].ToUpper() == "Y")
                        {
                            isXyz = true;
                            Debug.Log("Cannot have XYZ Monsters in Main Deck.");
                            //return false;
                        }
                        if (split[10].ToUpper() == "Y")
                        {
                            isSynchro = true;
                            Debug.Log("Cannot have Synchro Monsters in Main Deck.");
                            //   return false;
                        }
                        if (split[11].ToUpper() == "Y")
                        {
                            isSynchroTuner = true;
                        }
                        if (split[12].ToUpper() == "Y")
                        {
                            isFusion = true;
                            Debug.Log("Cannot have Fusion Monsters in Main Deck.");
                            //  return false;
                        }
                        if (split[13].ToUpper() == "Y")
                        {
                            isRitual = true;
                        }

                        c = new MonsterCard(split[0], int.Parse(split[1]), CardAttributeOrType.Wind, split[3], int.Parse(split[4]), int.Parse(split[5]), split[6], long.Parse(split[7]), isPendulum, isXyz, isSynchro, isSynchroTuner, isFusion, isRitual, bi);
                    }
                    else if (split[2] == "Light")
                    {
                        bool isPendulum     = false;
                        bool isXyz          = false;
                        bool isSynchro      = false;
                        bool isSynchroTuner = false;
                        bool isFusion       = false;
                        bool isRitual       = false;

                        if (split[8].ToUpper() == "Y")
                        {
                            isPendulum = true;
                        }
                        if (split[9].ToUpper() == "Y")
                        {
                            isXyz = true;
                            Debug.Log("Cannot have XYZ Monsters in Main Deck.");
                            //return false;
                        }
                        if (split[10].ToUpper() == "Y")
                        {
                            isSynchro = true;
                            Debug.Log("Cannot have Synchro Monsters in Main Deck.");
                            //   return false;
                        }
                        if (split[11].ToUpper() == "Y")
                        {
                            isSynchroTuner = true;
                        }
                        if (split[12].ToUpper() == "Y")
                        {
                            isFusion = true;
                            Debug.Log("Cannot have Fusion Monsters in Main Deck.");
                            //  return false;
                        }
                        if (split[13].ToUpper() == "Y")
                        {
                            isRitual = true;
                        }

                        c = new MonsterCard(split[0], int.Parse(split[1]), CardAttributeOrType.Light, split[3], int.Parse(split[4]), int.Parse(split[5]), split[6], long.Parse(split[7]), isPendulum, isXyz, isSynchro, isSynchroTuner, isFusion, isRitual, bi);
                    }
                    allPossibleCards.Add(c);
                    Debug.Log("Was able to fully create: " + c.CardName);
                }
                //return true;
            }
            catch (Exception e)
            {
                Debug.Log(e);
                //return false;
            }
        }