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")
def test_Protection(self): #Protection from Red red = MgColorExpression(MgColorTerm(MgColorTerm.ColorTermEnum.Red)) pro_red = MgProtectionAbility(red) self.assertTrue(pro_red.isTraversable()) self.assertEqual(len(pro_red.getTraversalSuccessors()), 1) self.assertTrue(pro_red.isChild(red)) self.assertEqual(red.getParent(), pro_red) self.assertEqual(pro_red.unparseToString().lower(), "protection from red") #Protection from instant spell[s] and from sorcery spell[s] #Note that the default unparsing routine does not do pluralization, #though it's expected of a dedicated unparser. instant_spells = MgDescriptionExpression( MgTypeExpression(MgType(MgType.TypeEnum.Instant)), MgQualifier(MgQualifier.QualifierEnum.Spell)) sorcery_spells = MgDescriptionExpression( MgTypeExpression(MgType(MgType.TypeEnum.Sorcery)), MgQualifier(MgQualifier.QualifierEnum.Spell)) pro_instantAndSorcery = MgProtectionAbility(instant_spells, sorcery_spells) self.assertEqual(len(pro_instantAndSorcery.getTraversalSuccessors()), 2) self.assertTrue(pro_instantAndSorcery.isChild(instant_spells)) self.assertEqual(instant_spells.getParent(), pro_instantAndSorcery) self.assertEqual( pro_instantAndSorcery.unparseToString().lower(), "protection from instant spell and from sorcery spell")
def test_TypeExpressions(self): t_legendary = MgSupertype(MgSupertype.SupertypeEnum.Legendary) t_human = MgSubtype(MgSubtype.CreatureSubtypeEnum.Human) t_cleric = MgSubtype(MgSubtype.CreatureSubtypeEnum.Cleric) texpr = MgTypeExpression(t_legendary,t_human,t_cleric) self.assertTrue(t_legendary.isTraversable()) self.assertEqual(len(texpr.getTraversalSuccessors()),3) self.assertTrue(texpr.isChild(t_legendary)) self.assertEqual(t_legendary.getParent(),texpr) self.assertEqual(texpr.unparseToString().lower(),"legendary human cleric") ##test pluralization #texpr.setPlural(True) #self.assertEqual(texpr.unparseToString().lower(),"legendary human clerics") #test comma delimitation. nonvampire = MgNonExpression(MgSubtype(MgSubtype.CreatureSubtypeEnum.Vampire)) nonwerewolf = MgNonExpression(MgSubtype(MgSubtype.CreatureSubtypeEnum.Werewolf)) nonzombie = MgNonExpression(MgSubtype(MgSubtype.CreatureSubtypeEnum.Zombie)) t_creature = MgType(MgType.TypeEnum.Creature) commaExpr = MgTypeExpression(nonvampire,nonwerewolf,nonzombie,t_creature) commaExpr.setCommaDelimited(True) self.assertEqual(commaExpr.unparseToString().lower(),"non-vampire, non-werewolf, non-zombie creature")
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_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_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")
def test_modifiers(self): triggered = MgAbilityModifier(MgAbilityModifier.AbilityModifierEnum.Triggered) ability = MgQualifier(MgQualifier.QualifierEnum.Ability) triggered_ability = MgDescriptionExpression(triggered,ability) self.assertTrue(triggered.isTraversable()) self.assertEqual(len(triggered.getTraversalSuccessors()),0) self.assertEqual(triggered.getModifier(),MgAbilityModifier.AbilityModifierEnum.Triggered) self.assertEqual(triggered_ability.unparseToString().lower(),"triggered ability") blocking = MgCombatStatusModifier(MgCombatStatusModifier.CombatStatusEnum.Blocking) creature = MgTypeExpression(MgType(MgType.TypeEnum.Creature)) blocking_creature = MgDescriptionExpression(blocking,creature) self.assertEqual(blocking_creature.unparseToString().lower(),"blocking creature") enchanted = MgKeywordStatusModifier(MgKeywordStatusModifier.KeywordStatusEnum.Enchanted) permanent = MgQualifier(MgQualifier.QualifierEnum.Permanent) enchanted_permanent = MgDescriptionExpression(enchanted,permanent) self.assertEqual(enchanted_permanent.unparseToString().lower(),"enchanted permanent") tapped = MgTapStatusModifier(MgTapStatusModifier.TapStatusEnum.Tapped) artifact = MgTypeExpression(MgType(MgType.TypeEnum.Artifact)) tapped_artifact = MgDescriptionExpression(tapped,artifact) self.assertEqual(tapped_artifact.unparseToString().lower(),"tapped artifact") chosen = MgEffectStatusModifier(MgEffectStatusModifier.EffectStatusEnum.Chosen) token = MgQualifier(MgQualifier.QualifierEnum.Token) tapped_artifact = MgDescriptionExpression(chosen,token) self.assertEqual(tapped_artifact.unparseToString().lower(),"chosen token")
def __init__(self): """Default constructor for an empty type line.""" self._traversable = True self._supertypes = MgTypeExpression() self._supertypes.setParent(self) self._types = MgTypeExpression() self._types.setParent(self) self._subtypes = MgTypeExpression() self._subtypes.setParent(self)
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_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")
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_CreateTokenExpressions(self): saproling_description = MgDescriptionExpression( #1/1 MgPTExpression( MgNumberValue(1, MgNumberValue.NumberTypeEnum.Literal), MgNumberValue(1, MgNumberValue.NumberTypeEnum.Literal)), #green MgColorExpression(MgColorTerm(MgColorTerm.ColorTermEnum.Green)), #saproling creature MgTypeExpression( MgSubtype(MgSubtype.CreatureSubtypeEnum.Saproling), MgType(MgType.TypeEnum.Creature)), #token MgQualifier(MgQualifier.QualifierEnum.Token)) three_of_them = MgNumberValue(3, MgNumberValue.NumberTypeEnum.Quantity) create_three_saprolings = MgCreateTokenExpression( descriptor=saproling_description, quantity=three_of_them) self.assertTrue(create_three_saprolings.isTraversable()) self.assertEqual(len(create_three_saprolings.getTraversalSuccessors()), 2) self.assertTrue(create_three_saprolings.isChild(saproling_description)) self.assertEqual(saproling_description.getParent(), create_three_saprolings) self.assertTrue(create_three_saprolings.isChild(three_of_them)) self.assertEqual(three_of_them.getParent(), create_three_saprolings) self.assertEqual(create_three_saprolings.unparseToString().lower(), "create three 1/1 green saproling creature token")
def test_TapUntapExpressions(self): t_creature = MgType(MgType.TypeEnum.Creature) typeexpr = MgTypeExpression(t_creature) targetExpr = MgTargetExpression(typeexpr) tapExpr = MgTapUntapExpression(targetExpr, tap=True, untap=False) self.assertTrue(tapExpr.isTraversable()) self.assertEqual(len(tapExpr.getTraversalSuccessors()), 1) self.assertTrue(tapExpr.isChild(targetExpr)) self.assertEqual(targetExpr.getParent(), tapExpr) self.assertTrue(tapExpr.isTap()) self.assertFalse(tapExpr.isUntap()) self.assertEqual(tapExpr.unparseToString().lower(), "tap target creature") tapExpr.setTap(False) tapExpr.setUntap(True) self.assertFalse(tapExpr.isTap()) self.assertTrue(tapExpr.isUntap()) self.assertEqual(tapExpr.unparseToString().lower(), "untap target creature") tapExpr.setTap(True) self.assertEqual(tapExpr.unparseToString().lower(), "tap or untap target creature")
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")
def test_TargetExpressions(self): t_artifact = MgType(MgType.TypeEnum.Artifact) t_creature = MgType(MgType.TypeEnum.Creature) typeexpr = MgTypeExpression(t_artifact,t_creature) targetExpr = MgTargetExpression(typeexpr) self.assertEqual(targetExpr.unparseToString().lower(),"target artifact creature")
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")
def __init__(self, supertypes=None, types=None, subtypes=None): """Constructor that allows you to supply MgTypeExpression objects.""" self._traversable = True if supertypes is not None: self._supertypes = supertypes else: self._supertypes = MgTypeExpression() self._supertypes.setParent(self) if types is not None: self._types = types else: self._types = MgTypeExpression() self._types.setParent(self) if subtypes is not None: self._subtypes = subtypes else: self._subtypes = MgTypeExpression() self._subtypes.setParent(self)
def test_thatReferences(self): color_white = MgColorExpression(MgColorTerm(MgColorTerm.ColorTermEnum.White)) t_enchantment = MgTypeExpression(MgType(MgType.TypeEnum.Enchantment)) original_enchantment_description = MgDescriptionExpression(color_white,t_enchantment) targetExpr = MgTargetExpression(original_enchantment_description) descriptor_enchantment = MgDescriptionExpression(MgTypeExpression(MgType(MgType.TypeEnum.Enchantment))) thatref_enchantment = MgThatReference(descriptor=descriptor_enchantment,antecedent=original_enchantment_description) self.assertTrue(thatref_enchantment.isTraversable()) self.assertEqual(len(thatref_enchantment.getTraversalSuccessors()),1) self.assertTrue(thatref_enchantment.isChild(descriptor_enchantment)) self.assertEqual(descriptor_enchantment.getParent(),thatref_enchantment) self.assertEqual(thatref_enchantment.getDescriptor(),descriptor_enchantment) self.assertTrue(thatref_enchantment.hasAntecedent()) self.assertEqual(thatref_enchantment.getAntecedent(),original_enchantment_description) thatref_enchantment.setAntecedent(original_enchantment_description) self.assertEqual(thatref_enchantment.getAntecedent(),original_enchantment_description) self.assertEqual(thatref_enchantment.unparseToString().lower(),"that enchantment")
def test_DestroyExpressions(self): t_creature = MgType(MgType.TypeEnum.Creature) typeExpr = MgTypeExpression(t_creature) allcreatures = MgAllExpression(typeExpr) destroyExpr = MgDestroyExpression(allcreatures) self.assertTrue(destroyExpr.isTraversable()) self.assertEqual(len(destroyExpr.getTraversalSuccessors()), 1) self.assertTrue(destroyExpr.isChild(allcreatures)) self.assertEqual(allcreatures.getParent(), destroyExpr) self.assertEqual(destroyExpr.unparseToString().lower(), "destroy all creature")
def test_NonExpressions(self): t_ferret = mtgcompiler.AST.mtypes.MgSubtype(mtgcompiler.AST.mtypes.MgSubtype.CreatureSubtypeEnum.Ferret) nonferret = MgNonExpression(t_ferret) self.assertEqual(nonferret.unparseToString().lower(),"non-ferret") self.assertTrue(nonferret.isTraversable()) self.assertEqual(len(nonferret.getTraversalSuccessors()),1) self.assertTrue(nonferret.isChild(t_ferret)) self.assertEqual(t_ferret.getParent(),nonferret) t_legendary = MgSupertype(MgSupertype.SupertypeEnum.Legendary) nonlegendary = MgNonExpression(t_legendary) t_creature = MgType(MgType.TypeEnum.Creature) typeexpr = MgTypeExpression(nonlegendary,t_creature) self.assertEqual(typeexpr.unparseToString().lower(),"non-legendary creature")
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_UncastExpressions(self): t_nonenchantment = MgTypeExpression( MgNonExpression(MgType(MgType.TypeEnum.Enchantment))) q_spell = MgQualifier(MgQualifier.QualifierEnum.Spell) description = MgDescriptionExpression(t_nonenchantment, q_spell) targetExpr = MgTargetExpression(description) uncastExpr = MgUncastExpression(targetExpr) self.assertTrue(uncastExpr.isTraversable()) self.assertEqual(len(uncastExpr.getTraversalSuccessors()), 1) self.assertTrue(uncastExpr.isChild(targetExpr)) self.assertEqual(targetExpr.getParent(), uncastExpr) self.assertEqual(uncastExpr.unparseToString().lower(), "counter target non-enchantment spell")
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_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")
def test_selfReferences(self): creature_description = MgDescriptionExpression(MgTypeExpression(MgType(MgType.TypeEnum.Creature))) targetExpr = MgTargetExpression(creature_description) selfref = MgSelfReference(reftype=MgSelfReference.SelfEnum.Neutral,antecedent=creature_description) self.assertTrue(selfref.isTraversable()) self.assertEqual(len(selfref.getTraversalSuccessors()),0) self.assertTrue(selfref.hasAntecedent()) selfref.setAntecedent(creature_description) self.assertEqual(selfref.getAntecedent(),creature_description) self.assertTrue(selfref.isNeutral()) self.assertEqual(selfref.unparseToString().lower(),"itself") selfref.setNeutral() selfref.setMale() self.assertTrue(selfref.isMale()) self.assertEqual(selfref.unparseToString().lower(),"himself") selfref.setFemale() self.assertTrue(selfref.isFemale()) self.assertEqual(selfref.unparseToString().lower(),"herself")