/
GamesInProgress.cs
67 lines (56 loc) · 1.46 KB
/
GamesInProgress.cs
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using System.Collections.Generic;
using sharpdungeon.actors.hero;
namespace sharpdungeon
{
public class GamesInProgress
{
private static readonly Dictionary<HeroClass, Info> State = new Dictionary<HeroClass, Info>();
public static Info Check(HeroClass cl)
{
if (State.ContainsKey(cl))
return State[cl];
Info info;
try
{
var bundle = Dungeon.GameBundle(Dungeon.GameFile(cl));
info = new Info();
Dungeon.Preview(info, bundle);
}
catch
{
info = null;
}
State.Add(cl, info);
return info;
}
public static void Set(HeroClass cl, int depth, int level)
{
var info = new Info();
info.Depth = depth;
info.Level = level;
if (State.ContainsKey(cl))
State[cl] = info;
else
State.Add(cl, info);
}
public static HeroClass Unknown
{
set
{
State.Remove(value);
}
}
public static void Delete(HeroClass cl)
{
if (State.ContainsKey(cl))
State[cl] = null;
else
State.Add(cl, null);
}
public class Info
{
public int Depth;
public int Level;
}
}
}