-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGalaxy.cs
76 lines (68 loc) · 2.14 KB
/
Galaxy.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
68
69
70
71
72
73
74
75
76
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace HazeronProspector
{
public class Galaxy
{
protected Dictionary<string, Sector> _sectors = new Dictionary<string, Sector>();
public Dictionary<string, Sector> Sectors
{
get { return _sectors; }
}
protected string _name;
public string Name
{
get { return _name; }
}
public bool ContainSurvey
{
get { return _sectors.Values.Any(x => x.ContainSurvey); }
}
public Galaxy(string name)
{
_name = name;
}
public void AddSector(Sector sector)
{
_sectors.Add(sector.ID, sector);
sector.HostGalaxy = this;
}
public Dictionary<ResourceType, Resource> BestResources()
{
List<Dictionary<ResourceType, Resource>> resourceLists = new List<Dictionary<ResourceType, Resource>>();
foreach (Sector sector in _sectors.Values)
{
foreach (HSystem system in sector.Systems.Values)
{
foreach (CelestialBody body in system.CelestialBodies.Values)
{
foreach (Zone zone in body.ResourceZones)
{
resourceLists.Add(body.BestResources());
}
}
}
}
return resourceLists.SelectMany(dict => dict)
.ToLookup(pair => pair.Key, pair => pair.Value)
.ToDictionary(k => k.Key, v => v.Aggregate((i, j) => i.Quality > j.Quality ? i : j));
}
public override string ToString()
{
return _name;
}
//public override bool Equals(object obj)
//{
// Galaxy galaxy = obj as Galaxy;
// if (galaxy == null)
// return false;
// return Equals(galaxy);
//}
//public bool Equals(Galaxy galaxy)
//{
// return _name == galaxy.Name;
//}
}
}