Exemple #1
0
def getNondummyList(game):
    from werewolf.game.rule.RuleFactory import SUBRULE_NAME, getSubrule
    wolfAssault = getSubrule(SUBRULE_NAME.ASSAULT_ONESELF, game)
    if wolfAssault:
        return Truecharacter.LIST_OTHERS
    else:
        return Truecharacter.LIST_OTHERS + Truecharacter.LIST_WEREWOLF
Exemple #2
0
 def writePlayerWill(self):
     from werewolf.game.rule.RuleFactory import SUBRULE_NAME, getSubrule
     tele = getSubrule(SUBRULE_NAME.TELEPATHY_NONE, self.game)
     if tele:
         mason_list = self.game.entry.getPlayersByTruecharacter(Truecharacter.FREEMASONS)
         for mason in mason_list:
             mason.writeWill("저는 초능력자입니다. (자동 생성된 로그입니다.)", "텔레")
Exemple #3
0
 def deleteTelepathy(self):
     from werewolf.game.rule.RuleFactory import SUBRULE_NAME, getSubrule
     tele = getSubrule(SUBRULE_NAME.TELEPATHY_NONE, self.game)
     if tele:
         cursor = self.game.db.cursor
         query = """update `zetyx_board_werewolf_entry` set telepathy ='0' where game = '%s'"""
         query %= (self.game.game)
         logging.debug(query)
         cursor.execute(query)
Exemple #4
0
    def initGame(self):
        #플레이해본 사람
        expertPlayers = self.game.entry.getExpertPlayers()
        #print "expertPlayers",expertPlayers

        #초보자
        novicePlayers = self.game.entry.getNovicePlayers()
        #print "novicePlayers",novicePlayers

        #분배할 직업 리스트
        truecharacterList = self.getTruecharacterList(len(novicePlayers) + len(expertPlayers) + 1)
        logging.info("players: %d", len(novicePlayers) + len(expertPlayers) + 1)

        # 더미룰 직업 분배
        dummyrule = getSubrule(SUBRULE_NAME.NPC_ALLOCATION, self.game)
        if not dummyrule:
            try:
                truecharacterList.remove(Truecharacter.HUMAN)
                npc_role = Truecharacter.HUMAN
            except ValueError:
                logging.debug("NO HUMAN exists -> autometically dummyrule turnon")
                dummyrule = True
        if dummyrule:
            from werewolf.game.entry.Role import getNondummyList
            nondummy_list = getNondummyList(self.game)
            while True:
                npc_role = random.choice(truecharacterList)
                if not npc_role in nondummy_list:
                    truecharacterList.remove(npc_role)
                    break


        #마을 사람 배치
        random.shuffle(novicePlayers)
        logging.debug("noviceEntry: %s", [str(player) for player in novicePlayers])
        while novicePlayers:
            try:
                truecharacterList.remove(Truecharacter.HUMAN)
            except ValueError:
                logging.debug("초보자 할당: 남은 마을사람 부족 %d명", len(truecharacterList))
                break
            player = novicePlayers.pop()
            logging.debug("%s with job %d", player, Truecharacter.HUMAN)
            player.setTruecharacter(Truecharacter.HUMAN)

        restPlayers = expertPlayers + novicePlayers
        random.shuffle(restPlayers)
        logging.debug("restEntry: %s", [str(player) for player in restPlayers])
        logging.debug("restJob: %s", truecharacterList)
        while restPlayers:
            player = restPlayers.pop()
            job = truecharacterList.pop()
            logging.debug("%s with job %d", player, job)
            player.setTruecharacter(job)
        if truecharacterList:
            logging.error("Some roles are NOT assigned: %s", truecharacterList)

        #2. 희생자의 코멘트
        victim = self.game.entry.getVictim()
        victim.setTruecharacter(npc_role)
        logging.debug("victim: %s", victim)
        victim.writeWill()
        self.writePlayerWill()

        #3. 게임 정보 업데이트
        self.game.setGameState("state", GAME_STATE.PLAYING)
        self.game.setGameState("day", self.game.day+1)

        #보통 방으로..
        cursor = self.game.db.cursor
        query = "update `zetyx_board_werewolf` set `%s` = '%s'  where no = '%s'"
        query %= ("is_secret", 0, self.game.game)
        logging.debug(query)
        cursor.execute(query)

        #4. 코멘트 초기화
        self.game.entry.initComment()