Пример #1
0
    def test_Landwalk(self):
        t_island_expr = MgTypeExpression(
            MgSubtype(MgSubtype.LandSubtypeEnum.Island))
        islandwalk = MgLandwalkAbility(landtype=t_island_expr)

        self.assertTrue(islandwalk.isTraversable())
        self.assertTrue(islandwalk.hasLandType())
        self.assertEqual(len(islandwalk.getTraversalSuccessors()), 1)
        self.assertTrue(islandwalk.isChild(t_island_expr))
        self.assertEqual(t_island_expr.getParent(), islandwalk)
        self.assertEqual(islandwalk.unparseToString().lower(), "islandwalk")

        t_nonbasic_land_expr = MgTypeExpression(
            MgNonExpression(MgSupertype(MgSupertype.SupertypeEnum.Basic)),
            MgType(MgType.TypeEnum.Land))

        nonbasiclandwalk = MgLandwalkAbility(landtype=t_nonbasic_land_expr)
        self.assertEqual(nonbasiclandwalk.unparseToString().lower(),
                         "non-basic landwalk")

        #Used when talking about landwalk abilities in general.
        landwalk = MgLandwalkAbility()
        self.assertEqual(landwalk.unparseToString().lower(), "landwalk")

        t_lair_expr = MgTypeExpression(
            MgSubtype(MgSubtype.LandSubtypeEnum.Lair))
        landwalk.setLandType(t_lair_expr)
        self.assertEqual(landwalk.getLandType(), t_lair_expr)
        self.assertTrue(landwalk.isChild(t_lair_expr))
        self.assertEqual(t_lair_expr.getParent(), landwalk)
        self.assertEqual(landwalk.unparseToString().lower(), "lairwalk")
Пример #2
0
    def test_TypeLine(self):
        t_legendary = MgSupertype(MgSupertype.SupertypeEnum.Legendary)
        t_creature = MgType(MgType.TypeEnum.Creature)
        t_human = MgSubtype(MgSubtype.CreatureSubtypeEnum.Human)
        t_cleric = MgSubtype(MgSubtype.CreatureSubtypeEnum.Cleric)

        texpr_supertypes = MgTypeExpression(t_legendary)
        texpr_types = MgTypeExpression(t_creature)
        texpr_subtypes = MgTypeExpression(t_human, t_cleric)

        typeline = MgTypeLine(supertypes=texpr_supertypes,
                              types=texpr_types,
                              subtypes=texpr_subtypes)

        self.assertTrue(typeline.isTraversable())
        self.assertEqual(len(typeline.getTraversalSuccessors()), 3)

        self.assertTrue(typeline.isChild(texpr_types))
        self.assertEqual(texpr_types.getParent(), typeline)

        self.assertTrue(typeline.hasSupertype(t_legendary))
        self.assertTrue(typeline.hasType(t_creature))
        self.assertTrue(typeline.hasSubtype(t_human))

        self.assertEqual(typeline.unparseToString().lower(),
                         "legendary creature — human cleric")
Пример #3
0
    def test_Enchant(self):
        t_creature = MgTypeExpression(MgType(MgType.TypeEnum.Creature))
        ability = MgEnchantAbility(t_creature)

        self.assertTrue(ability.isTraversable())
        self.assertEqual(len(ability.getTraversalSuccessors()), 1)
        self.assertTrue(ability.isChild(t_creature))
        self.assertEqual(t_creature.getParent(), ability)
        self.assertEqual(ability.unparseToString().lower(), "enchant creature")
Пример #4
0
    def test_Offering(self):
        t_planeswalker = MgTypeExpression(MgType(MgType.TypeEnum.Planeswalker))
        offering = MgOfferingAbility(descriptor=t_planeswalker)
        self.assertTrue(offering.isChild(t_planeswalker))
        self.assertEqual(t_planeswalker.getParent(), offering)
        self.assertEqual(offering.getDescriptor(), t_planeswalker)
        self.assertEqual(len(offering.getTraversalSuccessors()), 1)
        self.assertEqual(offering.unparseToString().lower(),
                         "planeswalker offering")

        t_artifact = MgTypeExpression(MgType(MgType.TypeEnum.Artifact))
        offering.setDescriptor(t_artifact)
        self.assertEqual(offering.getDescriptor(), t_artifact)
        self.assertEqual(offering.unparseToString().lower(),
                         "artifact offering")
Пример #5
0
    def test_Affinity(self):
        t_artifact = MgTypeExpression(MgType(MgType.TypeEnum.Artifact))
        affinity = MgAffinityAbility(descriptor=t_artifact)
        self.assertTrue(affinity.isChild(t_artifact))
        self.assertEqual(t_artifact.getParent(), affinity)
        self.assertEqual(affinity.getDescriptor(), t_artifact)
        self.assertEqual(len(affinity.getTraversalSuccessors()), 1)

        #The default unparser does not perform pluralization.
        self.assertEqual(affinity.unparseToString().lower(),
                         "affinity for artifact")

        t_planeswalker = MgTypeExpression(MgType(MgType.TypeEnum.Planeswalker))
        affinity.setDescriptor(t_planeswalker)
        self.assertEqual(affinity.getDescriptor(), t_planeswalker)
        self.assertEqual(affinity.unparseToString().lower(),
                         "affinity for planeswalker")
Пример #6
0
    def test_Banding(self):
        ability = MgBandingAbility()

        self.assertTrue(ability.isTraversable())
        self.assertEqual(len(ability.getTraversalSuccessors()), 0)
        self.assertFalse(ability.hasQualitySpecifier())
        self.assertEqual(ability.unparseToString().lower(), "banding")

        t_barbarian = MgTypeExpression(
            MgSubtype(MgSubtype.CreatureSubtypeEnum.Barbarian))
        bandswithother = MgBandingAbility(quality=t_barbarian)

        self.assertTrue(bandswithother.hasQualitySpecifier())
        self.assertTrue(bandswithother.isChild(t_barbarian))
        self.assertEqual(t_barbarian.getParent(), bandswithother)
        self.assertEqual(len(bandswithother.getTraversalSuccessors()), 1)

        #The default unparser does not perform pluralization.
        self.assertEqual(bandswithother.unparseToString().lower(),
                         "bands with other barbarian")