Commit e6585bbf authored by nanahira's avatar nanahira

Merge branch 'master' of github.com:IceYGO/windbot

parents bb7f6a1b bbb765d1
Pipeline #2687 failed with stages
in 41 seconds
This diff is collapsed.
This diff is collapsed.
......@@ -59,7 +59,7 @@ namespace WindBot.Game.AI
_game = game;
DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(DialogsData));
string dialogfilename = game.Dialog;
using (FileStream fs = File.OpenRead("Dialogs/" + dialogfilename + ".json"))
using (FileStream fs = Program.ReadFile("Dialogs", dialogfilename, "json"))
{
DialogsData data = (DialogsData)serializer.ReadObject(fs);
_welcome = data.welcome;
......
......@@ -43,7 +43,7 @@ namespace WindBot.Game
StreamReader reader = null;
try
{
reader = new StreamReader(new FileStream("Decks/" + name + ".ydk", FileMode.Open, FileAccess.Read));
reader = new StreamReader(Program.ReadFile("Decks", name, "ydk"));
Deck deck = new Deck();
bool side = false;
......
......@@ -201,5 +201,22 @@ namespace WindBot
}
#endif
}
public static FileStream ReadFile(string directory, string filename, string extension)
{
string tryfilename = filename + "." + extension;
string fullpath = Path.Combine(directory, tryfilename);
if (!File.Exists(fullpath))
fullpath = filename;
if (!File.Exists(fullpath))
fullpath = Path.Combine("../", filename);
if (!File.Exists(fullpath))
fullpath = Path.Combine("../deck/", filename);
if (!File.Exists(fullpath))
fullpath = Path.Combine("../", tryfilename);
if (!File.Exists(fullpath))
fullpath = Path.Combine("../deck/", tryfilename);
return new FileStream(fullpath, FileMode.Open, FileAccess.Read);
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment