예제 #1
0
def ItemVariantsAHLoad(item, dbconn, id):
    restoredVariants = {}

    if (item.hasVariants):
        for code,svalue,value,value2,value3,value4,value5 in dbconn.execute("SELECT code,svalue,value,value2,value3,value4,value5 from ItemVariant WHERE item_list_id = %s;"%id): 
            if code == V_STAT:
                if item.spellEnhanceLevel == 9999:  # indicates an enchanted item, additional stat value
                    if value2:	# hack for float values
                        statValue = float(value) + float(value2) / 100.0
                    else:
                        statValue = value
                    var = (svalue,statValue)
                else:
                    var = (svalue,value)
                try:
                    restoredVariants[V_STAT].append(var)
                except KeyError:
                    restoredVariants[V_STAT] = [var]
            # Because of their unique abilities, V_WEAPON mods need to be kept separately.
            # They get stored in a list so one can still edit them independently.
            elif code == V_WEAPON:
                restoredVariants[V_WEAPON] = [value,value2,value3,value4]
            elif code == V_BANEWEAPON:
                restoredVariants[V_BANEWEAPON] = (svalue,value)
            elif code == V_WEAPONPROC:
                proc = ItemSpellTemp(SpellProto.byName(svalue),RPG_ITEM_TRIGGER_POISON,value)
                item.procs[proc] = [value2,value3]
                
        item.variants = restoredVariants
예제 #2
0
def ItemVariantsLoad(item):
    dbItem = item.item
    restoredVariants = {}
    for variant in list(dbItem.variants):
        if variant.code == V_STAT:
            if dbItem.spellEnhanceLevel == 9999:  # indicates an enchanted item, additional stat value
                if variant.value2:	# hack for float values
                    statValue = float(variant.value) + float(variant.value2) / 100.0
                else:
                    statValue = variant.value
                var = (variant.svalue,statValue)
            else:
                var = (variant.svalue,variant.value)
            try:
                restoredVariants[V_STAT].append(var)
            except KeyError:
                restoredVariants[V_STAT] = [var]
        # Because of their unique abilities, V_WEAPON mods need to be kept separately.
        # They get stored in a list so one can still edit them independently.
        elif variant.code == V_WEAPON:
            restoredVariants[V_WEAPON] = [variant.value,variant.value2,variant.value3,variant.value4]
        elif variant.code == V_BANEWEAPON:
            restoredVariants[V_BANEWEAPON] = (variant.svalue,variant.value)
        elif variant.code == V_WEAPONPROC:
            proc = ItemSpellTemp(SpellProto.byName(variant.svalue),RPG_ITEM_TRIGGER_POISON,variant.value)
            item.procs[proc] = [variant.value2,variant.value3]
    item.variants = restoredVariants
 def install(self,char):
     try:
         sp = SpellProto.byName(self.protoName)
     except:
         print "Spell: %s no longer exists"%self.protoName
         return
     
     FilterColumns(SpellStore,self.dbAttr)
     self.dbAttr["spellProtoID"] = sp.id
     self.dbAttr["characterID"] = char.id
     SpellStore(**self.dbAttr)
예제 #4
0
    def install(self, char):
        try:
            sp = SpellProto.byName(self.protoName)
        except:
            print "Spell: %s no longer exists" % self.protoName
            return

        FilterColumns(SpellStore, self.dbAttr)
        self.dbAttr["spellProtoID"] = sp.id
        self.dbAttr["characterID"] = char.id
        SpellStore(**self.dbAttr)
예제 #5
0
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)
예제 #7
0
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)
예제 #8
0
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