def CreateSpellPages(spawnSpells):

    indexPage = "---+ Index of all Spells\n\n"
    spellScrollPage = "---+ Spell Scrolls\n\n"

    for s in SpellProto.select(orderBy="name"):
        page = SpellPage

        TWIKINAME = "Spell%s" % GetTWikiName(s.name)
        indexPage += "\t* [[%s][%s]]\n" % (TWIKINAME, s.name)

        DESCTEXT = GenDescText(s, spawnSpells, TWIKINAME)
        STATTEXT = GenStatText(s)
        EFFECTTEXT = GenEffectText(s)

        page = page.replace("^^SPELLNAME^^",
                            s.name).replace("^^DESCTEXT^^", DESCTEXT).replace(
                                "^^STATTEXT^^",
                                STATTEXT).replace("^^EFFECTTEXT^^", EFFECTTEXT)

        if len(s.exclusions):
            overwritings = {True: [], False: []}
            for sname, overwrites in s.exclusions.iteritems():
                overwritings[overwrites].append(sname)
            page += "*Overwrites:* %s\n\n" % ', '.join(
                "[[Spell%s][%s]]" % (GetTWikiName(sname), sname)
                for sname in overwritings[True])
            page += "*Gets overwritten by:* %s\n\n\n" % ', '.join(
                "[[Spell%s][%s]]" % (GetTWikiName(sname), sname)
                for sname in overwritings[False])

        if len(s.classes):
            scrollname = "Scroll of %s" % s.name
            TWIKISCROLLNAME = GetTWikiName(scrollname)
            page += "*Spell Scroll:* [[Item%s][%s]]\n" % (TWIKISCROLLNAME,
                                                          scrollname)
            spellScrollPage += "\t* [[Item%s][%s]]\n" % (TWIKISCROLLNAME,
                                                         scrollname)

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

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

    CreateSpellIndex(spawnSpells)

    return SPELLSUMMONITEMS, SPELLCLASSES
def SiftSpellProtos():
    from mud.world.spell import SpellProto
    
    sounds = ("sndCasting","sndBegin","sndTick","sndEnd")
    
    for spell in SpellProto.select():
        for s in sounds:
            snd = getattr(spell,s)
            if snd:
                AddSound("./$/data/sound/%s"%snd)
        
        for e in spell.effectProtos:
            if e.summonPet:
                SiftSpawn(e.summonPet)
def SiftSpellProtos():
    from mud.world.spell import SpellProto

    sounds = ("sndCasting", "sndBegin", "sndTick", "sndEnd")

    for spell in SpellProto.select():
        for s in sounds:
            snd = getattr(spell, s)
            if snd:
                AddSound("./$/data/sound/%s" % snd)

        for e in spell.effectProtos:
            if e.summonPet:
                SiftSpawn(e.summonPet)
def CreateSpellPages(spawnSpells):
    
    indexPage = "---+ Index of all Spells\n\n"
    spellScrollPage = "---+ Spell Scrolls\n\n"
    
    for s in SpellProto.select(orderBy="name"):
        page = SpellPage
        
        TWIKINAME = "Spell%s"%GetTWikiName(s.name)
        indexPage += "\t* [[%s][%s]]\n"%(TWIKINAME,s.name)
        
        DESCTEXT = GenDescText(s,spawnSpells,TWIKINAME)
        STATTEXT = GenStatText(s)
        EFFECTTEXT = GenEffectText(s)
        
        page = page.replace("^^SPELLNAME^^",s.name).replace("^^DESCTEXT^^",DESCTEXT).replace("^^STATTEXT^^",STATTEXT).replace("^^EFFECTTEXT^^",EFFECTTEXT)
        
        if len(s.exclusions):
            overwritings = {True: [], False: []}
            for sname,overwrites in s.exclusions.iteritems():
                overwritings[overwrites].append(sname)
            page += "*Overwrites:* %s\n\n"%', '.join("[[Spell%s][%s]]"%(GetTWikiName(sname),sname) for sname in overwritings[True])
            page += "*Gets overwritten by:* %s\n\n\n"%', '.join("[[Spell%s][%s]]"%(GetTWikiName(sname),sname) for sname in overwritings[False])
        
        if len(s.classes):
            scrollname = "Scroll of %s"%s.name
            TWIKISCROLLNAME = GetTWikiName(scrollname)
            page += "*Spell Scroll:* [[Item%s][%s]]\n"%(TWIKISCROLLNAME,scrollname)
            spellScrollPage += "\t* [[Item%s][%s]]\n"%(TWIKISCROLLNAME,scrollname)
        
        f = file("./distrib/twiki/data/MoMWorld/%s.txt"%TWIKINAME,"w")
        f.write(page)
        f.close()
    
    f = file("./distrib/twiki/data/MoMWorld/ItemSpellScrollsIndex.txt","w")
    f.write(spellScrollPage)
    f.close()
    f = file("./distrib/twiki/data/MoMWorld/SpellAllIndex.txt","w")
    f.write(indexPage)
    f.close()
    
    CreateSpellIndex(spawnSpells)
    
    return SPELLSUMMONITEMS,SPELLCLASSES