forked from YuriDLL/stacklands-data-loader
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCardDataLookup.cs
More file actions
41 lines (37 loc) · 1.21 KB
/
CardDataLookup.cs
File metadata and controls
41 lines (37 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
namespace DataLoaderPlugin
{
public class CardDataLookup
{
private Dictionary<string, CardData> CardData;
/// <summary>
/// Attempts to get the name of the card given a card id.
/// If the cardId cannot be found, returns the cardId.
/// </summary>
/// <param name="cardId"></param>
/// <returns></returns>
public string GetCardName(string cardId)
{
return CardData.TryGetValue(cardId, out var cardData) ? cardData.Name : cardId;
}
/// <summary>
/// Gets the Card data for the card's ID.
/// Returns null if not found.
/// </summary>
/// <param name="cardId"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public CardData GetCardData(string cardId)
{
return CardData.TryGetValue(cardId, out CardData cardData) ? cardData : null;
}
public CardDataLookup(WorldManager worldManager)
{
CardData = worldManager.CardDataPrefabs
.ToDictionary(x => x.Id);
}
}
}