Esempio n. 1
0
    def create(cls,
               key,
               raw_template,
               utg_template,
               verificators,
               author,
               parent=None,
               restrictions=frozenset(),
               state=relations.TEMPLATE_STATE.ON_REVIEW):
        model = cls._db_create(
            key=key,
            state=state,
            raw_template=raw_template,
            author=None if author is None else author._model,
            parent=None if parent is None else parent._model,
            data=s11n.to_json({
                'verificators': [v.serialize() for v in verificators],
                'template':
                utg_template.serialize(),
                'restrictions':
                list(restrictions),
                'groups':
                lexicon_logic.get_verificators_groups(key=key)
            }))
        prototype = cls(model)

        prototype.update_errors_status(force_update=True)
        prototype.sync_restrictions()

        environment.workers.linguistics_manager.cmd_game_lexicon_changed()

        return prototype
Esempio n. 2
0
 def test_get_verificators_groups__first_substitution__multiple(self):
     groups = logic.get_verificators_groups(key=keys.LEXICON_KEY.QUEST_SEARCH_SMITH_DIARY_UPGRADE__BUY_AND_CHANGE, old_groups={})
     self.assertEqual(groups,
                      {'artifact': (4, 0),
                       'coins': (1, 0),
                       'hero': (0, 0),
                       'receiver': (0, 1),
                       'receiver_position': (2, 0),
                       'sell_price': (1, 1),
                       'unequipped': (4, 1)} )
Esempio n. 3
0
 def test_get_verificators_groups__first_substitution__multiple(self):
     groups = logic.get_verificators_groups(key=keys.LEXICON_KEY.QUEST_SEARCH_SMITH_DIARY_UPGRADE__BUY_AND_CHANGE, old_groups={})
     self.assertEqual(groups,
                      {'artifact': (4, 0),
                       'coins': (1, 0),
                       'hero': (0, 0),
                       'receiver': (0, 1),
                       'receiver_position': (2, 0),
                       'sell_price': (1, 1),
                       'unequipped': (4, 1)} )
Esempio n. 4
0
    def test_get_verificators__without_old(self):
        groups = lexicon_logic.get_verificators_groups(key=keys.LEXICON_KEY.HERO_COMMON_JOURNAL_LEVEL_UP, old_groups={})
        self.assertEqual(groups, {'date': (8, 0), 'hero': (0, 0), 'level': (1, 0)})

        verificators = prototypes.Verificator.get_verificators(key=self.key, groups=groups)

        self.assertEqual(len(verificators), 4)

        self.assertEqual(verificators[0], prototypes.Verificator(text='', externals={'date': ('18 сухого месяца 183 года', ''), 'hero': ('герой', ''), 'level': (1, '')}))
        self.assertEqual(verificators[1], prototypes.Verificator(text='', externals={'date': ('18 сухого месяца 183 года', ''), 'hero': ('привидение', ''), 'level': (2, '')}))
        self.assertEqual(verificators[2], prototypes.Verificator(text='', externals={'date': ('18 сухого месяца 183 года', ''), 'hero': ('героиня', ''), 'level': (5, '')}))
        self.assertEqual(verificators[3], prototypes.Verificator(text='', externals={'date': ('18 сухого месяца 183 года', ''), 'hero': ('рыцарь', 'мн'), 'level': (1, '')}))
Esempio n. 5
0
    def test_get_verificators__one_substitutions_type(self):
        groups = lexicon_logic.get_verificators_groups(key=keys.LEXICON_KEY.PVP_USE_ABILITY_BLOOD, old_groups={})
        self.assertEqual(groups, {'duelist_1': (0, 0), 'duelist_2': (0, 1), 'effectiveness': (1, 0)})

        verificators = prototypes.Verificator.get_verificators(key=self.key, groups=groups)

        self.assertEqual(len(verificators), 4)

        self.assertEqual(verificators[0], prototypes.Verificator(text='', externals={'duelist_1': ('герой', ''), 'duelist_2': ('чудовище', ''), 'effectiveness': (1, '')}))
        self.assertEqual(verificators[1], prototypes.Verificator(text='', externals={'duelist_1': ('привидение', ''), 'duelist_2': ('русалка', ''), 'effectiveness': (2, '')}))
        self.assertEqual(verificators[2], prototypes.Verificator(text='', externals={'duelist_1': ('героиня', ''), 'duelist_2': ('боец', 'мн'),'effectiveness': (5, '')}))
        self.assertEqual(verificators[3], prototypes.Verificator(text='', externals={'duelist_1': ('рыцарь', 'мн'), 'duelist_2': ('призрак', ''), 'effectiveness': (1, '')}))
Esempio n. 6
0
    def test_get_verificators__without_old(self):
        groups = lexicon_logic.get_verificators_groups(key=keys.LEXICON_KEY.HERO_COMMON_JOURNAL_LEVEL_UP, old_groups={})
        self.assertEqual(groups, {'hero': (0, 0), 'level': (1, 0)})

        verificators = prototypes.Verificator.get_verificators(key=self.key, groups=groups)

        self.assertEqual(len(verificators), 4)

        self.assertEqual(verificators[0], prototypes.Verificator(text='', externals={'hero': ('герой', ''), 'level': (1, '')}))
        self.assertEqual(verificators[1], prototypes.Verificator(text='', externals={'hero': ('привидение', ''), 'level': (2, '')}))
        self.assertEqual(verificators[2], prototypes.Verificator(text='', externals={'hero': ('героиня', ''), 'level': (5, '')}))
        self.assertEqual(verificators[3], prototypes.Verificator(text='', externals={'hero': ('рыцарь', 'мн'), 'level': (1, '')}))
Esempio n. 7
0
 def test_get_verificators_groups__existed_substitutions(self):
     old_groups = {'coins': (1, 1),
                   'hero': (0, 2),
                   'receiver': (0, 0),
                   'unequipped': (4, 3)}
     groups = logic.get_verificators_groups(key=keys.LEXICON_KEY.QUEST_SEARCH_SMITH_DIARY_UPGRADE__BUY_AND_CHANGE, old_groups=old_groups)
     self.assertEqual(groups,
                      {'date': (8, 0),
                       'artifact': (4, 0),
                       'coins': (1, 1),
                       'hero': (0, 2),
                       'receiver': (0, 0),
                       'receiver_position': (2, 0),
                       'sell_price': (1, 0),
                       'unequipped': (4, 3)} )
Esempio n. 8
0
    def test_get_verificators__one_substitutions_type(self):
        groups = lexicon_logic.get_verificators_groups(key=keys.LEXICON_KEY.PVP_USE_ABILITY_BLOOD, old_groups={})
        self.assertEqual(groups, {'date': (8, 0), 'duelist_1': (0, 0), 'duelist_2': (0, 1), 'effectiveness': (1, 0)})

        verificators = prototypes.Verificator.get_verificators(key=self.key, groups=groups)

        self.assertEqual(len(verificators), 4)

        self.assertEqual(verificators[0], prototypes.Verificator(text='',
                                                                 externals={'date': ('18 сухого месяца 183 года', ''), 'duelist_1': ('герой', ''), 'duelist_2': ('чудовище', ''), 'effectiveness': (1, '')}))
        self.assertEqual(verificators[1], prototypes.Verificator(text='',
                                                                 externals={'date': ('18 сухого месяца 183 года', ''), 'duelist_1': ('привидение', ''), 'duelist_2': ('русалка', ''), 'effectiveness': (2, '')}))
        self.assertEqual(verificators[2], prototypes.Verificator(text='',
                                                                 externals={'date': ('18 сухого месяца 183 года', ''), 'duelist_1': ('героиня', ''), 'duelist_2': ('боец', 'мн'),'effectiveness': (5, '')}))
        self.assertEqual(verificators[3], prototypes.Verificator(text='',
                                                                 externals={'date': ('18 сухого месяца 183 года', ''), 'duelist_1': ('рыцарь', 'мн'), 'duelist_2': ('призрак', ''), 'effectiveness': (1, '')}))
Esempio n. 9
0
    def create(cls, key, raw_template, utg_template, verificators, author, parent=None, restrictions=frozenset(), state=relations.TEMPLATE_STATE.ON_REVIEW):
        model = cls._db_create(key=key,
                               state=state,
                               raw_template=raw_template,
                               author=None if author is None else author._model,
                               parent=None if parent is None else parent._model,
                               data=s11n.to_json({'verificators': [v.serialize() for v in verificators],
                                                  'template': utg_template.serialize(),
                                                  'restrictions': list(restrictions),
                                                  'groups': lexicon_logic.get_verificators_groups(key=key)}))
        prototype = cls(model)

        prototype.update_errors_status(force_update=True)
        prototype.sync_restrictions()

        environment.workers.linguistics_manager.cmd_game_lexicon_changed()

        return prototype
