-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPCGWGame.cs
120 lines (106 loc) · 3.48 KB
/
PCGWGame.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
using System;
using Playnite.SDK;
using Playnite.SDK.Models;
using Newtonsoft.Json.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using Microsoft.VisualBasic.FileIO;
using System.IO;
namespace PCGamingWikiMetadata
{
public class PCGWGame : GenericItemOption
{
private readonly ILogger logger = LogManager.GetLogger();
public int PageID { get; set; }
private List<string> genres;
public List<string> Genres { get { return genres; } }
private List<string> developers;
public List<string> Developers { get { return developers; } }
private List<string> publishers;
public List<string> Publishers { get { return publishers; } }
private List<string> features;
public List<string> Features { get { return features; } }
private List<Link> links;
public List<Link> Links { get { return links; } }
private IDictionary<string, DateTime?> ReleaseDates;
public string Series;
public PCGWGame()
{
this.links = new List<Link>();
this.genres = new List<string>();
this.features = new List<string>();
this.developers = new List<string>();
this.publishers = new List<string>();
this.ReleaseDates = new Dictionary<string, DateTime?>();
}
public PCGWGame(string name, int pageid) : this()
{
this.Name = name;
this.PageID = pageid;
AddPCGamingWikiLink();
}
protected Link PCGamingWikiLink()
{
string escapedName = Uri.EscapeUriString(this.Name);
return new Link("PCGamingWiki", $"https://www.pcgamingwiki.com/wiki/{escapedName}");
}
public void AddPCGamingWikiLink()
{
this.links.Add(PCGamingWikiLink());
}
public void AddTaxonomy(string type, string value)
{
switch (type)
{
case "Microtransactions":
break;
case "Modes":
this.features.Add(value);
break;
case "Pacing":
break;
case "Perspectives":
break;
case "Controls":
break;
case "Genres":
this.genres.AddRange(SplitCSVString(value));
break;
case "Vehicles":
break;
case "Art styles":
break;
case "Themes":
break;
case "Series":
this.Series = value;
break;
default:
logger.Debug($"Unknown taxonomy {type}");
break;
}
}
public DateTime? WindowsReleaseDate()
{
DateTime? date;
if (this.ReleaseDates.TryGetValue("Windows", out date))
{
return date;
}
else
{
return null;
}
}
public void AddReleaseDate(string platform, DateTime? date)
{
this.ReleaseDates[platform] = date;
}
public string[] SplitCSVString(string csv)
{
TextFieldParser parser = new TextFieldParser(new StringReader(csv));
parser.SetDelimiters(",");
return parser.ReadFields();
}
}
}