Exemplo n.º 1
0
def get_faction_info(factionID):
    faction = Faction.get(factionID)
    if not faction:
        return {}
    player = Player.simple_load(faction.leaderID, ['prototypeID', 'name'])
    return dict(
        factionID=factionID,
        name=faction.name,
        level=FactionRankRanking.get_score(faction.factionID) or 1,
        mcount=len(faction.memberset),
        acount=len(faction.applyset),
        totalfp=faction.totalfp,
        todayfp=faction.todayfp,
        rank=FactionRankRanking.get_rank(factionID),
        prototypeID=player.prototypeID,
        leader=player.name,
        createtime=faction.createtime,
        notice=faction.notice,
        mode=faction.mode,
        strengthen_hp_level=faction.strengthen_hp_level,
        strengthen_at_level=faction.strengthen_at_level,
        strengthen_ct_level=faction.strengthen_ct_level,
        strengthen_df_level=faction.strengthen_df_level,
        can_strengthen=get_config(CanStrengthenConfig)[1].can,
        leaderID=faction.leaderID,
        dflag=faction.dflag,
    )
Exemplo n.º 2
0
def get_faction_thumb(factionID):
    faction = Faction.get(factionID)
    if not faction:
        return {}
    player = Player.simple_load(faction.leaderID, ['prototypeID'])
    return {
        'factionID': faction.factionID,
        'name': faction.name,
        'totalfp': faction.totalfp,
        'todayfp': faction.todayfp,
        'prototypeID': player.prototypeID,
        'mcount': len(faction.memberset),
    }
Exemplo n.º 3
0
 def faction_apply(self, msgtype, body):
     p = self.player
     if p.factionID:
         return fail_msg(msgtype,
                         msgTips.FAIL_MSG_FACTION_ALREADY_HAD_FACTION)
     req = poem_pb.ApplyFaction()
     req.ParseFromString(body)
     if is_apply(p, req.factionID):
         return fail_msg(msgtype, msgTips.FAIL_MSG_FACTION_ALREADY_APPLYED)
     try:
         faction = Faction.get(req.factionID)
     except EntityNotFoundError:
         return fail_msg(msgtype, msgTips.FAIL_MSG_FACTION_NOT_THIS_FACTION)
     if faction.dflag:
         return fail_msg(
             msgtype,
             msgTips.FAIL_MSG_FACTION_CAN_NOT_JOIN_WILL_DISMISS_FACTION)
     if p.entityID in faction.inviteset:
         return fail_msg(msgtype, msgTips.FAIL_MSG_FACTION_ALREADY_INVITED)
     if faction.mode == poem_pb.Free:
         if not isrecommend(req.factionID):
             return fail_msg(msgtype,
                             msgTips.FAIL_MSG_FACTION_MEMBERS_LIMIT_EXCEED)
         join_faction(p.entityID, faction.factionID)
     elif faction.mode == poem_pb.Deny:
         return fail_msg(msgtype, msgTips.FAIL_MSG_FACTION_DENY_APPLY)
     else:
         # now = int(time.time())
         faction.applyset.add(self.player.entityID)
         faction.save()
         proxy.sync_apply(faction.leaderID)
         self.player.applyFactions.add(faction.factionID)
         # self.player.applyFactionID = faction.factionID
         # self.player.applyFactionTime = now + APPLYFACTIONCD
     p.save()
     p.sync()
     return success_msg(msgtype, '')