Esempio n. 10
0
    def test_get_verificators__with_old(self):
        groups = lexicon_logic.get_verificators_groups(key=keys.LEXICON_KEY.HERO_COMMON_JOURNAL_LEVEL_UP, old_groups={})
        self.assertEqual(groups, {'hero': (0, 0), 'level': (1, 0)})

        old_verificators = [prototypes.Verificator(text=u'1', externals={'hero': (u'привидение', u''), 'level': (1, u'')}),
                            prototypes.Verificator(text=u'2', externals={'hero': (u'героиня', u''), 'level': (1, u'')}),
                            prototypes.Verificator(text=u'3', externals={'hero': (u'рыцарь', u'ед'), 'level': (5, u'')}),
                            prototypes.Verificator(text=u'4', externals={'hero': (u'абракадабра', u''), 'level': (5, u'')}),
                            prototypes.Verificator(text=u'5', externals={'hero': (u'герой', u''), 'level': (2, u'')}) ]

        verificators = prototypes.Verificator.get_verificators(key=self.key, groups=groups, old_verificators=old_verificators)

        self.assertEqual(len(verificators), 4)

        self.assertEqual(verificators[0], prototypes.Verificator(text=u'1', externals={'hero': (u'привидение', u''), 'level': (1, u'')}))
        self.assertEqual(verificators[1], prototypes.Verificator(text=u'5', externals={'hero': (u'герой', u''), 'level': (2, u'')}))
        self.assertEqual(verificators[2], prototypes.Verificator(text=u'', externals={'hero': (u'героиня', u''), 'level': (5, u'')}))
        self.assertEqual(verificators[3], prototypes.Verificator(text=u'', externals={'hero': (u'рыцарь', u'мн'), 'level': (1, u'')}))
Esempio n. 11
0
    def test_get_verificators__with_old(self):
        groups = lexicon_logic.get_verificators_groups(
            key=keys.LEXICON_KEY.HERO_COMMON_JOURNAL_LEVEL_UP, old_groups={})
        self.assertEqual(groups, {'hero': (0, 0), 'level': (1, 0)})

        old_verificators = [
            prototypes.Verificator(text=u'1',
                                   externals={
                                       'hero': (u'привидение', u''),
                                       'level': (1, u'')
                                   }),
            prototypes.Verificator(text=u'2',
                                   externals={
                                       'hero': (u'героиня', u''),
                                       'level': (1, u'')
                                   }),
            prototypes.Verificator(text=u'3',
                                   externals={
                                       'hero': (u'рыцарь', u'ед'),
                                       'level': (5, u'')
                                   }),
            prototypes.Verificator(text=u'4',
                                   externals={
                                       'hero': (u'абракадабра', u''),
                                       'level': (5, u'')
                                   }),
            prototypes.Verificator(text=u'5',
                                   externals={
                                       'hero': (u'герой', u''),
                                       'level': (2, u'')
                                   })
        ]

        verificators = prototypes.Verificator.get_verificators(
            key=self.key, groups=groups, old_verificators=old_verificators)

        self.assertEqual(len(verificators), 4)

        self.assertEqual(
            verificators[0],
            prototypes.Verificator(text=u'1',
                                   externals={
                                       'hero': (u'привидение', u''),
                                       'level': (1, u'')
                                   }))
        self.assertEqual(
            verificators[1],
            prototypes.Verificator(text=u'5',
                                   externals={
                                       'hero': (u'герой', u''),
                                       'level': (2, u'')
                                   }))
        self.assertEqual(
            verificators[2],
            prototypes.Verificator(text=u'',
                                   externals={
                                       'hero': (u'рыцарь', u'мн'),
                                       'level': (5, u'')
                                   }))
        self.assertEqual(
            verificators[3],
            prototypes.Verificator(text=u'',
                                   externals={
                                       'hero': (u'героиня', u''),
                                       'level': (5, u'')
                                   }))
Esempio n. 12
0
 def test_get_verificators_groups__first_substitution(self):
     groups = logic.get_verificators_groups(key=keys.LEXICON_KEY.HERO_COMMON_JOURNAL_LEVEL_UP, old_groups={})
     self.assertEqual(groups, {'date': (8, 0), 'hero': (0, 0), 'level': (1, 0)})
Esempio n. 13
0
 def test_get_verificators_groups__first_substitution(self):
     groups = logic.get_verificators_groups(key=keys.LEXICON_KEY.HERO_COMMON_JOURNAL_LEVEL_UP, old_groups={})
     self.assertEqual(groups, {'hero': (0, 0), 'level': (1, 0)})
Esempio n. 14
0
 def get_all_verificatos(self):
     groups = lexicon_logic.get_verificators_groups(key=self.key, old_groups=self.lexicon_groups)
     verificators = Verificator.get_verificators(key=self.key, groups=groups, old_verificators=self.verificators)
     return verificators
Esempio n. 15
0
 def get_start_verificatos(self, key):
     groups = lexicon_logic.get_verificators_groups(key=key, old_groups=())
     verificators = Verificator.get_verificators(key=key, groups=groups, old_verificators=())
     return verificators