Exemple #1
0
 def install(self):
     FilterColumns(Spawn, self.dbAttr)
     try:
         s = Spawn(**self.dbAttr)
     except:
         print "Problem installing %s trying with an appended X to name" % (
             self.dbAttr["name"])
         self.dbAttr["name"] = self.dbAttr["name"] + "X"
         try:
             s = Spawn(**self.dbAttr)
         except:
             raise "Error"
     return s
def CreateSpawnIndexByLevel():
    page = '%META:TOPICINFO{author="JoshRitter" date="1121799107" format="1.0" version="1.1"}%\n'
    page += "---+ Spawn Index by Level\n\n"
    
    level = 0
    for spawn in Spawn.select(orderBy="plevel"):
        if level != spawn.level:
            page += "---++ Level %i<br>\n"%spawn.level
            level = spawn.level
        page += "\t* [[Spawn%s][%s]]\n"%(GetTWikiName(spawn.name),spawn.name)
    
    f = file("./distrib/twiki/data/MoMWorld/SpawnIndexByLevel.txt","w")
    f.write(page)
    f.close()
def CreateSpawnIndexByLevel():
    page = '%META:TOPICINFO{author="JoshRitter" date="1121799107" format="1.0" version="1.1"}%\n'
    page += "---+ Spawn Index by Level\n\n"

    level = 0
    for spawn in Spawn.select(orderBy="plevel"):
        if level != spawn.level:
            page += "---++ Level %i<br>\n" % spawn.level
            level = spawn.level
        page += "\t* [[Spawn%s][%s]]\n" % (GetTWikiName(
            spawn.name), spawn.name)

    f = file("./distrib/twiki/data/MoMWorld/SpawnIndexByLevel.txt", "w")
    f.write(page)
    f.close()
def CreateSpawnPages():
    #SpawnIndex
    CreateSpawnIndexByLevel()
    
    indexPage = '%META:TOPICINFO{author="JoshRitter" date="1121799107" format="1.0" version="1.1"}%\n'
    indexPage += "---+ Spawn (NPC) Index\n\n"
    
    for spawn in Spawn.select(orderBy="name"):
        SPAWNNAME = spawn.name
        TWIKINAME = 'Spawn'+GetTWikiName(SPAWNNAME)
        indexPage += "\t* [[%s][%s]]\n"%(TWIKINAME,SPAWNNAME)
        if spawn.flags&RPG_SPAWN_UNIQUE and spawn.realm == RPG_REALM_MONSTER:
            if spawn.flags&RPG_SPAWN_INN:
                SPAWNNAME += " (Unique Monster Innkeeper)"
            else:
                SPAWNNAME += " (Unique Monster)"
        elif spawn.flags&RPG_SPAWN_UNIQUE:
            if spawn.flags&RPG_SPAWN_INN:
                SPAWNNAME += " (Unique NPC Innkeeper)"
            else:
                SPAWNNAME += " (Unique NPC)"
        
        #levels
        levels = ((spawn.plevel,spawn.pclassInternal),(spawn.slevel,spawn.sclassInternal),(spawn.tlevel,spawn.tclassInternal))
                
        LEVELTEXT = ""
        for level,klass in levels:
            if not level or not klass:
                break
            LEVELTEXT += "[[Class%s][%s]] (%i) "%(GetTWikiName(klass),klass,level)
        
        DESCTEXT = "None"
        if spawn.desc:
            DESCTEXT = LINKPARSER.sub(r'[[\1][\2]]',spawn.desc)
        
        #HABITAT
        zones = []
        for sinfo in spawn.spawnInfos:
            for sgroup in sinfo.spawnGroups:
                if sgroup.zone not in zones:
                    zones.append(sgroup.zone)
        
        HABITATTEXT = ', '.join('[[Zone%s][%s]]'%(GetTWikiName(z.niceName),z.niceName) for z in zones)
        if not HABITATTEXT:
            HABITATTEXT = "Summoned"
        
        LOOTTEXT = GenLootText(spawn)
        FACTIONSTEXT = GenFactionsText(spawn)
        QUESTTEXT = GenQuestText(spawn)
        
        STATSTEXT = GenStatsText(spawn)
        VENDORTEXT = GenVendorText(spawn)
        
        if spawn.realm == RPG_REALM_NEUTRAL:
            realmtext = "Neutral"
        if spawn.realm == RPG_REALM_DARKNESS:
            realmtext = "Minions of Darkness"
        if spawn.realm == RPG_REALM_LIGHT:
            realmtext = "Fellowship of Light"
        if spawn.realm == RPG_REALM_MONSTER:
            realmtext = "Monster"
        
        image = spawn.model+spawn.textureSingle
        image = image.upper()
        image = image.replace(".DTS","")
        image = image.replace("/","")
        
        IMAGELINK = ""
        if image:
            if os.path.isfile("./mud/worlddocs/images/%s.jpg"%image):
                pass
            else:
                if "QUARANTINE" not in image:
                    print image+'.jpg'
                image = "UNKNOWN.jpg"
            
            IMAGELINK = r'<a href="http://www.prairiegames.com/twiki/pub/MoMWorld/%s.jpg"><img src="http://www.prairiegames.com/twiki/pub/MoMWorld/%s.jpg" width="192" height="192" align="right"  /></a>'%(image,image)
        
        page = SpawnPage
        page = page.replace("^^SPAWNNAME^^",SPAWNNAME)
        page = page.replace("^^LEVELTEXT^^",LEVELTEXT)
        page = page.replace("^^DESCTEXT^^",DESCTEXT)
        page = page.replace("^^LOOTTEXT^^",LOOTTEXT)
        page = page.replace("^^FACTIONSTEXT^^",FACTIONSTEXT)
        page = page.replace("^^STATSTEXT^^",STATSTEXT)
        page = page.replace("^^HABITATTEXT^^",HABITATTEXT)
        page = page.replace("^^VENDORTEXT^^",VENDORTEXT)
        page = page.replace("^^QUESTTEXT^^",QUESTTEXT)
        page = page.replace("^^IMAGELINK^^",IMAGELINK)
        page = page.replace("^^REALMTEXT^^",realmtext)
        
        f = file("./distrib/twiki/data/MoMWorld/%s.txt"%TWIKINAME,"w")
        f.write(page)
        f.close()
    
    f = file("./distrib/twiki/data/MoMWorld/SpawnIndex.txt","w")
    f.write(indexPage)
    f.close()
    
    return QUESTDIALOGS,SPAWNSPELLS,SPAWNFACTIONS
