示例#1
0
文件: docs.py 项目: whiteprism/mywork
    def set_equip(self, pos, playerequip_or_playerequip_id=None):
        if not playerequip_or_playerequip_id:
            _id = 0
        elif is_digits(playerequip_or_playerequip_id):
            _id = playerequip_or_playerequip_id
        else:
            _id = playerequip_or_playerequip_id.pk

        if pos == 1:
            self.equip1Id = _id
        elif pos == 2:
            self.equip2Id = _id
        elif pos == 3:
            self.equip3Id = _id
        elif pos == 4:
            self.equip4Id = _id
        elif pos == 5:
            self.artifact1Id = _id
        elif pos == 6:
            self.artifact2Id = _id

        if pos < 5:
            self.check_equip_enhancemaster()
            self.check_equip_refinemaster()
        else:
            self.check_artifact_enhancemaster()
            self.check_artifact_refinemaster()
示例#2
0
def acquire_item(player, item_or_item_id, number=1, info="", **argvs):
    ''' 
    获取物品
    '''
    if isinstance(item_or_item_id, Item):
        item_id = item_or_item_id.pk
    elif is_digits(int(item_or_item_id)):
        item_id = int(item_or_item_id)

    _, playeritem = player.items.get_or_create(item_id, obj_id=item_id)
    playeritem.add(number, info)
    player.update_item(playeritem, True)

    return playeritem
示例#3
0
文件: api.py 项目: whiteprism/mywork
def acquire_artifact(player, artifact_or_artifact_id, info="", **argvs):
    ''' 
    获取圣物
    '''
    if isinstance(artifact_or_artifact_id, Artifact):
        artifact_id = artifact_or_artifact_id.pk
    elif is_digits(int(artifact_or_artifact_id)):
        artifact_id = int(artifact_or_artifact_id)

    playerartifact = player.artifacts.create(artifact_id = artifact_id, **argvs)
    ActionLogWriter.artifact_acquire(player, playerartifact.pk, artifact_id, info)
    artifact = get_artifact(artifact_id)
    playerartifact.get_random_skill(artifact)
    player.update_artifact(playerartifact, True)
    return playerartifact
示例#4
0
def acquire_buyrecord(player, item_or_item_id, number=1, info="", **argvs):
    ''' 
    添加购买记录
    '''
    if isinstance(item_or_item_id, Item):
        item_id = item_or_item_id.pk
    elif is_digits(int(item_or_item_id)):
        item_id = int(item_or_item_id)

    _, playerbuyrecord = player.buyrecords.get_or_create(item_id,
                                                         item_id=item_id,
                                                         **argvs)
    playerbuyrecord.buy(player, number, info)
    player.update_buyrecord(playerbuyrecord, True)
    return playerbuyrecord
示例#5
0
文件: api.py 项目: whiteprism/mywork
def acquire_buildingfragment(player,
                             fragment_or_fragment_id,
                             number=1,
                             info="",
                             **argvs):
    """
    获取建筑碎片
    """
    if isinstance(fragment_or_fragment_id, BuildingFragment):
        buildingfragment_id = fragment_or_fragment_id.pk
    elif is_digits(int(fragment_or_fragment_id)):
        buildingfragment_id = int(fragment_or_fragment_id)

    _, playerbuildingfragment = player.buildingfragments.get_or_create(
        buildingfragment_id, obj_id=buildingfragment_id, **argvs)
    playerbuildingfragment.add(number, info)
    player.update_buildingfragment(playerbuildingfragment, True)
    return playerbuildingfragment
示例#6
0
文件: api.py 项目: whiteprism/mywork
def acquire_artifactfragment(player, fragment_or_fragment_id, number=1, info="", **argvs):
    ''' 
    获取圣物碎片
    '''
    if isinstance(fragment_or_fragment_id, ArtifactFragment):
        fragment_id = fragment_or_fragment_id.pk
    elif is_digits(int(fragment_or_fragment_id)):
        fragment_id = int(fragment_or_fragment_id)

    # playerfragment = player.get_artifactfragment(fragment_id) 
    # playerfragment.add(number, info=info)
    # playerfragment.save()
    # player.update_artifactfragment(playerfragment)
    # return playerfragment
    _, playerartifactfragment = player.artifactfragments.get_or_create(fragment_id, obj_id=fragment_id, **argvs)
    playerartifactfragment.add(number, info)
    player.update_artifactfragment(playerartifactfragment, True)
    
    return playerartifactfragment
示例#7
0
文件: api.py 项目: whiteprism/mywork
def acquire_building(player, building_or_building_id, info="", **argvs):
    ''' 
    获取建筑
    '''
    if isinstance(building_or_building_id, Building):
        building = building_or_building_id
    elif is_digits(building_or_building_id):
        building = get_building(building_or_building_id)
        if not building:
            return None
    else:
        return None

    playerbuilding = player.buildings.create(pk=PlayerBuilding._incrment_id(),
                                             building_id=building.pk,
                                             **argvs)
    player.update_building(playerbuilding, True)
    ActionLogWriter.building_create(player, playerbuilding.pk,
                                    playerbuilding.building_id, info)
    return playerbuilding
