コード例 #1
0
def makeGuild(request):
    mandatory_keys, optional_keys = getKeys()
    fields = Fields(request.text, mandatory_keys, optional_keys)
    editFields(fields)
    makeHyperlinks(fields)
    editHeadsAndVices(fields)
    if not guildAlreadyExists(fields):
        checkGuildInfo(fields)
        Guild.create(**fields)
コード例 #2
0
def guildAlreadyExists(guild):
    name = guild['name']
    head = guild['head']
    old_guild = Guild(name=name)
    if old_guild.exists:
        if old_guild.head == head:
            return True
コード例 #3
0
def getGuild(text, result):
    result_index = text.index(result)
    name = text[:result_index].strip()
    guild = Guild(name=name)
    if guild.exists:
        return guild
    else:
        raise GB_guild_not_found
コード例 #4
0
def handleGuildCommand(request):
    command = request.guild_command
    if command == "exclude":
        player = Player(request.id)
        guild = player.guild
        excludeFromGuild(player)
    elif command == "setrank":
        guild = player.guild
        guild.setPosition(request.id, request.rank)
    elif command == "endguild":
        guild = Guild(request.id)
        endGuild(guild)
        refreshGuilds()
    database.save()
    updateGuild(guild.id)
コード例 #5
0
def getGuilds():
    guild_ids = database.getAll("guilds", "id")
    return [Guild(id=id) for id in guild_ids]
コード例 #6
0
def editFields(fields):
	players = fields['участники'].split(" ")
	fields['участники'] = [Player(id=p) for p in players]
	fields['волны'] = int(fields['волны'])
	fields['гильдия'] = Guild(name=fields['гильдия'])
	fields['испытание'] = Achi(name=fields['испытание'])
コード例 #7
0
def checkGuildName(guild_name):
    pattern = r"^[\[\]A-Za-z_\d ]+$"
    if search(pattern, guild_name) is None:
        raise GMError("Название гильдии содержит недопустимые символы.")
    elif Guild(name=guild_name).exists:
        raise GMError("Гильдия с таким названием уже существует.")