-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
pixeltris
committed
May 14, 2018
1 parent
73db6c1
commit b36a5e1
Showing
4 changed files
with
1,935 additions
and
0 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
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,59 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace Lotd.FileFormats | ||
{ | ||
/// <summary> | ||
/// Holds limited / banned card information (pd_limits.bin) | ||
/// </summary> | ||
public class CardLimits : FileData | ||
{ | ||
public HashSet<short> Forbidden { get; private set; } | ||
public HashSet<short> Limited { get; private set; } | ||
public HashSet<short> SemiLimited { get; private set; } | ||
|
||
public CardLimits() | ||
{ | ||
Forbidden = new HashSet<short>(); | ||
Limited = new HashSet<short>(); | ||
SemiLimited = new HashSet<short>(); | ||
} | ||
|
||
public override void Load(BinaryReader reader, long length) | ||
{ | ||
ReadCardIds(reader, Forbidden); | ||
ReadCardIds(reader, Limited); | ||
ReadCardIds(reader, SemiLimited); | ||
} | ||
|
||
public override void Save(BinaryWriter writer) | ||
{ | ||
WriteCardIds(writer, Forbidden); | ||
WriteCardIds(writer, Limited); | ||
WriteCardIds(writer, SemiLimited); | ||
} | ||
|
||
private void ReadCardIds(BinaryReader reader, HashSet<short> cardIds) | ||
{ | ||
cardIds.Clear(); | ||
|
||
short count = reader.ReadInt16(); | ||
for (int i = 0; i < count; i++) | ||
{ | ||
cardIds.Add(reader.ReadInt16()); | ||
} | ||
} | ||
|
||
private void WriteCardIds(BinaryWriter writer, HashSet<short> cardIds) | ||
{ | ||
writer.Write((short)cardIds.Count); | ||
foreach (ushort cardId in cardIds) | ||
{ | ||
writer.Write(cardId); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.