def test_BanisherPriest(self): #Card name: Banisher Priest cardName = MgName("Banisher Priest") #Mana cost: 1WW. s0 = MgManaSymbol(cvalue=1) s1 = MgManaSymbol(colorv=MgManaSymbol.ManaType.White) s2 = MgManaSymbol(colorv=MgManaSymbol.ManaType.White) manaExpr = MgManaExpression(s0,s1,s2) #Creature - Human Cleric t_creature = MgTypeExpression(MgType(MgType.TypeEnum.Creature)) t_human = MgTypeExpression(MgType(MgType.SubtypeEnum.Human)) t_cleric = MgTypeExpression(MgType(MgType.SubtypeEnum.Cleric)) typeLine = MgTypeLine(types=MgTypeLine(t_creature),subtypes=MgTypeLine(t_human,t_cleric)) #exile target creature an opponent controls exileEffect = MgExileEffectExpression( subject = MgTargetExpression(MgDescriptionExpression( MgTypeExpression(MgType(MgType.TypeEnum.Creature)), MgControlExpression("an opponent"))) ) #[...] until Banisher Priest leaves the battlefield. untilCondition = MgUntilExpression(MgEntersLeavesBattlefieldExpression(MgNameReference(),entering=False)) #when Banisher Priest enters the battlefield, [...] entersTheBattlefield = MgEntersLeavesBattlefieldExpression(MgNameReference,entering=True)
def test_Forecast(self): return None #TODO manaCost = MgManaExpression( MgManaSymbol(cvalue=1), MgManaSymbol(colorv=MgManaSymbol.ManaType.White)) tap_creature = MgStatementSequence( MgStatement( MgTapUntapExpression(MgTargetExpression( MgTypeExpression(MgType(MgType.TypeEnum.Creature))), tap=True))) activatedAbility = MgActivatedAbility( cost=None, instructions=tap_creature, abilityWord=None, #Forecast is in fact *not* an ability word. reminderText= None #The reminder text is attached to Forecast, not the underlying ability. ) reminder = MgReminderText( "Activate this ability only during your upkeep and only once each turn." ) forecast = MgForecastAbility(activatedAbility=activatedAbility, reminderText=reminder)
def test_DoomBlade(self): #Card name: Doom Blade. cardName = MgName("Doom Blade") #Mana cost: 1B. s0 = MgManaSymbol(cvalue=1) s1 = MgManaSymbol(colorv=MgManaSymbol.ManaType.Black) manaExpr = MgManaExpression(s0,s1) #Instant. t_instant = MgTypeExpression(MgType(MgType.TypeEnum.Instant)) typeLine = MgTypeLine(types=t_instant) #Destroy target non-black creature. c_nonblack = MgColorExpression(MgNonExpression(MgColorTerm(MgColorTerm.ColorTermEnum.Black))) t_creature = MgTypeExpression(MgType(MgType.TypeEnum.Creature)) description = MgDescriptionExpression(c_nonblack,t_creature) targetExpr = MgTargetExpression(description) destroyExpr = MgDestroyExpression(targetExpr) instructions = MgStatementSequence(MgStatement(destroyExpr)) ability = MgSpellAbility(instructions) textBox = MgTextBox(ability) #The card, all put together card = MgCard(**{ "name" : cardName, "manaCost" : manaExpr, "typeLine" : typeLine, "textBox" : textBox })
def test_CrypticCommand(self): #Card name: Cryptic Command cardName = MgName("Cryptic Command") #Mana cost: 1UUU. s0 = MgManaSymbol(cvalue=1) s1 = MgManaSymbol(colorv=MgManaSymbol.ManaType.Blue) s2 = MgManaSymbol(colorv=MgManaSymbol.ManaType.Blue) s3 = MgManaSymbol(colorv=MgManaSymbol.ManaType.Blue) manaExpr = MgManaExpression(s0,s1,s2,s3) #Instant. t_instant = MgTypeExpression(MgType(MgType.TypeEnum.Instant)) typeLine = MgTypeLine(types=t_instant) #counter target spell choice_counterspell = MgStatementSequence(MgStatement(MgUncastExpression(MgTargetExpression(MgDescriptionExpression( MgQualifier(MgQualifier.QualifierEnum.Spell) ))))) #Return target permanent to its owner's hand. choice_bounce = MgStatementSequence(MgStatement(MgReturnExpression( subject = MgTargetExpression(MgDescriptionExpression(MgQualifier(MgQualifier.QualifierEnum.Permanent))), destination = MgPossessiveExpression(possessive=MgPossessiveExpression.PossessiveEnum.Owner,owned=MgZone(MgZone.ZoneEnum.Hand)) ))) #Tap all creatures your opponents control. choice_tap = MgStatementSequence(MgStatement(MgTapUntapExpression( MgAllExpression(MgDescriptionExpression(MgTypeExpression(MgType(MgType.TypeEnum.Creature)),MgControlExpression("your opponents"))) ,tap=True ))) #Draw a card. choice_draw = MgStatementSequence(MgStatement(MgCardDrawExpression(MgNumberValue(value=1,ntype=MgNumberValue.NumberTypeEnum.Quantity)))) #Choose two modalExpr = MgModalExpression( MgNumberValue(value=2,ntype=MgNumberValue.NumberTypeEnum.Quantity), choice_counterspell,choice_bounce,choice_tap,choice_draw ) instructions = MgStatementSequence(MgStatement(modalExpr,periodTerminated=False)) ability = MgSpellAbility(instructions) textBox = MgTextBox(ability) card = MgCard(**{ "name" : cardName, "manaCost" : manaExpr, "typeLine" : typeLine, "textBox" : textBox }) print(card.unparseToString().lower()) visitor = SimpleGraphingVisitor() visitor.traverse(card)
def test_Splice(self): t_arcane = MgTypeExpression( MgSubtype(MgSubtype.SpellSubtypeEnum.Arcane)) s0 = MgManaSymbol(cvalue=1) s1 = MgManaSymbol(colorv=MgManaSymbol.ManaType.White) s2 = MgManaSymbol(colorv=MgManaSymbol.ManaType.White) manaExpr = MgManaExpression(s0, s1, s2) ability = MgSpliceAbility(cost=manaExpr, spliceType=t_arcane) self.assertTrue(ability.isTraversable()) self.assertEqual(len(ability.getTraversalSuccessors()), 2) self.assertTrue(ability.isChild(t_arcane)) self.assertEqual(manaExpr.getParent(), ability) self.assertEqual(ability.getCost(), manaExpr) self.assertEqual(ability.unparseToString().lower(), "splice onto arcane {1}{w}{w}")
def test_JumpStart(self): threegeneric = MgManaExpression( MgManaSymbol(colorv=None, modifiers=None, cvalue=3)) ability = MgJumpStartAbility(cost=threegeneric) self.assertTrue(ability.isTraversable()) self.assertEqual(len(ability.getTraversalSuccessors()), 1) self.assertTrue(ability.isChild(threegeneric)) self.assertEqual(threegeneric.getParent(), ability) self.assertEqual(ability.getCost(), threegeneric) self.assertEqual(ability.unparseToString().lower(), "jump-start {3}")
def test_Morph(self): threegeneric = MgManaExpression( MgManaSymbol(colorv=None, modifiers=None, cvalue=3)) ability = MgMorphAbility(cost=threegeneric) self.assertTrue(ability.isTraversable()) self.assertEqual(len(ability.getTraversalSuccessors()), 1) self.assertTrue(ability.isChild(threegeneric)) self.assertEqual(threegeneric.getParent(), ability) self.assertEqual(ability.getCost(), threegeneric) self.assertEqual(ability.unparseToString().lower(), "morph {3}") self.assertFalse(ability.isMegamorphAbility()) ability.setIsMegamorphAbility(True) self.assertEqual(ability.unparseToString().lower(), "megamorph {3}")
def test_Equip(self): manaExpr = MgManaExpression(MgManaSymbol(cvalue=4)) ability = MgEquipAbility(cost=manaExpr) self.assertTrue(ability.isTraversable()) self.assertEqual(len(ability.getTraversalSuccessors()), 1) self.assertTrue(ability.isChild(manaExpr)) self.assertEqual(manaExpr.getParent(), ability) self.assertEqual(ability.unparseToString().lower(), "equip {4}") t_planetouched = MgTypeExpression(MgSupertype("Planetouched")) equip_planetouched = MgEquipAbility(cost=manaExpr, quality=t_planetouched) self.assertEqual(len(equip_planetouched.getTraversalSuccessors()), 2) self.assertEqual(equip_planetouched.unparseToString().lower(), "equip planetouched {4}")
def test_ManaExpressions(self): s0 = MgManaSymbol(cvalue=1) s1 = MgManaSymbol(colorv=MgManaSymbol.ManaType.Red) s2 = MgManaSymbol(colorv=MgManaSymbol.ManaType.Green) s3 = MgManaSymbol(colorv=MgManaSymbol.ManaType.White) mexpr = MgManaExpression(s0,s1,s2,s3) self.assertTrue(mexpr.isTraversable()) self.assertEqual(len(mexpr.getTraversalSuccessors()),4) self.assertTrue(mexpr.isChild(s0)) self.assertEqual(s0.getParent(),mexpr) self.assertEqual(mexpr.unparseToString(),"{1}{R}{G}{W}")
def test_ModifiedSymbols(self): snowSymbol = MgManaSymbol(modifiers=MgManaSymbol.ManaModifier.Snow) self.assertEqual(snowSymbol.unparseToString(), "{S}") phyrexianBlueSymbol = MgManaSymbol( colorv=MgManaSymbol.ManaType.Blue, modifiers=MgManaSymbol.ManaModifier.Phyrexian) self.assertEqual(phyrexianBlueSymbol.unparseToString(), "{U/P}") halfWhiteSymbol = MgManaSymbol( colorv=MgManaSymbol.ManaType.White, modifiers=MgManaSymbol.ManaModifier.Half) self.assertEqual(halfWhiteSymbol.unparseToString(), "{HW}") redAlternateTwoSymbol = MgManaSymbol( colorv=MgManaSymbol.ManaType.Red, modifiers=MgManaSymbol.ManaModifier.AlternateTwo) self.assertEqual(redAlternateTwoSymbol.unparseToString(), "{R/2}")
def test_SimpleColorManaSymbols(self): whiteSymbol = MgManaSymbol(colorv=MgManaSymbol.ManaType.White) self.assertEqual(whiteSymbol.unparseToString(), "{W}") blueSymbol = MgManaSymbol(colorv=MgManaSymbol.ManaType.Blue) self.assertEqual(blueSymbol.unparseToString(), "{U}") blackSymbol = MgManaSymbol(colorv=MgManaSymbol.ManaType.Black) self.assertEqual(blackSymbol.unparseToString(), "{B}") redSymbol = MgManaSymbol(colorv=MgManaSymbol.ManaType.Red) self.assertEqual(redSymbol.unparseToString(), "{R}") greenSymbol = MgManaSymbol(colorv=MgManaSymbol.ManaType.Green) self.assertEqual(greenSymbol.unparseToString(), "{G}")
def test_HybridManaSymbols(self): #This test is currently failing. I'm not fully understanding why the canonical order #for hybrid mana symbols is the way that it is. #Allied hybrid symbols gwSymbol = MgManaSymbol(colorv=MgManaSymbol.ManaType.Green | MgManaSymbol.ManaType.White) self.assertEqual(gwSymbol.unparseToString(), "{G/W}") wuSymbol = MgManaSymbol(colorv=MgManaSymbol.ManaType.White | MgManaSymbol.ManaType.Blue) self.assertEqual(gwSymbol.unparseToString(), "{W/U}") ubSymbol = MgManaSymbol(colorv=MgManaSymbol.ManaType.Blue | MgManaSymbol.ManaType.Black) self.assertEqual(gwSymbol.unparseToString(), "{U/B}") brSymbol = MgManaSymbol(colorv=MgManaSymbol.ManaType.Black | MgManaSymbol.ManaType.Red) self.assertEqual(gwSymbol.unparseToString(), "{B/R}") rgSymbol = MgManaSymbol(colorv=MgManaSymbol.ManaType.Red | MgManaSymbol.ManaType.Green) self.assertEqual(rgSymbol.unparseToString(), "{R/G}") #Enemy allied symbols wbSymbol = MgManaSymbol(colorv=MgManaSymbol.ManaType.White | MgManaSymbol.ManaType.Black) self.assertEqual(wbSymbol.unparseToString(), "{W/B}") urSymbol = MgManaSymbol(colorv=MgManaSymbol.ManaType.Blue | MgManaSymbol.ManaType.Red) self.assertEqual(urSymbol.unparseToString(), "{U/R}") bgSymbol = MgManaSymbol(colorv=MgManaSymbol.ManaType.Black | MgManaSymbol.ManaType.Green) self.assertEqual(bgSymbol.unparseToString(), "{B/G}") guSymbol = MgManaSymbol(colorv=MgManaSymbol.ManaType.Green | MgManaSymbol.ManaType.Blue) self.assertEqual(bgSymbol.unparseToString(), "{G/U}") rwSymbol = MgManaSymbol(colorv=MgManaSymbol.ManaType.Red | MgManaSymbol.ManaType.White) self.assertEqual(bgSymbol.unparseToString(), "{R/W}")
def test_GenericManaSymbols(self): zeroSymbol = MgManaSymbol(colorv=None, modifiers=None, cvalue=0) self.assertEqual(zeroSymbol.unparseToString(), "{0}") eightSymbol = MgManaSymbol(colorv=None, modifiers=None, cvalue=8) self.assertEqual(eightSymbol.unparseToString(), "{8}") xSymbol = MgManaSymbol(colorv=None, modifiers=None, cvalue="X") self.assertEqual(xSymbol.unparseToString(), "{X}") infinitySymbol = MgManaSymbol(colorv=None, modifiers=None, cvalue="∞") self.assertEqual(infinitySymbol.unparseToString(), "{∞}")