Ejemplo n.º 1
0
from the_tale.linguistics.forms import WordField

from the_tale.game.map.relations import TERRAIN

from the_tale.game import relations as game_relations

from the_tale.game.heroes.habilities import ABILITIES
from the_tale.game.heroes.habilities.battle import HIT

from the_tale.game.mobs.prototypes import MobRecordPrototype


def to_ability(ability_id):
    return ABILITIES[ability_id]

ABILITY_CHOICES_DICT = dict( (ability.get_id(), ability.NAME) for ability in MobRecordPrototype.get_available_abilities() )

ABILITY_CHOICES = sorted(ABILITY_CHOICES_DICT.items(), key=lambda choice: choice[1])

MOB_TYPE_CHOICES = sorted(game_relations.BEING_TYPE.choices(), key=lambda choice: choice[1])


class MobRecordBaseForm(forms.Form):

    level = fields.IntegerField(label='минимальный уровень')

    name = WordField(word_type=utg_relations.WORD_TYPE.NOUN, label='Название')

    type = fields.TypedChoiceField(label='тип', choices=MOB_TYPE_CHOICES, coerce=game_relations.BEING_TYPE.get_from_name)
    archetype = fields.TypedChoiceField(label='тип', choices=game_relations.ARCHETYPE.choices(), coerce=game_relations.ARCHETYPE.get_from_name)
Ejemplo n.º 2
0
from the_tale.game import relations as game_relations

from the_tale.game.heroes.habilities import ABILITIES
from the_tale.game.heroes.habilities.battle import HIT

from the_tale.game.mobs.prototypes import MobRecordPrototype


def to_ability(ability_id):
    return ABILITIES[ability_id]


ABILITY_CHOICES_DICT = dict(
    (ability.get_id(), ability.NAME)
    for ability in MobRecordPrototype.get_available_abilities())

ABILITY_CHOICES = sorted(ABILITY_CHOICES_DICT.items(),
                         key=lambda choice: choice[1])

MOB_TYPE_CHOICES = sorted(game_relations.BEING_TYPE.choices(),
                          key=lambda choice: choice[1])


class MobRecordBaseForm(forms.Form):

    level = fields.IntegerField(label='минимальный уровень')

    name = WordField(word_type=utg_relations.WORD_TYPE.NOUN, label='Название')

    type = fields.TypedChoiceField(