Ejemplo n.º 1
0
    def test_wash_with_lock(self):
        skills = SkillManager(1, 1).get_staff_skills(self.staff_id)
        sid = random.choice(skills.keys())

        SkillManager(1, 1).lock_toggle(self.staff_id, int(sid))
        cost = ConfigSkillWashCost.get_cost(1)

        MongoCharacter.db(1).update_one(
            {'_id': 1},
            {'$set': {'club.diamond': abs(cost['diamond'])}}
        )

        SkillManager(1, 1).wash(self.staff_id)

        new_skills = SkillManager(1, 1).get_staff_skills(self.staff_id)
        print 'new_skills:', new_skills.keys()
        print 'old_skills:', skills.keys()
        assert sid in new_skills
Ejemplo n.º 2
0
 def test_upgrade_speedup_can_not(self):
     skills = SkillManager(1, 1).get_staff_skills(self.staff_id)
     skill_id = random.choice(skills.keys())
     try:
         SkillManager(1, 1).upgrade_speedup(self.staff_id, int(skill_id))
     except GameException as e:
         assert e.error_id == ConfigErrorMessage.get_error_id("SKILL_UPGRADE_SPEEDUP_CANNOT")
     else:
         raise Exception('error')
Ejemplo n.º 3
0
    def test_add_toggle(self):
        skills = SkillManager(1, 1).get_staff_skills(self.staff_id)
        sid = random.choice(skills.keys())

        SkillManager(1, 1).lock_toggle(self.staff_id, int(sid))
        skills = SkillManager(1, 1).get_staff_skills(self.staff_id)
        assert skills[sid]['locked'] == 1

        SkillManager(1, 1).lock_toggle(self.staff_id, int(sid))
        skills = SkillManager(1, 1).get_staff_skills(self.staff_id)
        assert skills[sid]['locked'] == 0
Ejemplo n.º 4
0
    def test_upgrade(self):
        skills = SkillManager(1, 1).get_staff_skills(self.staff_id)
        skill_id = random.choice(skills.keys())
        config = ConfigSkill.get(int(skill_id))

        need_id, need_amount = config.get_upgrade_needs(skills[str(skill_id)]['level']+1)
        BagTrainingSkill(1, 1).add([(need_id, need_amount)])

        SkillManager(1, 1).upgrade(self.staff_id, int(skill_id))
        skills = SkillManager(1, 1).get_staff_skills(self.staff_id)
        assert skills[str(skill_id)]['end_at'] > 0
Ejemplo n.º 5
0
    def test_check_skill_not_own(self):
        skill_id = 0
        skills = SkillManager(1, 1).get_staff_skills(self.staff_id)
        for i in ConfigSkill.INSTANCES.keys():
            if i not in skills.keys():
                skill_id = i

        try:
            SkillManager(1, 1).check(self.staff_id, skill_id)
        except GameException as e:
            assert e.error_id == ConfigErrorMessage.get_error_id("SKILL_NOT_OWN")
        else:
            raise Exception('error')
Ejemplo n.º 6
0
    def test_upgrade_upgrading(self):
        skills = SkillManager(1, 1).get_staff_skills(self.staff_id)
        skill_id = random.choice(skills.keys())

        MongoStaff.db(1).update_one(
            {'_id': 1},
            {"$set":
                {'staffs.{0}.skills.{1}.end_at'.format(self.staff_id, skill_id): arrow.utcnow().timestamp + 10}}
        )

        try:
            SkillManager(1, 1).upgrade(self.staff_id, int(skill_id))
        except GameException as e:
            assert e.error_id == ConfigErrorMessage.get_error_id("SKILL_ALREADY_IN_UPGRADE")
        else:
            raise Exception('error')
Ejemplo n.º 7
0
    def test_upgrade_already_max_level(self):
        skills = SkillManager(1, 1).get_staff_skills(self.staff_id)
        skill_id = random.choice(skills.keys())
        config = ConfigSkill.get(int(skill_id))

        MongoStaff.db(1).update_one(
            {'_id': 1},
            {"$set":
                {'staffs.{0}.skills.{1}.level'.format(self.staff_id, skill_id): config.max_level}}
        )

        try:
            SkillManager(1, 1).upgrade(self.staff_id, int(skill_id))
        except GameException as e:
            assert e.error_id == ConfigErrorMessage.get_error_id("SKILL_ALREADY_MAX_LEVEL")
        else:
            raise Exception('error')
Ejemplo n.º 8
0
    def test_upgrade_speedup(self):
        skills = SkillManager(1, 1).get_staff_skills(self.staff_id)
        skill_id = random.choice(skills.keys())
        config = ConfigSkill.get(int(skill_id))

        need_id, need_amount = config.get_upgrade_needs(skills[str(skill_id)]['level']+1)
        BagTrainingSkill(1, 1).add([(need_id, need_amount)])

        MongoCharacter.db(1).update_one(
            {'_id': 1},
            {'$set': {'club.diamond': 10000}}
        )

        SkillManager(1, 1).upgrade(self.staff_id, int(skill_id))
        SkillManager(1, 1).upgrade_speedup(self.staff_id, int(skill_id))

        skills_after = SkillManager(1, 1).get_staff_skills(self.staff_id)
        assert skills_after[str(skill_id)]['level'] == skills[str(skill_id)]['level']+1
Ejemplo n.º 9
0
    def test_check(self):
        assert not SkillManager(1, 1).check(self.staff_id)

        skills = SkillManager(1, 1).get_staff_skills(self.staff_id)
        skill_id = random.choice(skills.keys())
        assert SkillManager(1, 1).check(self.staff_id, int(skill_id))
Ejemplo n.º 10
0
 def test_get_staff_skill_level(self):
     skills = SkillManager(1, 1).get_staff_skills(self.staff_id)
     skill_id = random.choice(skills.keys())
     assert SkillManager(1, 1).get_staff_skill_level(self.staff_id, skill_id)