Skip to content

Commit 7932d92

Browse files
committed
Make Deck.Load always return a deck object
1 parent a93c951 commit 7932d92

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

Game/AI/Deck.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ private void AddNewCard(int cardId, bool mainDeck, bool sideDeck)
3131
public static Deck Load(string name)
3232
{
3333
StreamReader reader = null;
34+
Deck deck = new Deck();
3435
try
3536
{
3637
reader = new StreamReader(new FileStream(Path.IsPathRooted(name) ? name : Path.Combine(Program.AssetPath, "Decks/", name + ".ydk"), FileMode.Open, FileAccess.Read));
3738

38-
Deck deck = new Deck();
3939
bool main = true;
4040
bool side = false;
4141

@@ -64,14 +64,13 @@ public static Deck Load(string name)
6464
}
6565

6666
reader.Close();
67-
68-
return deck;
6967
}
7068
catch (Exception)
7169
{
70+
Logger.WriteLine("Failed to load deck: " + name + ".");
7271
reader?.Close();
73-
return null;
7472
}
73+
return deck;
7574
}
7675
}
7776
}

0 commit comments

Comments
 (0)