Rift Wizard

Rift Wizard

Not enough ratings
Output a list of spell / skill with python
By BlueSilverCat
I created a list of spells / skills with python.

This guide assumes Python users.
Therefore, detailed explanations are omitted.

Please check the source code and use it carefully.
   
Award
Favorite
Favorited
Unfavorite
How to use
        
  1. Install Python
        
  2. Crate a Text file to RiftWizard game directory.
    e.g. "C:\Program Files (x86)\Steam\steamapps\common\Rift Wizard\RiftWizard"
      
  3. Copy source code to a file.
      
  4. Change file name.
    e.g. "listSpell.py"
      
  5. Run with python.
    e.g. "py listSlell.py"
Source code
import re import operator import Spells import Upgrades def checkType(value, length): return True if isinstance(value, tuple) and len(value) >= length else False def capitalize(name, replace="_"): return " ".join([s.capitalize() for s in name.replace(replace, " ").split()]) def formatDescription(desc): if desc is None: return "" desc = desc.replace("\n", " ") desc = re.sub(r"\[(.+?)(?::.+?)?\]", r"\1", desc) desc = desc.replace("_", " ") if len(desc) > 0 and desc[-1] != ".": desc += "." return desc def tagsToString(tags): return [tag.name for tag in tags] class List(): @classmethod def getCsv(cls): string = cls.getTitleString() for data in cls.data: string += cls.getDataString(data) return string @classmethod def print(cls): print(cls.getCsv()) @classmethod def output(cls, path): with open(path, "w", encoding="utf_8") as file: file.write(cls.getCsv()) class ListSpell(List): data = [cl() for cl in Spells.all_player_spell_constructors] data.sort(key=operator.attrgetter("level", "name")) @staticmethod def getTitleString(): # string = f"name, tags, level, range, max charges, description, requires los, upgrade name, upgrade cost, upgrade value, upgrade description\n" string = f"name;tags;level;range;max charges;description;requires los;upgrade name;upgrade cost;upgrade value;upgrade description\n" return string @staticmethod def getResistsString(obj): if not hasattr(obj, "resists"): return "" result = [] for key, val in obj.resists.items(): result.append(' %d%% Resist %s' % (val, key.name)) return " ".join(result) @staticmethod def upgradesToString(upgrades, spellName, sep=";"): result = [] for u in upgrades: desc = formatDescription(getattr(u, "description", "")) name = f"'{u.name}'" if len(desc) > 0 else u.name # capitalize cost = u.level amount = getattr(u, "amount", "") result.append(f"{name}{sep}{cost}{sep}{amount}{sep}{desc}{sep}") return "".join(result)[:-len(sep)] @staticmethod def getDataString(obj, sep=";"): message = "" message += f"{obj.name}{sep}" message += f"{tagsToString(obj.tags)}{sep}" message += f"{obj.level}{sep}" message += f"{obj.range}{sep}" message += f"{obj.max_charges}{sep}" desc = obj.get_description().replace("\n", " ") message += f"{formatDescription(desc)}{sep}" message += f"{obj.requires_los}{sep}" message += f"{ListSpell.upgradesToString(obj.spell_upgrades, obj.name)}/n" return message class ListSkill(List): data = [cl() for cl in Upgrades.skill_constructors] data.sort(key=operator.attrgetter("level", "name")) @staticmethod def getTitleString(): # string = f"name, tags, level, description\n" string = f"name;tags;level;description\n" return string @staticmethod def getDataString(obj, sep=";"): message = "" message += f"{obj.name}{sep}" message += f"{tagsToString(obj.tags)}{sep}" message += f"{obj.level}{sep}" desc = obj.get_description().replace("\n", " ") desc += ListSkill.getTagBonusesString(obj) desc += ListSkill.getResistsString(obj) # desc += ListSkill.getGlobalBonusesString(obj) message += f"{formatDescription(desc)}{sep}\n" return message @staticmethod def getTagBonusesString(obj): if not hasattr(obj, "tag_bonuses"): return "" result = [] for tag, bonuses in obj.tag_bonuses.items(): for attr, val in bonuses.items(): result.append("%s spells and skills gain [%s_%s:%s]." % (tag.name, val, attr, attr)) return " ".join(result) # @staticmethod # def getGlobalBonusesString(obj): # if not hasattr(obj, "global_bonuses"): # return "" # result = [] # for attr, val in obj.global_bonuses.items(): # if val < 0: # val = -val # result.append("All spells and skills gain %d %s" % (val, capitalize(attr))) # # print(result) # return " ".join(result) @staticmethod def getResistsString(obj): if not hasattr(obj, "resists"): return "" result = [] for key, val in obj.resists.items(): result.append(' %d%% Resist %s' % (val, key.name)) return " ".join(result) if __name__ == "__main__": ListSpell.print() ListSpell.output("spell.csv") ListSkill.print() ListSkill.output("skill.csv")
2 Comments
BlueSilverCat  [author] 27 Nov, 2023 @ 2:08am 
@patras_t

Thank you for your comment.
You are right.
Based on your comment, I added a warning to the summary.
patras_t 26 Nov, 2023 @ 11:47pm 
Friendly warning to anyone seeing this post:
Although the code looks fine at first glance, never just copy and run code you get off the internet, it could easily be malicous. (I'm not accusing OP of being a malicous user, just a warning to some of the possible less tech-literate)