Пример #1
0
def createScene(playdata, characters, pos, castBots, charList):
    text = ""
    line = ""
    numChars = 0
    numLines = 0
    dirFrustration = 0
    dirAnger = 0
    chars = []
    scene = DataStructures.SceneObject()
    for part in playdata.sceneList:
        scene.length = scene.length + (
            part.length +
            random.random() * part.vLength) * part.getContribution(pos)
        numChars = math.floor(numChars +
                              part.numChars * part.getContribution(pos))
        #dirAnger = math.ceil(len(part.characters)*part.getContribution(pos))

    scene.length = scene.length / len(playdata.sceneList)
    scene.length = max(scene.length, .1)
    numChars = max([numChars, 3])
    numLines = playdata.numLines * scene.length
    chatBots = []
    print scene.length
    print numChars
    for i in range(2, int(numChars)):
        j = random.randint(0, len(characters) - 1)
        chars.append(characters[j])
        chatBots.append(castBots[j])

    if len(chars) < 2:
        j = random.randint(0, len(characters) - 1)
        chars.append(characters[j])
        chatBots.append(castBots[j])
        j = random.randint(0, len(characters) - 1)
        chars.append(characters[j])
        chatBots.append(castBots[j])
    while numLines > 0:
        numLines = numLines - 1
        talk = chars[0]
        for temp in chars:
            if temp.frustration > talk.frustration:
                talk = temp
            temp.frustration = temp.frustration + temp.anger
        print talk.name
        print chars.index(talk)
        print chatBots
        print chars
        bot = chatBots[chars.index(talk)]

        if 'DIRECTION' in talk.name:
            line = bot.get_response(line)
            text = text + line + "\n"
            talk.frustration = 0
        else:
            text = text + "\t\t 0m" + str(charList.index(talk)) + "m0\n"
            line = bot.get_response(line)
            text = text + "\t" + line + "\n"
            talk.frustration = 0

    return {'text': text, 'scene': scene}
Пример #2
0
def AddToStructures(line):
    global PlayList
    global scriptWatcher
    global lineCounter
    global sceneCounter
    global charWatcher
    global firstScene
    global firstPlay

    if line.scene == sceneCounter and line.script == scriptWatcher:
        return

    #if new play
    if line.script != scriptWatcher:
        if not firstPlay:
            UpdatePreviousScene()
            UpdatePreviousScript()
        scriptWatcher = line.script
        resetCounters()
        PlayList.append(DataStructures.PlayData(line.script))
        firstPlay = False
        firstScene = True
    lineCounter += 1
    #if new Scene
    if line.scene != sceneCounter:
        if not firstScene:
            UpdatePreviousScene()
        sceneCounter = line.scene
        temp = DataStructures.SceneObject()
        temp.start = lineCounter
        temp.name = str(sceneCounter)
        getPlayinList(scriptWatcher).sceneList.append(temp)
        firstScene = False
    #if new Character
    if line.character not in charWatcher:
        charWatcher.append(line.character)
    return