示例#8
0
文件: api.py 项目: whiteprism/mywork
def acquire_buildingplant(player, plant_id, info="", **argvs):
    ''' 
    获取建筑
    '''
    if isinstance(plant_id, BuildingPlant):
        plant = plant_id
    elif is_digits(plant_id):
        plant = get_buildingplant(plant_id)
        if not plant:
            return None
    else:
        return None

    playerplant = player.buildingplants.create(pk=PlayerPlant._incrment_id(),
                                               plantId=plant.pk,
                                               **argvs)
    #设置种植时间
    playerplant.cultivate()
    player.update_buildingplant(playerplant, True)
    return playerplant
示例#9
0
文件: api.py 项目: whiteprism/mywork
def acquire_hero(player, warrior_or_warrior_id, info="", **argvs):
    ''' 
    acquire player hero
    return playerhero
    return playersoulfragment
    '''
    if isinstance(warrior_or_warrior_id, Warrior):
        warrior = warrior_or_warrior_id
    elif is_digits(warrior_or_warrior_id):
        warrior = get_warrior(warrior_or_warrior_id)
        if not warrior:
            return None
    if player.heroes.get(warrior.cardId):
        soul = get_soul(warrior.hero.soulId)
        playersoul = acquire_soul(player,
                                  warrior.hero.soulId,
                                  soul.breakCost,
                                  info=info)
        return playersoul

    skillhero = get_heroskill(warrior.cardId)
    argvs["normSkillGid"] = skillhero.skill0
    argvs["normSkillLevel"] = skillhero.skill0Lv

    for i in range(0, len(skillhero.skillinfo) / 3):
        skillGiId, _, upgrade = skillhero.skillinfo[i * 3:(i + 1) * 3]
        if upgrade == 0:
            argvs["skill%sLevel" % (i + 1)] = 1
        else:
            argvs["skill%sLevel" % (i + 1)] = 0
        argvs["skill%sGid" % (i + 1)] = skillGiId

    playerhero = player.heroes.create(pk=warrior.cardId,
                                      cardId=warrior.cardId,
                                      warrior_id=warrior.id,
                                      **argvs)

    heroteamId = playerhero.warrior.hero.heroTeamId
    playerheroteam = player.heroteams.get(heroteamId)
    if not playerheroteam:
        playerheroteam = player.heroteams.create(pk=heroteamId,
                                                 teamId=heroteamId)
        player.update_heroteam(playerheroteam, True)

    player.update_hero(playerhero, True)

    player.seven_days_task_going(Static.SEVEN_TASK_CATEGORY_ACQUIRE_HREO,
                                 number=1,
                                 is_incr=True,
                                 is_series=True)
    ActionLogWriter.hero_acquire(player,
                                 playerhero.id,
                                 warrior.id,
                                 warrior.cardId,
                                 info=info)

    # 获得也可以获得高星级的英雄。同时这个也算是完成相应的任务,七天乐或者成就等
    if playerhero.star >= 3:
        player.seven_days_task_going(
            Static.SEVEN_TASK_CATEGORY_HERO_STAR_UP_GREEN3,
            number=1,
            is_incr=True,
            is_series=True)

    if playerhero.star >= 5:
        player.seven_days_task_going(
            Static.SEVEN_TASK_CATEGORY_HERO_STAR_UP_GREEN5,
            number=1,
            is_incr=True,
            is_series=True)

    if playerhero.star >= 6:
        player.task_going(Static.TASK_CATEGORY_HERO_STAR2_UPGRADE,
                          number=1,
                          is_incr=True,
                          is_series=True)

    if playerhero.star >= 7:
        player.seven_days_task_going(
            Static.SEVEN_TASK_CATEGORY_HERO_STAR_UP_BLUE2,
            number=1,
            is_incr=True,
            is_series=True)

    if playerhero.star >= 10:
        player.seven_days_task_going(
            Static.SEVEN_TASK_CATEGORY_HERO_STAR_UP_BLUE5,
            number=1,
            is_incr=True,
            is_series=True)

    if playerhero.star >= 11:
        player.task_going(Static.TASK_CATEGORY_HERO_STAR3_UPGRADE,
                          number=1,
                          is_incr=True,
                          is_series=True)
        player.seven_days_task_going(
            Static.SEVEN_TASK_CATEGORY_HERO_STAR_UP_PURPLE,
            number=1,
            is_incr=True,
            is_series=True)

    if playerhero.star >= 16:
        player.task_going(Static.TASK_CATEGORY_HERO_STAR5_UPGRADE,
                          number=1,
                          is_incr=True,
                          is_series=True)

    return playerhero