def deny_apply_failure(factionID, entityID): faction = Faction.simple_load(factionID, ['applyset', 'leaderID']) safe_remove(faction.applyset, entityID) faction.save() proxy.sync_apply(faction.leaderID) player = Player.simple_load(entityID, ['applyFactions']) if is_apply(player, factionID): # 玩家还没有取消申请 safe_remove(player.applyFactions, factionID) # player.applyFactionTime = 0 faction.save() player.save() return SUCCESS return msgTips.FAIL_MSG_FACTION_ALREADY_CANCEL_APPLY
def allow_apply(factionID, entityID): faction = Faction.simple_load(factionID, ['applyset', 'memberset', 'leaderID']) safe_remove(faction.applyset, entityID) faction.save() proxy.sync_apply(faction.leaderID) player = g_entityManager.get_player(entityID) if not isrecommend(factionID): return msgTips.FAIL_MSG_FACTION_MEMBERS_LIMIT_EXCEED if is_apply(player, factionID) and not player.factionID: # 玩家还没有取消申请 join_faction(player.entityID, factionID) player.save() player.sync() faction.save() return SUCCESS return msgTips.FAIL_MSG_FACTION_ALREADY_CANCEL_APPLY
def faction_cancel_apply(self, msgtype, body): req = poem_pb.CancelApplyFaction() req.ParseFromString(body) if not is_applied(self.player): return fail_msg(msgtype, msgTips.FAIL_MSG_FACTION_NOT_APPLYED) try: faction = Faction.load(req.factionID) except EntityNotFoundError: return fail_msg(msgtype, msgTips.FAIL_MSG_FACTION_NOT_THIS_FACTION) safe_remove(faction.applyset, self.player.entityID) safe_remove(self.player.applyFactions, req.factionID) # self.player.applyFactionID = 0 # self.player.applyFactionTime = 0 faction.save() proxy.sync_apply(faction.leaderID) self.player.save() self.player.sync() return success_msg(msgtype, '')
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, '')