def CreateSpawnPages():
    #SpawnIndex
    CreateSpawnIndexByLevel()

    indexPage = '%META:TOPICINFO{author="JoshRitter" date="1121799107" format="1.0" version="1.1"}%\n'
    indexPage += "---+ Spawn (NPC) Index\n\n"

    for spawn in Spawn.select(orderBy="name"):
        SPAWNNAME = spawn.name
        TWIKINAME = 'Spawn' + GetTWikiName(SPAWNNAME)
        indexPage += "\t* [[%s][%s]]\n" % (TWIKINAME, SPAWNNAME)
        if spawn.flags & RPG_SPAWN_UNIQUE and spawn.realm == RPG_REALM_MONSTER:
            if spawn.flags & RPG_SPAWN_INN:
                SPAWNNAME += " (Unique Monster Innkeeper)"
            else:
                SPAWNNAME += " (Unique Monster)"
        elif spawn.flags & RPG_SPAWN_UNIQUE:
            if spawn.flags & RPG_SPAWN_INN:
                SPAWNNAME += " (Unique NPC Innkeeper)"
            else:
                SPAWNNAME += " (Unique NPC)"

        #levels
        levels = ((spawn.plevel, spawn.pclassInternal),
                  (spawn.slevel, spawn.sclassInternal), (spawn.tlevel,
                                                         spawn.tclassInternal))

        LEVELTEXT = ""
        for level, klass in levels:
            if not level or not klass:
                break
            LEVELTEXT += "[[Class%s][%s]] (%i) " % (GetTWikiName(klass), klass,
                                                    level)

        DESCTEXT = "None"
        if spawn.desc:
            DESCTEXT = LINKPARSER.sub(r'[[\1][\2]]', spawn.desc)

        #HABITAT
        zones = []
        for sinfo in spawn.spawnInfos:
            for sgroup in sinfo.spawnGroups:
                if sgroup.zone not in zones:
                    zones.append(sgroup.zone)

        HABITATTEXT = ', '.join('[[Zone%s][%s]]' %
                                (GetTWikiName(z.niceName), z.niceName)
                                for z in zones)
        if not HABITATTEXT:
            HABITATTEXT = "Summoned"

        LOOTTEXT = GenLootText(spawn)
        FACTIONSTEXT = GenFactionsText(spawn)
        QUESTTEXT = GenQuestText(spawn)

        STATSTEXT = GenStatsText(spawn)
        VENDORTEXT = GenVendorText(spawn)

        if spawn.realm == RPG_REALM_NEUTRAL:
            realmtext = "Neutral"
        if spawn.realm == RPG_REALM_DARKNESS:
            realmtext = "Minions of Darkness"
        if spawn.realm == RPG_REALM_LIGHT:
            realmtext = "Fellowship of Light"
        if spawn.realm == RPG_REALM_MONSTER:
            realmtext = "Monster"

        image = spawn.model + spawn.textureSingle
        image = image.upper()
        image = image.replace(".DTS", "")
        image = image.replace("/", "")

        IMAGELINK = ""
        if image:
            if os.path.isfile("./mud/worlddocs/images/%s.jpg" % image):
                pass
            else:
                if "QUARANTINE" not in image:
                    print image + '.jpg'
                image = "UNKNOWN.jpg"

            IMAGELINK = r'<a href="http://www.prairiegames.com/twiki/pub/MoMWorld/%s.jpg"><img src="http://www.prairiegames.com/twiki/pub/MoMWorld/%s.jpg" width="192" height="192" align="right"  /></a>' % (
                image, image)

        page = SpawnPage
        page = page.replace("^^SPAWNNAME^^", SPAWNNAME)
        page = page.replace("^^LEVELTEXT^^", LEVELTEXT)
        page = page.replace("^^DESCTEXT^^", DESCTEXT)
        page = page.replace("^^LOOTTEXT^^", LOOTTEXT)
        page = page.replace("^^FACTIONSTEXT^^", FACTIONSTEXT)
        page = page.replace("^^STATSTEXT^^", STATSTEXT)
        page = page.replace("^^HABITATTEXT^^", HABITATTEXT)
        page = page.replace("^^VENDORTEXT^^", VENDORTEXT)
        page = page.replace("^^QUESTTEXT^^", QUESTTEXT)
        page = page.replace("^^IMAGELINK^^", IMAGELINK)
        page = page.replace("^^REALMTEXT^^", realmtext)

        f = file("./distrib/twiki/data/MoMWorld/%s.txt" % TWIKINAME, "w")
        f.write(page)
        f.close()

    f = file("./distrib/twiki/data/MoMWorld/SpawnIndex.txt", "w")
    f.write(indexPage)
    f.close()

    return QUESTDIALOGS, SPAWNSPELLS, SPAWNFACTIONS