-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved project structure and bumped toc version
- Loading branch information
Showing
12 changed files
with
165 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
CreatureFactionInfo.lua | ||
Factions.lua | ||
enUS/FactionInfo.lua | ||
__pycache__/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
ID,UnitName,FactionName,FactionID | ||
3394,Barak Kodobane,"Centaur, Kolkar",90 | ||
3395,Verog the Dervish,"Centaur, Kolkar",90 | ||
3396,Hezrul Bloodmark,"Centaur, Kolkar",90 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from FlavorFactions.common import merge_update_csv_files | ||
from FlavorFactions.generate_CreatureFactionInfo import generate_creature_faction_info_lua | ||
from FlavorFactions.generate_Factions import generate_factions_lua, generate_faction_info_lua, get_base_neutral_factions | ||
|
||
# Base neutral factions (e.g Booty Bay) are always displayed for characters already. | ||
# So no need to handle them ourselves => we can decrease AddOn size! | ||
base_neutral_factions = get_base_neutral_factions('Factions.csv') | ||
|
||
# Unfortunately, GetFactionInfoByGroupID does not return data for opposite faction reputations so we store them here. | ||
factions_csv_files = [ | ||
'Factions.csv' | ||
] | ||
factions_df = merge_update_csv_files(factions_csv_files, 'ID') | ||
factions_df.ID = factions_df.ID.astype(int) | ||
factions_df = factions_df[~factions_df.ID.isin(base_neutral_factions)] | ||
generate_factions_lua('Factions.lua', factions_df) | ||
generate_faction_info_lua('enUS/FactionInfo.lua', factions_df) | ||
|
||
creature_csv_files = [ | ||
'CreatureFactionInfo.csv', | ||
'FixesCreatureFactionInfo.csv' | ||
] | ||
creature_faction_info_df = merge_update_csv_files(creature_csv_files, 'ID') | ||
creature_faction_info_df.FactionID = creature_faction_info_df.FactionID.astype(int) | ||
creature_faction_info_df = creature_faction_info_df[~creature_faction_info_df.FactionID.isin(base_neutral_factions)] | ||
generate_creature_faction_info_lua('CreatureFactionInfo.lua', creature_faction_info_df) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
local _, L = ... | ||
-- Improved faction names that are consistent with already existing ones | ||
|
||
L["Gnoll - Riverpaw_Name"] = "Riverpaw Gnolls" | ||
L["Gnoll - Redridge_Name"] = "Redridge Gnolls" | ||
L["Gnoll - Shadowhide_Name"] = "Shadowhide Gnolls" | ||
L["Undead, Scourge_Name"] = "Scourge" | ||
L["Troll, Bloodscalp_Name"] = "Bloodscalp Trolls" | ||
L["Troll, Skullsplitter_Name"] = "Skullsplitter Trolls" | ||
L["Troll, Frostmane_Name"] = "Frostmane Trolls" | ||
L["Orc, Blackrock_Name"] = "Blackrock Clan" | ||
L["Dragonflight, Green_Name"] = "Green Dragonflight" | ||
L["Human, Night Watch_Name"] = "Night Watch" | ||
L["Dragonflight, Red_Name"] = "Red Dragonflight" | ||
L["Gnoll - Mosshide_Name"] = "Mosshide Gnolls" | ||
L["Orc, Dragonmaw_Name"] = "Dragonmaw Clan" | ||
L["Gnome - Leper_Name"] = "Leper Gnomes" | ||
L["Gnoll - Rothide_Name"] = "Rothide Gnolls" | ||
L["Gnoll - Mudsnout_Name"] = "Mudsnout Gnolls" | ||
L["Dragonflight, Black_Name"] = "Black Dragonflight" | ||
L["Troll, Witherbark_Name"] = "Witherbark Trolls" | ||
L["Quilboar, Razormane_Name"] = "Razormane Quillboars" | ||
L["Quilboar, Bristleback_Name"] = "Bristleback Quillboars" | ||
L["Centaur, Kolkar_Name"] = "Kolkar Clan Centaur" | ||
L["Centaur, Galak_Name"] = "Galak Clan Centaur" | ||
L["Quilboar, Razorfen_Name"] = "Razorfen Quillboars" | ||
L["Quilboar, Razormane 2_Name"] = "Razormane Quillboars" | ||
L["Quilboar, Deathshead_Name"] = "Deathshead Quillboars" | ||
L["Dragonflight, Bronze_Name"] = "Bronze Dragonflight" | ||
L["Dragonflight, Blue_Name"] = "Blue Dragonflight" | ||
L["Troll, Vilebranch_Name"] = "Vilebranch Trolls" | ||
|
||
|
||
|
||
|
||
|
||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,18 @@ | ||
import csv | ||
import pandas as pd | ||
|
||
from FlavorFactions.common import unlock_file, lock_file | ||
|
||
# Base neutral factions (e.g Booty Bay) are always displayed for characters already. | ||
# So no need to handle them ourselves => we can decrease AddOn size! | ||
base_neutral_factions = set() | ||
with open('Factions.csv', 'r', encoding='UTF-8-sig', newline='') as csv_file: | ||
reader = csv.DictReader(csv_file, dialect="excel-backslash") | ||
for row in reader: | ||
try: | ||
faction_id = int(row['ID']) | ||
if int(row['BaseFaction']) == 1: | ||
base_neutral_factions.add(faction_id) | ||
except ValueError: | ||
print(f"Invalid row: {row}") | ||
|
||
LUA_FILE_PATH = 'CreatureFactionInfo.lua' | ||
def generate_creature_faction_info_lua(lua_file_path, creature_faction_info_df): | ||
creature_faction_info_df = creature_faction_info_df.apply(lambda row: f"F[{row.ID}] = {row.FactionID}", axis=1) | ||
pd.set_option("display.max_colwidth", 10000) # disable truncation | ||
|
||
unlock_file(LUA_FILE_PATH) | ||
|
||
with open(LUA_FILE_PATH, 'w', encoding='UTF-8') as lua_file: | ||
luaHeader = """-- *** DO NOT EDIT. THIS IS A GENERATED FILE. *** | ||
unlock_file(lua_file_path) | ||
with open(lua_file_path, 'w', encoding='UTF-8') as lua_file: | ||
lua_header = """-- *** DO NOT EDIT. THIS IS A GENERATED FILE. *** | ||
--- Format: F[ID] = <factionID> | ||
CreatureFactionInfo = {} | ||
local F = CreatureFactionInfo\n""" | ||
lua_file.write(luaHeader) | ||
with open('CreatureFactionInfo.csv', 'r', encoding='UTF-8-sig', newline='') as csv_file: | ||
reader = csv.DictReader(csv_file, dialect="excel-backslash") | ||
for row in reader: | ||
try: | ||
unit_id = int(row['ID']) | ||
faction_id = int(row['FactionID']) | ||
if faction_id not in base_neutral_factions: | ||
lua_file.write(f'F[{unit_id}] = {faction_id}\n') | ||
except ValueError: | ||
print(f"Invalid row: {row}") | ||
|
||
lock_file(LUA_FILE_PATH) | ||
lua_file.write(lua_header) | ||
creature_faction_info_df.to_string(buf=lua_file, index=False) | ||
lock_file(lua_file_path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,59 @@ | ||
import csv | ||
|
||
import pandas as pd | ||
|
||
from FlavorFactions.common import unlock_file, lock_file | ||
|
||
# Unfortunately, GetFactionInfoByGroupID does not return data for opposite faction reputations so we store them here. | ||
|
||
LUA_FILE_PATH = 'Factions.lua' | ||
unlock_file(LUA_FILE_PATH) | ||
def generate_factions_lua(lua_file_path, factions_df): | ||
def lua_assignation(row): | ||
return f'F[{row.ID}] = {{name="{row.Name_lang}", isGameplayOnly={"true" if row.GameplayOnly == "1" else "false"}, isBaseFaction={row.BaseFaction}}}' | ||
|
||
factions_df = factions_df.apply(lua_assignation, axis=1) | ||
|
||
unlock_file(lua_file_path) | ||
|
||
with open(lua_file_path, 'w', encoding='UTF-8') as lua_file: | ||
lua_header = """-- *** DO NOT EDIT. THIS IS A GENERATED FILE. *** | ||
Factions = {} | ||
local F = Factions\n""" | ||
lua_file.write(lua_header) | ||
pd.set_option("display.max_colwidth", 10000) # disable truncation | ||
factions_df.to_string(buf=lua_file, index=False) | ||
|
||
lock_file(lua_file_path) | ||
|
||
|
||
with open(LUA_FILE_PATH, 'w', encoding='UTF-8') as lua_file: | ||
luaHeader = """-- *** DO NOT EDIT. THIS IS A GENERATED FILE. *** | ||
Factions = {} | ||
local F = Factions\n""" | ||
lua_file.write(luaHeader) | ||
with open('Factions.csv', 'r', encoding='UTF-8-sig', newline='') as csv_file: | ||
def generate_faction_info_lua(lua_file_path, factions_df): | ||
names_df = factions_df[factions_df.Name_lang != ""].apply( | ||
lambda row: f'L["{row.Name_lang}_Name"] = "{row.Name_lang}"', axis=1 | ||
) | ||
|
||
unlock_file(lua_file_path) | ||
|
||
with open(lua_file_path, 'w', encoding='UTF-8') as lua_file: | ||
lua_header = """-- *** DO NOT EDIT. THIS IS A GENERATED FILE. *** | ||
local _, L = ...\n""" | ||
lua_file.write(lua_header) | ||
pd.set_option("display.max_colwidth", 10000) # disable truncation | ||
names_df.to_string(buf=lua_file, index=False) | ||
|
||
lock_file(lua_file_path) | ||
|
||
|
||
def get_base_neutral_factions(factions_csv_path): | ||
""" | ||
:param factions_csv_path: Path to CSV file with factions | ||
:return: A set of integer faction IDs of neutral factions present in base World of Warcraft. | ||
""" | ||
factions = set() | ||
with open(factions_csv_path, 'r', encoding='UTF-8-sig', newline='') as csv_file: | ||
reader = csv.DictReader(csv_file, dialect="excel-backslash") | ||
for row in reader: | ||
try: | ||
faction_id = int(row['ID']) | ||
faction_name = row['Name_lang'] | ||
faction_description = row['Description_lang'] | ||
faction_gameplay_only = True if int(row["GameplayOnly"]) == 1 else False | ||
faction_base_faction = int(row["BaseFaction"]) | ||
lua_file.write(f'F[{faction_id}] = {{name="{faction_name}", description="{faction_description}", ' | ||
f'isGameplayOnly={"true" if faction_gameplay_only else "false"}, isBaseFaction=' | ||
f'{faction_base_faction}}}\n') | ||
if int(row['BaseFaction']) == 1: | ||
factions.add(faction_id) | ||
except ValueError: | ||
print(f"Invalid row: {row}") | ||
|
||
lock_file(LUA_FILE_PATH) | ||
return factions |