internal Result RequestEquip(int id, object equipableCard, ref MonsterCard monsterCard) { if (player1.id == id && playerWhosTurnItIs == 1 && equipableCard is SpellAndTrapCard) { SpellAndTrapCard stc = equipableCard as SpellAndTrapCard; if (stc.getName() == "Legendary Sword") { if (monsterCard.getYuGhiOhType().ToUpper().Contains("WARRIOR")) { monsterCard.setAttackPoints(monsterCard.getAttackPoints() + 300); monsterCard.setDefensePoints(monsterCard.getDefensePoints() + 300); } else { return(Result.IneligibleMonsterType); } } else if (stc.getName() == "Beast Fangs") { if (monsterCard.getYuGhiOhType().ToUpper().Contains("BEAST")) { monsterCard.setAttackPoints(monsterCard.getAttackPoints() + 300); monsterCard.setDefensePoints(monsterCard.getDefensePoints() + 300); } else { return(Result.IneligibleMonsterType); } } else if (stc.getName() == "Violet Crystal") { if (monsterCard.getYuGhiOhType().ToUpper().Contains("ZOMBIE")) { monsterCard.setAttackPoints(monsterCard.getAttackPoints() + 300); monsterCard.setDefensePoints(monsterCard.getDefensePoints() + 300); } else { return(Result.IneligibleMonsterType); } } else if (stc.getName() == "Book of Secret Arts") { if (monsterCard.getYuGhiOhType().ToUpper().Contains("SPELLCASTER")) { monsterCard.setAttackPoints(monsterCard.getAttackPoints() + 300); monsterCard.setDefensePoints(monsterCard.getDefensePoints() + 300); } else { return(Result.IneligibleMonsterType); } } else if (stc.getName() == "Power of Kaishin") { if (monsterCard.getYuGhiOhType().ToUpper().Contains("AQUA")) { monsterCard.setAttackPoints(monsterCard.getAttackPoints() + 300); monsterCard.setDefensePoints(monsterCard.getDefensePoints() + 300); } else { return(Result.IneligibleMonsterType); } } else { return(Result.InvalidMove); } return(Result.Success); } else if (player1.id == id && playerWhosTurnItIs == 2) { return(Result.NotYourTurn); } else if (player2.id == id && playerWhosTurnItIs == 2) { SpellAndTrapCard stc = equipableCard as SpellAndTrapCard; if (stc.getName() == "Legendary Sword") { if (monsterCard.getYuGhiOhType().ToUpper().Contains("WARRIOR")) { monsterCard.setAttackPoints(monsterCard.getAttackPoints() + 300); monsterCard.setDefensePoints(monsterCard.getDefensePoints() + 300); } else { return(Result.IneligibleMonsterType); } } else if (stc.getName() == "Beast Fangs") { if (monsterCard.getYuGhiOhType().ToUpper().Contains("BEAST")) { monsterCard.setAttackPoints(monsterCard.getAttackPoints() + 300); monsterCard.setDefensePoints(monsterCard.getDefensePoints() + 300); } else { return(Result.IneligibleMonsterType); } } else if (stc.getName() == "Violet Crystal") { if (monsterCard.getYuGhiOhType().ToUpper().Contains("ZOMBIE")) { monsterCard.setAttackPoints(monsterCard.getAttackPoints() + 300); monsterCard.setDefensePoints(monsterCard.getDefensePoints() + 300); } else { return(Result.IneligibleMonsterType); } } else if (stc.getName() == "Book of Secret Arts") { if (monsterCard.getYuGhiOhType().ToUpper().Contains("SPELLCASTER")) { monsterCard.setAttackPoints(monsterCard.getAttackPoints() + 300); monsterCard.setDefensePoints(monsterCard.getDefensePoints() + 300); } else { return(Result.IneligibleMonsterType); } } else if (stc.getName() == "Power of Kaishin") { if (monsterCard.getYuGhiOhType().ToUpper().Contains("AQUA")) { monsterCard.setAttackPoints(monsterCard.getAttackPoints() + 300); monsterCard.setDefensePoints(monsterCard.getDefensePoints() + 300); } else { return(Result.IneligibleMonsterType); } } else { return(Result.InvalidMove); } return(Result.Success); } else if (player2.id == id && playerWhosTurnItIs == 1) { return(Result.NotYourTurn); } else { return(Result.InvalidMove); } }
/// <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(Object spellOrTrapToPlay) { if (spellOrTrapToPlay is SpellAndTrapCard && hand.Contains(spellOrTrapToPlay)) { SpellAndTrapCard stc = spellOrTrapToPlay as SpellAndTrapCard; Game.Result amIAllowedToSummon; if (stc.getName().Equals("Dark Hole")) { amIAllowedToSummon = myCurrentGame.RequestDarkHole(id); if (amIAllowedToSummon == Game.Result.Success) { SendToGraveYard(spellOrTrapToPlay, Zone.Hand); } } else if (stc.getName().Equals("Red Medicine")) { amIAllowedToSummon = myCurrentGame.RequestRedMedicine(id); if (amIAllowedToSummon == Game.Result.Success) { SendToGraveYard(spellOrTrapToPlay, Zone.Hand); } } else if (stc.getName().Equals("Sparks")) { amIAllowedToSummon = myCurrentGame.RequestSparks(id); if (amIAllowedToSummon == Game.Result.Success) { SendToGraveYard(spellOrTrapToPlay, Zone.Hand); } } else if (stc.getName().Equals("Fissure")) { amIAllowedToSummon = myCurrentGame.RequestFissure(id); if (amIAllowedToSummon == Game.Result.Success) { SendToGraveYard(spellOrTrapToPlay, Zone.Hand); } } else if (stc.getName().Equals("Trap Hole")) { amIAllowedToSummon = myCurrentGame.RequestTrapHole(id); if (amIAllowedToSummon == Game.Result.Success) { faceDownCardsInSpellAndTrapZone.Add(spellOrTrapToPlay as SpellAndTrapCard); m_meReadOnly.setNumberOfFaceDownSpellsAndTraps(faceDownCardsInSpellAndTrapZone.Count); hand.Remove(spellOrTrapToPlay); m_meReadOnly.setCardsInHand(m_meReadOnly.getCardsInHand() - 1); } } else { amIAllowedToSummon = Game.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!"); } }
internal Result RequestChangeModeOfCard(int idOfAttacker, MonsterCard toChangeModeOf) { if (toChangeModeOf.CanAttack()) { if (player1.id == idOfAttacker && playerWhosTurnItIs == 1) { if (playerTwoTrapHoleEnabled && !toChangeModeOf.getIsFlipped() && toChangeModeOf.getAttackPoints() > 999) { player1.SendToGraveYard(toChangeModeOf, Zone.Monster); IList <SpellAndTrapCard> spellsAndTrapsP2 = player2.getFaceDownCardsInSpellAndTrapZone(); for (int i = 0; i < spellsAndTrapsP2.Count; i++) { if (spellsAndTrapsP2[i].getName().ToUpper() == "TRAP HOLE") { SpellAndTrapCard stc = spellsAndTrapsP2[i]; player2.SendToGraveYard(stc, Zone.SpellTrap); break; } } } else { player1.GameChangeModeOfCard(toChangeModeOf); } return(Result.Success); } else if (player1.id == idOfAttacker && playerWhosTurnItIs == 2) { return(Result.NotYourTurn); } else if (player2.id == idOfAttacker && playerWhosTurnItIs == 2) { if (playerOneTrapHoleEnabled && !toChangeModeOf.getIsFlipped() && toChangeModeOf.getAttackPoints() > 999) { player2.SendToGraveYard(toChangeModeOf, Zone.Monster); IList <SpellAndTrapCard> spellsAndTrapsP1 = player1.getFaceDownCardsInSpellAndTrapZone(); for (int i = 0; i < spellsAndTrapsP1.Count; i++) { if (spellsAndTrapsP1[i].getName().ToUpper() == "TRAP HOLE") { SpellAndTrapCard stc = spellsAndTrapsP1[i]; player1.SendToGraveYard(stc, Zone.SpellTrap); break; } } } else { player2.GameChangeModeOfCard(toChangeModeOf); } return(Result.Success); } else if (player2.id == idOfAttacker && playerWhosTurnItIs == 1) { return(Result.NotYourTurn); } else { return(Result.InvalidMove); } } else { return(Result.CantAttackBcAlreadyAttackedOrFirstTurnPlayed); } }
private async Task <bool> LoadAllPossibleCardsAsync() { try { var names = this.GetType().GetTypeInfo().Assembly.GetManifestResourceNames(); string databasePath = ""; string imagePath = ""; foreach (string n in names) { if (n.Contains("Database")) { databasePath = n; break; } } foreach (string n in names) { if (n.Contains("Images")) { //Truncate the .jpg imagePath = n.Substring(0, n.LastIndexOf(".")); //Truncate the actual file name we only want the path. imagePath = imagePath.Substring(0, imagePath.LastIndexOf(".") + 1); break; } } string allLines = ""; using (StreamReader sr = new StreamReader(this.GetType().GetTypeInfo().Assembly.GetManifestResourceStream(databasePath))) { allLines = sr.ReadToEnd(); } string[] splitIntoIndividualLines = allLines.Split('\n'); for (int i = 1; i < splitIntoIndividualLines.Length; i++) { string[] split = splitIntoIndividualLines[i].Split(','); Object c = new Object(); BitmapImage bi = new BitmapImage(); var assembly = this.GetType().GetTypeInfo().Assembly; using (var imageStream = assembly.GetManifestResourceStream(imagePath + split[14])) using (var memStream = new MemoryStream()) { await imageStream.CopyToAsync(memStream); memStream.Position = 0; using (var raStream = memStream.AsRandomAccessStream()) { bi.SetSource(raStream); } } 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.WriteLine("Cannot have XYZ Monsters in Main Deck."); //return false; } if (split[10].ToUpper() == "Y") { isSynchro = true; Debug.WriteLine("Cannot have Synchro Monsters in Main Deck."); //return false; } if (split[11].ToUpper() == "Y") { isSynchroTuner = true; } if (split[12].ToUpper() == "Y") { isFusion = true; Debug.WriteLine("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.WriteLine("Cannot have XYZ Monsters in Main Deck."); //return false; } if (split[10].ToUpper() == "Y") { isSynchro = true; Debug.WriteLine("Cannot have Synchro Monsters in Main Deck."); //return false; } if (split[11].ToUpper() == "Y") { isSynchroTuner = true; } if (split[12].ToUpper() == "Y") { isFusion = true; Debug.WriteLine("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.WriteLine("Cannot have XYZ Monsters in Main Deck."); // return false; } if (split[10].ToUpper() == "Y") { isSynchro = true; Debug.WriteLine("Cannot have Synchro Monsters in Main Deck."); // return false; } if (split[11].ToUpper() == "Y") { isSynchroTuner = true; } if (split[12].ToUpper() == "Y") { isFusion = true; Debug.WriteLine("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.WriteLine("Cannot have XYZ Monsters in Main Deck."); // return false; } if (split[10].ToUpper() == "Y") { isSynchro = true; Debug.WriteLine("Cannot have Synchro Monsters in Main Deck."); // return false; } if (split[11].ToUpper() == "Y") { isSynchroTuner = true; } if (split[12].ToUpper() == "Y") { isFusion = true; Debug.WriteLine("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.WriteLine("Cannot have XYZ Monsters in Main Deck."); return(false); } if (split[10].ToUpper() == "Y") { isSynchro = true; Debug.WriteLine("Cannot have Synchro Monsters in Main Deck."); // return false; } if (split[11].ToUpper() == "Y") { isSynchroTuner = true; } if (split[12].ToUpper() == "Y") { isFusion = true; Debug.WriteLine("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.WriteLine("Cannot have XYZ Monsters in Main Deck."); return(false); } if (split[10].ToUpper() == "Y") { isSynchro = true; Debug.WriteLine("Cannot have Synchro Monsters in Main Deck."); // return false; } if (split[11].ToUpper() == "Y") { isSynchroTuner = true; } if (split[12].ToUpper() == "Y") { isFusion = true; Debug.WriteLine("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.WriteLine("Cannot have XYZ Monsters in Main Deck."); return(false); } if (split[10].ToUpper() == "Y") { isSynchro = true; Debug.WriteLine("Cannot have Synchro Monsters in Main Deck."); // return false; } if (split[11].ToUpper() == "Y") { isSynchroTuner = true; } if (split[12].ToUpper() == "Y") { isFusion = true; Debug.WriteLine("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); } return(true); } catch (Exception e) { Debug.WriteLine(e); return(false); } }