Ejemplo n.º 1
0
async def leave(message, cmd):
    msgId = message.author.id
    cIndex = -1
    print('leave')
    if cList.count(msgId):
        cIndex = ship.findbycap(msgId)
        if cIndex == -1:
            cIndex = ship.findbyid(msgId)
            if cIndex > -1:
                if ship.callbyindex(cIndex).leaving(msgId):
                    cList.remove(msgId)
                    await client.send_message(message.channel,
                                              'you just left a boat')
                else:
                    await client.send_message(message.channel,
                                              '배는 바다로 둘러 싸여있다')
        else:
            if ship.callbyindex(cIndex).captain == msgId:
                await client.send_message(message.channel,
                                          'you can\'t leave your boat')
            else:
                await client.send_message(message.channel,
                                          'you\'re a captain of another boat')
    else:
        await client.send_message(message.channel, 'you\'re not unemployeed')
Ejemplo n.º 2
0
async def board(message, cmd):
    msgId = message.author.id
    cIndex = -1
    print('board')
    if cList.count(msgId):
        await client.send_message(message.channel, 'he\'s already on crewlist')
    else:
        if cmd[1].startswith('#') and cmd[1][1:].isnumeric():
            cIndex = int(cmd[1][1:])
            tmpB = ship.callbyindex(cIndex)
            if tmpB is not None:
                if tmpB.boarding(msgId):
                    cList.append(msgId)
                    await client.send_message(message.channel,
                                              'you just boarded')
                    if tmpB.maxc == len(tmpB.crews) + 1:
                        await client.send_message(
                            message.server.get_member(tmpB.captain),
                            '당신의 선원이 다 모였습니다. 출항 대기중')
                        pass
                else:
                    await client.send_message(message.channel,
                                              'you failed to get on the boat')
            else:
                await client.send_message(message.channel,
                                          'there\'s no such boat')
        else:
            await client.send_message(message.channel, 'wrong boat number')
Ejemplo n.º 3
0
async def boom(message, cmd):
    msgId = message.author.id
    cIndex = -1
    print('boom')
    cIndex = ship.findbycap(msgId)
    if cIndex < 0:
        await client.send_message(message.channel,
                                  'there\'s no boat in this port')
    else:
        if len(ship.callbyindex(cIndex).crews) != 0:
            for i in ship.boom(cIndex):
                cList.remove(i)
        else:
            ship.boom(cIndex)
        cList.remove(msgId)
        await client.send_message(message.channel, 'boomed!')
Ejemplo n.º 4
0
async def crewList(message, cmd):
    """선장전용"""
    msgId = message.author.id
    cIndex = ship.findbycap(msgId)
    embed = discord.Embed(title='선원 목록', description="당신의 선원입니다.")

    if cIndex != -1:
        c = ship.callbyindex(msgId).crews
        if len(c) > 0:
            for i in c:
                tmp = message.server.get_member(msgId)
                embed.add_field(name=tmp.nick, inline=True)
            await client.send_message(msgId, embed=embed)
        else:
            await client.sendsend_message(message.channel, "선원이 없습니다.")
    else:
        await client.send_message(message.channel, "당신은 선장이 아닙니다.")
    pass
Ejemplo n.º 5
0
async def depart(message, cmd):
    msgId = message.author.id
    cIndex = ship.findbycap(msgId)
    if cIndex != -1:
        tmpS = ship.callbyindex(cIndex)
        if tmpS.state == 1:
            await client.send_message(message.channel, "이미 바다에 나가버린 배입니다.")
        elif (len(tmpS.crews) + 1) >= tmpS.reqc:
            tmpS.state = 1  #수정 필요
            await client.send_message(message.channel, "요오시 출항이다!")
        else:
            await client.send_message(
                message.channel,
                "바다는 위험하단다. 어서 선원들을 더 모아오렴 (필요 노예 수:{})".format(
                    tmpS.reqc - len(tmpS.crews) - 1))
    else:
        await client.send_message(message.channel, "유령선은 출발하지 않는다.")
    pass
Ejemplo n.º 6
0
async def boatInform(message, cmd):
    msgId = message.author.id
    cIndex = -1
    print("check Information : {} - {}".format(message.author.name, msgId))
    cIndex = ship.findbyid(msgId)
    if cIndex >= 0:
        msgS = message.server
        tmpS = ship.callbyindex(cIndex)
        await client.send_message(
            message.channel, '#{}-{} : {} 선장(처녀, 임신가능) ({}/{}-{})'.format(
                cIndex, tmpS.subject,
                msgS.get_member(tmpS.captain).name,
                len(tmpS.crews) + 1, tmpS.reqc, tmpS.maxc))
        pass
    else:
        await client.send_message(message.channel, "당신의 배는 없는 거샤아악")
        pass
    pass
Ejemplo n.º 7
0
async def setBoat(message, cmd):
    msgId = message.author.id
    cIndex = -1
    #has attr, get attr, set attr을 사용해서 적절하게 짠다.
    cIndex = ship.findbycap(msgId)
    if cIndex != -1:
        argv = argParse(cmd[1])
        if len(argv.items()) > 0:
            boat = ship.callbyindex(cIndex)
            for k, v in argv.items():
                #print('{} : {}'.format(k,v))
                if boat.has(str(k)):  #has 메서드는 hasattr의 클래스 래핑 함수다.
                    boat.set(str(k), v)  #set 메서드도 그렇다
                    pass
            #await client.send_message(message.channel,'변경 완료')
        else:
            print('no args')
        pass
    pass
Ejemplo n.º 8
0
async def kickCrew(message, cmd):
    msgId = message.author.id
    cIndex = ship.findbycap(msgId)

    if cIndex != -1:
        s = ship.callbyindex(cIndex)
        tmp = cmd[1].split()
        if tmp.isnumeric():
            n = int(tmp)
            if n > 0 and n <= len(s.crews):
                cList.remove(s.crews[n - 1])
                kicked = s.crews.pop(n - 1)
                await client.send_message(
                    message.channel, "선원:{}을 당신의 배에서 추방했다.".format(
                        message.server.get_member(kicked).nick))
        else:
            await client.send_message(message.channel, "잘못된 명령어")
    else:
        await client.send_message(message.channel, "당신은 선장이 아닙니다.")
    pass
Ejemplo n.º 9
0
async def callMem(message, cmd):
    msgId = message.author.id
    cIndex = -1
    cIndex = ship.findbycap(msgId)
    if cIndex > -1:
        boat = ship.callbyindex(cIndex)
        #await client.send_message(message.server.get_member(boat.captain),"너는 선장인테치 선원을 부를수 있는테치") 테스트용 선장 호출메시지
        if len(boat.crews) > 0:
            for c in boat.crews:
                await client.send_message(
                    message.server.get_member(c),
                    '중망호({})의 선장이 선원들을 호출했다.'.format(boat.subject))
                pass
            pass
        else:
            client.send_message()
        pass
    else:
        await client.send_message(message.channel, "너는 선장이 아닌테치!")
        pass
    pass