forked from tesla1889tv/ControlValleyMod
-
Notifications
You must be signed in to change notification settings - Fork 0
/
WeaponClass.cs
217 lines (198 loc) · 7.76 KB
/
WeaponClass.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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
/*
* ControlValley
* Stardew Valley Support for Twitch Crowd Control
* Copyright (C) 2021 TerribleTable
* LGPL v2.1
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/
using System;
using System.Collections.Generic;
using StardewValley;
using StardewValley.Tools;
namespace ControlValley
{
public class WeaponClass : List<IWeaponTier>
{
public static readonly WeaponClass Club = new WeaponClass()
{
new SingleWeaponTier("Wood Club", new MeleeWeapon(24)),
new SingleWeaponTier("Wood Mallet", new MeleeWeapon(27)),
new SingleWeaponTier("Lead Rod", new MeleeWeapon(26)),
new SingleWeaponTier("Kudgel", new MeleeWeapon(46)),
new SingleWeaponTier("The Slammer", new MeleeWeapon(28)),
new SingleWeaponTier("Galaxy Hammer", new MeleeWeapon(29)),
new SingleWeaponTier("Dwarf Hammer", new MeleeWeapon(55)),
new SingleWeaponTier("Dragontooth Club", new MeleeWeapon(58)),
new SingleWeaponTier("Infinity Gavel", new MeleeWeapon(63))
};
public static readonly WeaponClass Dagger = new WeaponClass()
{
new MultiWeaponTier()
{
new KeyValuePair<string, Tool>("Carving Knife", new MeleeWeapon(16)),
new KeyValuePair<string, Tool>("Iron Dirk", new MeleeWeapon(17)),
new KeyValuePair<string, Tool>("Wind Spire", new MeleeWeapon(22))
},
new SingleWeaponTier("Elf Blade", new MeleeWeapon(20)),
new MultiWeaponTier()
{
new KeyValuePair<string, Tool>("Burglar's Shank", new MeleeWeapon(18)),
new KeyValuePair<string, Tool>("Crystal Dagger", new MeleeWeapon(21)),
new KeyValuePair<string, Tool>("Wooden Blade", new MeleeWeapon(19))
},
new SingleWeaponTier("Broken Trident", new MeleeWeapon(51)),
new MultiWeaponTier()
{
new KeyValuePair<string, Tool>("Wicked Kris", new MeleeWeapon(45)),
new KeyValuePair<string, Tool>("Galaxy Dagger", new MeleeWeapon(23))
},
new SingleWeaponTier("Dwarf Dagger", new MeleeWeapon(56)),
new MultiWeaponTier()
{
new KeyValuePair<string, Tool>("Dragontooth Shiv", new MeleeWeapon(59)),
new KeyValuePair<string, Tool>("Iridium Needle", new MeleeWeapon(61))
},
new SingleWeaponTier("Infinity Dagger", new MeleeWeapon(64))
};
public static readonly WeaponClass Sword = new WeaponClass()
{
new MultiWeaponTier()
{
new KeyValuePair<string, Tool>("Rusty Sword", new MeleeWeapon(0)),
new KeyValuePair<string, Tool>("Steel Smallsword", new MeleeWeapon(11)),
new KeyValuePair<string, Tool>("Wooden Blade", new MeleeWeapon(12))
},
new MultiWeaponTier()
{
new KeyValuePair<string, Tool>("Pirate's Sword", new MeleeWeapon(43)),
new KeyValuePair<string, Tool>("Silver Saber", new MeleeWeapon(1))
},
new MultiWeaponTier()
{
new KeyValuePair<string, Tool>("Cutlass", new MeleeWeapon(44)),
new KeyValuePair<string, Tool>("Forest Sword", new MeleeWeapon(15)),
new KeyValuePair<string, Tool>("Iron Edge", new MeleeWeapon(6))
},
new SingleWeaponTier("Insect Head", new MeleeWeapon(13)),
new MultiWeaponTier()
{
new KeyValuePair<string, Tool>("Bone Sword", new MeleeWeapon(5)),
new KeyValuePair<string, Tool>("Claymore", new MeleeWeapon(10)),
new KeyValuePair<string, Tool>("Neptune's Glaive", new MeleeWeapon(14)),
new KeyValuePair<string, Tool>("Templar's Blade", new MeleeWeapon(7))
},
new MultiWeaponTier()
{
new KeyValuePair<string, Tool>("Obsidian Edge", new MeleeWeapon(8)),
new KeyValuePair<string, Tool>("Ossified Blade", new MeleeWeapon(60))
},
new MultiWeaponTier()
{
new KeyValuePair<string, Tool>("Tempered Broadsword", new MeleeWeapon(52)),
new KeyValuePair<string, Tool>("Yeti Tooth", new MeleeWeapon(48))
},
new SingleWeaponTier("Steel Falchion", new MeleeWeapon(50)),
new SingleWeaponTier("Dark Sword", new MeleeWeapon(2)),
new SingleWeaponTier("Lava Katana", new MeleeWeapon(9)),
new MultiWeaponTier()
{
new KeyValuePair<string, Tool>("Dragontooth Cutlass", new MeleeWeapon(57)),
new KeyValuePair<string, Tool>("Dwarf Sword", new MeleeWeapon(54)),
new KeyValuePair<string, Tool>("Galaxy Sword", new MeleeWeapon(4))
},
new SingleWeaponTier("Infinity Blade", new MeleeWeapon(62))
};
public bool DoDowngrade()
{
for (int i = this.Count - 1; i > 0; --i)
{
if (this[i].RemoveWeapon())
{
this[i - 1].AddWeapon();
return true;
}
}
return false;
}
public bool DoUpgrade()
{
for (int i = 0; i < this.Count - 1; ++i)
{
if (this[i].RemoveWeapon())
{
this[i + 1].AddWeapon();
return true;
}
}
return false;
}
}
public interface IWeaponTier
{
void AddWeapon();
bool RemoveWeapon();
}
class MultiWeaponTier : List<KeyValuePair<string, Tool>>, IWeaponTier
{
private Random Random { get; set; }
public MultiWeaponTier() : base()
{
Random = new Random();
}
public void AddWeapon()
{
Game1.player.addItemByMenuIfNecessary(this[Random.Next(Count)].Value);
}
public bool RemoveWeapon()
{
foreach (KeyValuePair<string, Tool> weapon in this)
{
Tool tool = Game1.player.getToolFromName(weapon.Key);
if (tool != null)
{
Game1.player.removeItemFromInventory(tool);
return true;
}
}
return false;
}
}
class SingleWeaponTier : IWeaponTier
{
private readonly string name;
private readonly Tool tool;
public SingleWeaponTier(string name, Tool tool)
{
this.name = name;
this.tool = tool;
}
public void AddWeapon()
{
Game1.player.addItemByMenuIfNecessary(tool);
}
public bool RemoveWeapon()
{
Tool tool = Game1.player.getToolFromName(name);
if (tool != null)
{
Game1.player.removeItemFromInventory(tool);
return true;
}
return false;
}
}
}