forked from bitstobrowser/YahooNhlDownload
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Player.cs
96 lines (88 loc) · 3.3 KB
/
Player.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
using System;
using System.Collections.Generic;
public class Player
{
public Player() { }
public Player(string name, string nhlTeam, string positions)
{
this.Name = name ?? throw new ArgumentNullException(nameof(name));
this.TeamNHL = nhlTeam ?? throw new ArgumentNullException(nameof(nhlTeam));
this.Positions = positions ?? throw new ArgumentNullException(nameof(positions));
}
public const string KEY_OWNER = "Owner";
public const string KEY_GAMES_PLAYED = "GP*"; // The astrisk denotes a non-scoring stat.
public const string KEY_FANTASY_POINTS = "Fan Pts";
public const string KEY_PRESEASON_RANK = "Pre-Season";
public const string KEY_CURRENT_RANK = "Current";
public const string KEY_OWNED_PERCENTAGE = "% Owned";
public string Name { get; set; }
public string TeamNHL { get; set; }
public string TeamFantasy { get; set; }
public string Positions { get; set; }
// General Stats
public int StatGamesPlayed { get; set; }
public float StatFantasyPoints { get; set; }
public float StatOwnedPercentage { get; set; }
public int StatPreSeasonRank { get; set; }
public int StatCurrentRank { get; set; }
public string StatTimeOnIce { get; set; }
// Draft/Keeper Info
public int RoundDrafted { get; set; } = int.MaxValue;
public string DraftedBy { get; set; }
public bool IsKeeper { get; set; }
public bool WasDropped { get; set; } // Used to determing if the "Keep Cost" of a drafted player should be minimized.
public int PickLostIfKept { get; set; } = -1;
public void SetStatByHeader(string header, string value)
{
value = value == "-" ? "0" : value;
switch (header)
{
case KEY_OWNER:
TeamFantasy = value; // Originally used ".//div//a", revert back if problem occurs.
break;
case KEY_GAMES_PLAYED:
StatGamesPlayed = int.Parse(value);
break;
case KEY_FANTASY_POINTS:
StatFantasyPoints = float.Parse(value);
break;
case KEY_PRESEASON_RANK:
StatPreSeasonRank = int.Parse(value);
break;
case KEY_CURRENT_RANK:
StatCurrentRank = int.Parse(value);
break;
case KEY_OWNED_PERCENTAGE:
if (value.Equals("-"))
{
StatOwnedPercentage = 0f;
}
else
{
StatOwnedPercentage = float.Parse(value.Replace("%", "")) * 0.01f;
}
break;
}
}
public object GetStatByHeader(string header)
{
switch (header)
{
case KEY_OWNER:
return TeamFantasy;
case KEY_GAMES_PLAYED:
return StatGamesPlayed;
case KEY_FANTASY_POINTS:
return StatFantasyPoints;
case KEY_PRESEASON_RANK:
return StatPreSeasonRank;
case KEY_CURRENT_RANK:
return StatCurrentRank;
case KEY_OWNED_PERCENTAGE:
return KEY_OWNED_PERCENTAGE;
default:
//throw new ArgumentException("Header does not exist.", "header");
return null;
}
}
}