def handle(self, *args, **options): LINGUISTICS_FORMATTERS = {key.value: linguistics_logic.ui_format(key.ui_text) for key in linguistics_keys.LEXICON_KEY.records if key.ui_text is not None} with open(game_settings.JS_CONSTNATS_FILE_LOCATION, 'w') as f: f.write(jinja2.render('game/js_constants.js', context={'actor_type': s11n.to_json({a.name: a.value for a in ACTOR_TYPE.records}), 'gender_to_text': s11n.to_json(dict(GENDER.select('value', 'text'))), 'gender_to_str': s11n.to_json(dict(GENDER.select('value', 'name'))), 'person_type_to_text': s11n.to_json(dict(PERSON_TYPE.select('value', 'text'))), 'race_to_text': s11n.to_json(dict(RACE.select('value', 'text'))), 'race_to_str': s11n.to_json(dict(RACE.select('value', 'name'))), 'game_state': s11n.to_json(dict(GAME_STATE.select('name', 'value'))), 'ARTIFACT_TYPE': artifacts_relations.ARTIFACT_TYPE, 'NO_EFFECT': artifacts_relations.ARTIFACT_EFFECT.NO_EFFECT, 'EFFECTS': EFFECTS, 'ARTIFACT_RARITY': artifacts_relations.RARITY, 'CARD_RARITY': cards_relations.RARITY, 'CARDS_EFFECTS': cards_effects.EFFECTS, 'ABILITY_TYPE': ABILITY_TYPE, 'SPRITES': SPRITES, 'CELL_SIZE': map_settings.CELL_SIZE, 'LINGUISTICS_FORMATTERS': LINGUISTICS_FORMATTERS }))
def handle(self, *args, **options): with open(game_settings.JS_CONSTNATS_FILE_LOCATION, 'w') as f: f.write( jinja2.render( 'game/js_constants.js', context={ 'actor_type': s11n.to_json( {a.name: a.value for a in ACTOR_TYPE.records}), 'gender_to_text': s11n.to_json(dict(GENDER.select('value', 'text'))), 'gender_to_str': s11n.to_json(dict(GENDER.select('value', 'name'))), 'person_type_to_text': s11n.to_json(dict(PERSON_TYPE.select('value', 'text'))), 'race_to_text': s11n.to_json(dict(RACE.select('value', 'text'))), 'race_to_str': s11n.to_json(dict(RACE.select('value', 'name'))), 'game_state': s11n.to_json(dict(GAME_STATE.select('name', 'value'))), 'ARTIFACT_TYPE': artifacts_relations.ARTIFACT_TYPE, 'NO_EFFECT': artifacts_relations.ARTIFACT_EFFECT.NO_EFFECT, 'EFFECTS': EFFECTS, 'ARTIFACT_RARITY': artifacts_relations.RARITY, 'CARD_RARITY': cards_relations.RARITY, 'CARDS_EFFECTS': cards_effects.EFFECTS, 'ABILITY_TYPE': ABILITY_TYPE, 'SPRITES': SPRITES, 'CELL_SIZE': map_settings.CELL_SIZE }).encode('utf-8'))
def handle(self, *args, **options): with open(game_settings.JS_CONSTNATS_FILE_LOCATION, 'w') as f: f.write(jinja2.render('game/js_constants.js', context={'actor_type': s11n.to_json({a.name: a.value for a in ACTOR_TYPE.records}), 'gender_to_text': s11n.to_json(dict(GENDER.select('value', 'text'))), 'gender_to_str': s11n.to_json(dict(GENDER.select('value', 'name'))), 'person_type_to_text': s11n.to_json(dict(PERSON_TYPE.select('value', 'text'))), 'race_to_text': s11n.to_json(dict(RACE.select('value', 'text'))), 'race_to_str': s11n.to_json(dict(RACE.select('value', 'name'))), 'game_state': s11n.to_json(dict(GAME_STATE.select('name', 'value'))), 'ARTIFACT_TYPE': artifacts_relations.ARTIFACT_TYPE, 'NO_EFFECT': artifacts_relations.ARTIFACT_EFFECT.NO_EFFECT, 'EFFECTS': EFFECTS, 'ARTIFACT_RARITY': artifacts_relations.RARITY, 'CARD_RARITY': cards_relations.RARITY, 'CARDS_EFFECTS': cards_effects.EFFECTS, 'ABILITY_TYPE': ABILITY_TYPE, 'SPRITES': SPRITES, 'CELL_SIZE': map_settings.CELL_SIZE }).encode('utf-8'))
def deserialize(cls, data): obj = cls() obj.person_id = data['person_id'] obj.person_name = data['person_name'] obj.person_race = RACE(data['person_race']) obj.person_type = PERSON_TYPE(data['person_type']) obj.person_gender = GENDER(data['person_gender']) obj.place_id = data['place_id'] if 'old_place_name_forms' in data: obj.old_place_name_forms = utg_words.Word.deserialize(data['old_place_name_forms']) else: obj.old_place_name_forms = names.generator().get_fast_name('название утрачено') return obj
class EditNameForm(forms.Form): race = fields.TypedChoiceField(label=u'раса', choices=RACE.choices(), coerce=RACE.get_from_name) gender = fields.TypedChoiceField(label=u'пол', choices=GENDER.choices(), coerce=GENDER.get_from_name) name = WordField(word_type=utg_relations.WORD_TYPE.NOUN, label=u'имя', skip_markers=(utg_relations.NOUN_FORM.COUNTABLE, ), show_properties=False) def clean(self): cleaned_data = super(EditNameForm, self).clean() name = cleaned_data.get('name') if name is not None: for name_form in cleaned_data['name'].forms: if len(name_form) > models.Hero.MAX_NAME_LENGTH: raise ValidationError( u'Слишком длинное имя, максимальное число символов: %d' % modelsHero.MAX_NAME_LENGTH) if len(name_form) < conf.heroes_settings.NAME_MIN_LENGHT: raise ValidationError( u'Слишком короткое имя, минимальное число символов: %d' % conf.heroes_settings.NAME_MIN_LENGHT) if NAME_REGEX.match(name_form) is None: print name_form raise ValidationError( u'Имя героя может содержать только следующие символы: %s' % conf.heroes_settings.NAME_SYMBOLS_DESCRITION) name.properties = name.properties.clone( cleaned_data['gender'].utg_id) return cleaned_data @classmethod def get_initials(cls, hero): return { 'gender': hero.gender, 'race': hero.race, 'name': hero.utg_name }
def handle(self, *args, **options): LINGUISTICS_FORMATTERS = { key.value: linguistics_logic.ui_format(key.ui_text) for key in linguistics_keys.LEXICON_KEY.records if key.ui_text is not None } race_to_text = {} for race in RACE.records: race_to_text[race.value] = { 'male': race.male_text, 'female': race.female_text } personality_practical_to_text = {} for personality in persons_relations.PERSONALITY_PRACTICAL.records: personality_practical_to_text[personality.value] = { 'male': personality.male_text, 'female': personality.female_text } personality_cosmetic_to_text = {} for personality in persons_relations.PERSONALITY_COSMETIC.records: personality_cosmetic_to_text[personality.value] = { 'male': personality.male_text, 'female': personality.female_text } with open(game_settings.JS_CONSTNATS_FILE_LOCATION, 'w') as f: f.write( jinja2.render( 'game/js_constants.js', context={ 'actor_type': s11n.to_json( {a.name: a.value for a in ACTOR_TYPE.records}), 'gender_to_text': s11n.to_json(dict(GENDER.select('value', 'text'))), 'gender_to_str': s11n.to_json(dict(GENDER.select('value', 'name'))), 'person_type_to_text': s11n.to_json( dict( persons_relations.PERSON_TYPE.select( 'value', 'text'))), 'race_to_text': s11n.to_json(race_to_text), 'game_state': s11n.to_json(dict(GAME_STATE.select('name', 'value'))), 'ARTIFACT_TYPE': artifacts_relations.ARTIFACT_TYPE, 'NO_EFFECT': artifacts_relations.ARTIFACT_EFFECT.NO_EFFECT, 'EFFECTS': EFFECTS, 'ARTIFACT_RARITY': artifacts_relations.RARITY, 'CARD_RARITY': cards_relations.RARITY, 'CARD': cards.CARD, 'ABILITY_TYPE': ABILITY_TYPE, 'SPRITES': SPRITES, 'CELL_SIZE': map_settings.CELL_SIZE, 'LINGUISTICS_FORMATTERS': LINGUISTICS_FORMATTERS, 'personality_practical_to_text': personality_practical_to_text, 'personality_cosmetic_to_text': personality_cosmetic_to_text }))