Skip to content

Commit

Permalink
Make Deck.Load always return a deck object
Browse files Browse the repository at this point in the history
  • Loading branch information
edo9300 committed Jul 1, 2021
1 parent a93c951 commit 7932d92
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions Game/AI/Deck.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ private void AddNewCard(int cardId, bool mainDeck, bool sideDeck)
public static Deck Load(string name)
{
StreamReader reader = null;
Deck deck = new Deck();
try
{
reader = new StreamReader(new FileStream(Path.IsPathRooted(name) ? name : Path.Combine(Program.AssetPath, "Decks/", name + ".ydk"), FileMode.Open, FileAccess.Read));

Deck deck = new Deck();
bool main = true;
bool side = false;

Expand Down Expand Up @@ -64,14 +64,13 @@ public static Deck Load(string name)
}

reader.Close();

return deck;
}
catch (Exception)
{
Logger.WriteLine("Failed to load deck: " + name + ".");
reader?.Close();
return null;
}
return deck;
}
}
}

0 comments on commit 7932d92

Please sign in to comment.