Add is_default to Pokemon. Revise forms' is_default accordingly.

This commit is contained in:
Petr Viktorin 2011-04-30 19:01:43 +03:00
parent bc244aeb53
commit 8309b316f2
3 changed files with 709 additions and 703 deletions

File diff suppressed because it is too large Load diff

View file

@ -675,16 +675,16 @@ id,form_identifier,pokemon_id,introduced_in_version_group_id,is_default,is_battl
674,z,201,3,0,0,230 674,z,201,3,0,0,230
675,exclamation,201,5,0,0,230 675,exclamation,201,5,0,0,230
676,question,201,5,0,0,230 676,question,201,5,0,0,230
677,sunny,662,5,0,1,379 677,sunny,662,5,1,1,379
678,rainy,663,5,0,1,380 678,rainy,663,5,1,1,380
679,snowy,664,5,0,1,381 679,snowy,664,5,1,1,381
680,attack,650,7,0,0,419 680,attack,650,7,1,0,419
681,defense,651,7,0,0,420 681,defense,651,7,1,0,420
682,speed,652,6,0,0,421 682,speed,652,6,1,0,421
683,sandy,412,8,0,0,445 683,sandy,412,8,0,0,445
684,trash,412,8,0,0,445 684,trash,412,8,0,0,445
685,sandy,653,8,0,0,447 685,sandy,653,8,1,0,447
686,trash,654,8,0,0,448 686,trash,654,8,1,0,448
687,sunshine,421,8,0,1,456 687,sunshine,421,8,0,1,456
688,east,422,8,0,0,457 688,east,422,8,0,0,457
689,east,423,8,0,0,458 689,east,423,8,0,0,458
@ -705,23 +705,23 @@ id,form_identifier,pokemon_id,introduced_in_version_group_id,is_default,is_battl
704,steel,493,8,0,0,508 704,steel,493,8,0,0,508
705,water,493,8,0,0,508 705,water,493,8,0,0,508
706,unknown,493,8,0,0,508 706,unknown,493,8,0,0,508
707,heat,657,9,0,0,488 707,heat,657,9,1,0,488
708,wash,658,9,0,0,489 708,wash,658,9,1,0,489
709,frost,659,9,0,0,490 709,frost,659,9,1,0,490
710,fan,660,9,0,0,491 710,fan,660,9,1,0,491
711,mow,661,9,0,0,492 711,mow,661,9,1,0,492
712,origin,656,9,0,0,501 712,origin,656,9,1,0,501
713,sky,655,9,0,0,507 713,sky,655,9,1,0,507
714,spiky-eared,172,10,0,0,25 714,spiky-eared,172,10,0,0,25
715,blue-striped,665,11,0,0,566 715,blue-striped,665,11,1,0,566
716,zen,666,11,0,0,572 716,zen,666,11,1,0,572
717,summer,585,11,0,0,602 717,summer,585,11,0,0,602
718,autumn,585,11,0,0,602 718,autumn,585,11,0,0,602
719,winter,585,11,0,0,602 719,winter,585,11,0,0,602
720,summer,586,11,0,0,603 720,summer,586,11,0,0,603
721,autumn,586,11,0,0,603 721,autumn,586,11,0,0,603
722,winter,586,11,0,0,603 722,winter,586,11,0,0,603
723,pirouette,667,11,0,0,666 723,pirouette,667,11,1,0,666
724,douse,649,11,0,0,667 724,douse,649,11,0,0,667
725,shock,649,11,0,0,667 725,shock,649,11,0,0,667
726,burn,649,11,0,0,667 726,burn,649,11,0,0,667

1 id form_identifier pokemon_id introduced_in_version_group_id is_default is_battle_only order
675 674 z 201 3 0 0 230
676 675 exclamation 201 5 0 0 230
677 676 question 201 5 0 0 230
678 677 sunny 662 5 0 1 1 379
679 678 rainy 663 5 0 1 1 380
680 679 snowy 664 5 0 1 1 381
681 680 attack 650 7 0 1 0 419
682 681 defense 651 7 0 1 0 420
683 682 speed 652 6 0 1 0 421
684 683 sandy 412 8 0 0 445
685 684 trash 412 8 0 0 445
686 685 sandy 653 8 0 1 0 447
687 686 trash 654 8 0 1 0 448
688 687 sunshine 421 8 0 1 456
689 688 east 422 8 0 0 457
690 689 east 423 8 0 0 458
705 704 steel 493 8 0 0 508
706 705 water 493 8 0 0 508
707 706 unknown 493 8 0 0 508
708 707 heat 657 9 0 1 0 488
709 708 wash 658 9 0 1 0 489
710 709 frost 659 9 0 1 0 490
711 710 fan 660 9 0 1 0 491
712 711 mow 661 9 0 1 0 492
713 712 origin 656 9 0 1 0 501
714 713 sky 655 9 0 1 0 507
715 714 spiky-eared 172 10 0 0 25
716 715 blue-striped 665 11 0 1 0 566
717 716 zen 666 11 0 1 0 572
718 717 summer 585 11 0 0 602
719 718 autumn 585 11 0 0 602
720 719 winter 585 11 0 0 602
721 720 summer 586 11 0 0 603
722 721 autumn 586 11 0 0 603
723 722 winter 586 11 0 0 603
724 723 pirouette 667 11 0 1 0 666
725 724 douse 649 11 0 0 667
726 725 shock 649 11 0 0 667
727 726 burn 649 11 0 0 667

View file

@ -1072,17 +1072,13 @@ class Pokemon(TableBase):
info=dict(description=u"The base EXP gained when defeating this Pokémon")) # XXX: Is this correct? info=dict(description=u"The base EXP gained when defeating this Pokémon")) # XXX: Is this correct?
order = Column(Integer, nullable=False, index=True, order = Column(Integer, nullable=False, index=True,
info=dict(description=u"Order for sorting. Almost national order, except families are grouped together.")) info=dict(description=u"Order for sorting. Almost national order, except families are grouped together."))
is_default = Column(Boolean, nullable=False, index=True,
info=dict(description=u'Set for exactly one pokemon used as the default for each species.'))
@property @property
def name(self): def name(self):
u"""Returns True iff the Pokémon is the base form for its species,
e.g. Land Shaymin.
"""
return self.default_form.pokemon_name or self.species.name return self.default_form.pokemon_name or self.species.name
### Not forms!
def stat(self, stat_name): def stat(self, stat_name):
u"""Returns a PokemonStat record for the given stat name (or Stat row u"""Returns a PokemonStat record for the given stat name (or Stat row
object). Uses the normal has-many machinery, so all the stats are object). Uses the normal has-many machinery, so all the stats are
@ -1218,13 +1214,13 @@ class PokemonForm(TableBase):
id = Column(Integer, primary_key=True, nullable=False, id = Column(Integer, primary_key=True, nullable=False,
info=dict(description=u'A unique ID for this form.')) info=dict(description=u'A unique ID for this form.'))
form_identifier = Column(Unicode(16), nullable=True, form_identifier = Column(Unicode(16), nullable=True,
info=dict(description=u"An identifier of the form, uniue among a species", format='identifier')) info=dict(description=u"An identifier of the form, uniue among a species. May be None for the default form of the species.", format='identifier'))
pokemon_id = Column(Integer, ForeignKey('pokemon.id'), nullable=False, autoincrement=False, pokemon_id = Column(Integer, ForeignKey('pokemon.id'), nullable=False, autoincrement=False,
info=dict(description=u'The ID of the base Pokémon for this form.')) info=dict(description=u'The ID of the base Pokémon for this form.'))
introduced_in_version_group_id = Column(Integer, ForeignKey('version_groups.id'), autoincrement=False, introduced_in_version_group_id = Column(Integer, ForeignKey('version_groups.id'), autoincrement=False,
info=dict(description=u'The ID of the version group in which this form first appeared.')) info=dict(description=u'The ID of the version group in which this form first appeared.'))
is_default = Column(Boolean, nullable=False, is_default = Column(Boolean, nullable=False,
info=dict(description=u'Set for exactly one form used as the default for each species.')) info=dict(description=u'Set for exactly one form used as the default for each pokemon (not necessarily species).'))
is_battle_only = Column(Boolean, nullable=False, is_battle_only = Column(Boolean, nullable=False,
info=dict(description=u'Set iff the form can only appear in battle.')) info=dict(description=u'Set iff the form can only appear in battle.'))
order = Column(Integer, nullable=False, autoincrement=False, order = Column(Integer, nullable=False, autoincrement=False,
@ -1917,7 +1913,7 @@ Pokemon.default_form = relationship(PokemonForm,
primaryjoin=and_( primaryjoin=and_(
Pokemon.id==PokemonForm.pokemon_id, Pokemon.id==PokemonForm.pokemon_id,
PokemonForm.is_default==True), PokemonForm.is_default==True),
uselist=False) uselist=False, lazy='joined')
Pokemon.items = relationship(PokemonItem, Pokemon.items = relationship(PokemonItem,
backref='pokemon') backref='pokemon')
Pokemon.stats = relationship(PokemonStat, Pokemon.stats = relationship(PokemonStat,
@ -1957,7 +1953,7 @@ PokemonEvolution.trade_species = relationship(PokemonSpecies,
PokemonForm.pokemon = relationship(Pokemon, PokemonForm.pokemon = relationship(Pokemon,
primaryjoin=PokemonForm.pokemon_id==Pokemon.id, primaryjoin=PokemonForm.pokemon_id==Pokemon.id,
innerjoin=True) innerjoin=True, lazy='joined')
PokemonForm.species = association_proxy('pokemon', 'species') PokemonForm.species = association_proxy('pokemon', 'species')
PokemonForm.version_group = relationship(VersionGroup, PokemonForm.version_group = relationship(VersionGroup,
innerjoin=True) innerjoin=True)
@ -1995,7 +1991,7 @@ PokemonMove.method = relationship(PokemonMoveMethod,
PokemonStat.stat = relationship(Stat, PokemonStat.stat = relationship(Stat,
innerjoin=True, lazy='joined') innerjoin=True, lazy='joined')
PokemonSpecies.parent_pokemon = relationship(PokemonSpecies, PokemonSpecies.parent_species = relationship(PokemonSpecies,
primaryjoin=PokemonSpecies.evolves_from_species_id==PokemonSpecies.id, primaryjoin=PokemonSpecies.evolves_from_species_id==PokemonSpecies.id,
remote_side=[PokemonSpecies.id], remote_side=[PokemonSpecies.id],
backref='child_species') backref='child_species')
@ -2008,13 +2004,11 @@ PokemonSpecies.flavor_text = relationship(PokemonSpeciesFlavorText,
PokemonSpecies.growth_rate = relationship(GrowthRate, PokemonSpecies.growth_rate = relationship(GrowthRate,
innerjoin=True, innerjoin=True,
backref='evolution_chains') backref='evolution_chains')
PokemonSpecies.pokemon_habitat = relationship(PokemonHabitat, PokemonSpecies.habitat = relationship(PokemonHabitat,
backref='species') backref='species')
PokemonSpecies.habitat = association_proxy('pokemon_habitat', 'name') PokemonSpecies.color = relationship(PokemonColor,
PokemonSpecies.pokemon_color = relationship(PokemonColor,
innerjoin=True, innerjoin=True,
backref='species') backref='species')
PokemonSpecies.color = association_proxy('pokemon_color', 'name')
PokemonSpecies.egg_groups = relationship(EggGroup, PokemonSpecies.egg_groups = relationship(EggGroup,
secondary=PokemonEggGroup.__table__, secondary=PokemonEggGroup.__table__,
innerjoin=True, innerjoin=True,
@ -2024,10 +2018,22 @@ PokemonSpecies.forms = relationship(PokemonForm,
secondary=Pokemon.__table__, secondary=Pokemon.__table__,
primaryjoin=PokemonSpecies.id==Pokemon.species_id, primaryjoin=PokemonSpecies.id==Pokemon.species_id,
secondaryjoin=Pokemon.id==PokemonForm.pokemon_id, secondaryjoin=Pokemon.id==PokemonForm.pokemon_id,
order_by=Pokemon.order.asc()) order_by=(PokemonForm.order.asc(), PokemonForm.form_identifier.asc()))
PokemonSpecies.default_form = relationship(PokemonForm,
secondary=Pokemon.__table__,
primaryjoin=and_(PokemonSpecies.id==Pokemon.species_id,
Pokemon.is_default==True),
secondaryjoin=and_(Pokemon.id==PokemonForm.pokemon_id,
PokemonForm.is_default==True),
uselist=False)
PokemonSpecies.default_pokemon = relationship(Pokemon,
primaryjoin=and_(
PokemonSpecies.id==Pokemon.species_id,
Pokemon.is_default==True),
uselist=False, lazy='joined')
PokemonSpecies.evolution_chain = relationship(EvolutionChain, PokemonSpecies.evolution_chain = relationship(EvolutionChain,
innerjoin=True, innerjoin=True,
backref=backref('species', order_by=Pokemon.order.asc())) backref=backref('species', order_by=PokemonSpecies.id.asc()))
PokemonSpecies.dex_numbers = relationship(PokemonDexNumber, PokemonSpecies.dex_numbers = relationship(PokemonDexNumber,
innerjoin=True, innerjoin=True,
order_by=PokemonDexNumber.pokedex_id.asc(), order_by=PokemonDexNumber.pokedex_id.asc(),