-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPizza.cs
115 lines (101 loc) Β· 3.56 KB
/
Pizza.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
using System.Collections.Generic;
using System.Linq;
namespace DominosDiscord
{
/// <summary>
/// pizza pizza
/// </summary>
public class Pizza
{
public Pizza(string size, string type, bool isDoneBeingBuilt)
{
this.Size = size;
this.Type = type;
this.isDoneBeingBuilt = isDoneBeingBuilt;
}
public string Size { get; set; }
public string Type { get; set; }
/// <summary>
/// The toppings this pizza has
/// </summary>
public Dictionary<string, Dictionary<Dominos_API.DataEntities.PizzaSide, Dominos_API.DataEntities.Amount>> Toppings { get; set; }
/// <summary>
/// Did the user finish configuring the pizza?
/// </summary>
public bool isDoneBeingBuilt { get; set; }
public Pizza()
{
// Add sauce and cheese as default
Toppings = new Dictionary<string, Dictionary<Dominos_API.DataEntities.PizzaSide, Dominos_API.DataEntities.Amount>>();
Toppings.Add("C",
new Dictionary<Dominos_API.DataEntities.PizzaSide, Dominos_API.DataEntities.Amount>() {
{ Dominos_API.DataEntities.PizzaSide.Both, Dominos_API.DataEntities.Amount.Normal }
});
Toppings.Add("X",
new Dictionary<Dominos_API.DataEntities.PizzaSide, Dominos_API.DataEntities.Amount>() {
{ Dominos_API.DataEntities.PizzaSide.Both, Dominos_API.DataEntities.Amount.Normal }
});
}
/// <summary>
/// Convert the pizza type into a code for the API
/// </summary>
public string GetCode()
{
// Brooklyn Style and Medium Pan Pizza
if (Type == "PBKIREZA" || Type == "P12IPAZA")
return Type;
// Everything else
return $"{Size}{Type}";
}
/// <summary>
/// Add a topping to this pizza
/// </summary>
public void AddTopping(string code)
{
Toppings.Add(code,
new Dictionary<Dominos_API.DataEntities.PizzaSide, Dominos_API.DataEntities.Amount>() {
{ Dominos_API.DataEntities.PizzaSide.Both, Dominos_API.DataEntities.Amount.Normal }
});
}
/// <summary>
/// Convert this pizza object into a description
/// </summary>
public override string ToString() => $"1 {SizeToName()} {TypeToName()} - {string.Join(", ", Toppings.Select(x => DominosDiscord.Toppings.List[x.Key]).ToArray())}";
/// <summary>
/// Convert the pizza type into a name for the user
/// </summary>
private string SizeToName()
{
switch (Size)
{
case "10":
return "Small";
case "12":
return "Medium";
case "14":
return "Large";
default:
return "";
}
}
/// <summary>
/// Convert the pizza code type into a name for the user
/// </summary>
private string TypeToName()
{
switch (Type)
{
case "SCREEN":
return "Handtossed";
case "P12IPAZA":
return "Handmade Pan";
case "THIN":
return "Thincrust";
case "PBKIREZA":
return "Brooklyn Style";
default:
return "";
}
}
}
}