Develop and Download Open Source Software

Browse Subversion Repository

Contents of /SchoolIdolFestivalSimulator.Components/SearchedMember.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 48 - (show annotations) (download)
Thu Jul 17 15:30:23 2014 UTC (9 years, 9 months ago) by kayochin_3141
File size: 12057 byte(s)
部員入力画面不具合修正
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.Net;
6 using System.Reflection;
7 using System.IO;
8 namespace SchoolIdolFestivalSimulator.Components {
9 public class EDownloadFailedException : Exception {
10 public EDownloadFailedException() : base() {
11 }
12 public EDownloadFailedException(string message):base() {
13 }
14 }
15 public enum ShowSearchedMemberType {
16 Lv1,
17 Max,
18 AwakenMax
19 }
20
21 public class SearchedMember {
22 public enum HtmlCol : int {
23 CardId = 0,
24 Name = 1,
25 Rarity = 2,
26 StatusType = 3,
27 Lv1Stamina = 4,
28 BondsMax = 5,
29 BondsAwakenMax = 6,
30 Lv1Smile = 7,
31 Lv1Pure = 8,
32 Lv1Cool = 9,
33 MaxStamina = 10,
34 MaxSmile = 11,
35 MaxPure = 12,
36 MaxCool = 13,
37 AwakenMaxStamina = 14,
38 AwakenMaxSmile = 15,
39 AwakenMaxPure = 16,
40 AwakenMaxCool = 17,
41 SkillName = 18,
42 RaiseType = 19,
43 RaiseCount = 20,
44 Ratio = 21,
45 UpType = 22,
46 UpValule = 23,
47 CenterSourceType = 24,
48 CenterUpType = 25,
49 CenterUpRatio = 26
50 }
51
52 private int _cardId;
53 private string _name;
54 private Rarity _rarity;
55 private StatusType _statusType;
56 private int _lv1Stamina;
57 private int _bondsMax;
58 private int _bondsAwakenMax;
59 private StatusValue _lv1StatusValue = new StatusValue();
60 private int _maxStamina;
61 private StatusValue _maxStatusValue = new StatusValue();
62 private int _awakenMaxStamina;
63 private StatusValue _awakenMaxStatusValue = new StatusValue();
64 private Skill _skill = new Skill();
65 private CenterSkill _centerSkill = new CenterSkill();
66 public int CardId {
67 get {
68 return _cardId;
69 }
70 }
71 public int GetStamina(ShowSearchedMemberType type) {
72 switch (type) {
73 case ShowSearchedMemberType.Lv1:
74 return _lv1Stamina;
75 case ShowSearchedMemberType.Max:
76 return _maxStamina;
77 case ShowSearchedMemberType.AwakenMax:
78 return _awakenMaxStamina;
79 default:
80 return _lv1Stamina;
81 }
82 }
83 public int GetBonds(ShowSearchedMemberType type) {
84 switch (type) {
85 case ShowSearchedMemberType.Lv1:
86 return _bondsMax;
87 case ShowSearchedMemberType.Max:
88 return _bondsMax;
89 case ShowSearchedMemberType.AwakenMax:
90 return _bondsAwakenMax;
91 default:
92 return 0;
93 }
94 }
95 public StatusValue GetStatusValue(ShowSearchedMemberType type) {
96 switch (type) {
97 case ShowSearchedMemberType.Lv1:
98 return _lv1StatusValue;
99 case ShowSearchedMemberType.Max:
100 return _maxStatusValue;
101 case ShowSearchedMemberType.AwakenMax:
102 return _awakenMaxStatusValue;
103 default:
104 return _lv1StatusValue;
105 }
106 }
107 public int BondsMax {
108 get {
109 return _bondsMax;
110 }
111 }
112 public Skill Skill {
113 get {
114 return _skill;
115 }
116 }
117 public CenterSkill CenterSkill {
118 get {
119 return _centerSkill;
120 }
121 }
122 public StatusValue AwakenMaxStatusValue {
123 get {
124 return _awakenMaxStatusValue;
125 }
126 }
127 public int AwakenMaxStamina {
128 get {
129 return _awakenMaxStamina;
130 }
131 }
132 public StatusValue MaxStatusValue {
133 get {
134 return _maxStatusValue;
135 }
136 }
137 public int MaxStamina {
138 get {
139 return _maxStamina;
140 }
141 }
142 public StatusValue Lv1StatusValue {
143 get {
144 return _lv1StatusValue;
145 }
146 }
147 public int Bonds(ShowSearchedMemberType type) {
148 if (type == ShowSearchedMemberType.Lv1) {
149 return 0;
150 } else if (type == ShowSearchedMemberType.Max) {
151 return _bondsMax;
152 } else if (type == ShowSearchedMemberType.AwakenMax) {
153 return _bondsAwakenMax;
154 } else {
155 return 0;
156 }
157 }
158 public int BondsAwakenMax {
159 get {
160 return _bondsMax;
161 }
162 }
163 public Rarity GetRarity(ShowSearchedMemberType type) {
164 if (_rarity == Components.Rarity.N || _rarity == Components.Rarity.AwakenN) {
165 if (type == ShowSearchedMemberType.AwakenMax) {
166 return Components.Rarity.AwakenN;
167 } else {
168 return Components.Rarity.N;
169 }
170 } else if (_rarity == Components.Rarity.R || _rarity == Components.Rarity.AwakenR) {
171 if (type == ShowSearchedMemberType.AwakenMax) {
172 return Components.Rarity.AwakenR;
173 } else {
174 return Components.Rarity.R;
175 }
176 } else if (_rarity == Components.Rarity.SR || _rarity == Components.Rarity.AwakenSR) {
177 if (type == ShowSearchedMemberType.AwakenMax) {
178 return Components.Rarity.AwakenSR;
179 } else {
180 return Components.Rarity.SR;
181 }
182 } else if (_rarity == Components.Rarity.UR || _rarity == Components.Rarity.AwakenUR) {
183 if (type == ShowSearchedMemberType.AwakenMax) {
184 return Components.Rarity.AwakenUR;
185 } else {
186 return Components.Rarity.UR;
187 }
188 }
189 return _rarity;
190 }
191 public Rarity Rarity {
192 get {
193 return _rarity;
194 }
195 }
196 public StatusType StatusType {
197 get {
198 return _statusType;
199 }
200 }
201 public int Stamina(ShowSearchedMemberType type) {
202 if (type == ShowSearchedMemberType.Lv1) {
203 return _lv1Stamina;
204 } else if (type == ShowSearchedMemberType.Max) {
205 return _maxStamina;
206 } else if (type == ShowSearchedMemberType.AwakenMax) {
207 return _awakenMaxStamina;
208 } else {
209 return 0;
210 }
211 }
212 public int Lv1Stamina {
213 get {
214 return _lv1Stamina;
215 }
216 }
217 public string Name {
218 get {
219 return _name;
220 }
221 }
222 public SearchedMember(int cardId){
223 _cardId = cardId;
224 Download();
225 Initialize();
226 }
227 public bool NotAwakenExists {
228 get {
229 return _maxStamina > 0;
230 }
231 }
232 public decimal SmileValue(ShowSearchedMemberType type) {
233 if (type == ShowSearchedMemberType.Lv1) {
234 return _lv1StatusValue.Smile;
235 } else if (type == ShowSearchedMemberType.Max) {
236 return _maxStatusValue.Smile;
237 } else if (type == ShowSearchedMemberType.AwakenMax) {
238 return _awakenMaxStatusValue.Smile;
239 } else {
240 return 0;
241 }
242 }
243 public decimal PureValue(ShowSearchedMemberType type) {
244 if (type == ShowSearchedMemberType.Lv1) {
245 return _lv1StatusValue.Pure;
246 } else if (type == ShowSearchedMemberType.Max) {
247 return _maxStatusValue.Pure;
248 } else if (type == ShowSearchedMemberType.AwakenMax) {
249 return _awakenMaxStatusValue.Pure;
250 } else {
251 return 0;
252 }
253 }
254 public decimal CoolValue(ShowSearchedMemberType type) {
255 if (type == ShowSearchedMemberType.Lv1) {
256 return _lv1StatusValue.Cool;
257 } else if (type == ShowSearchedMemberType.Max) {
258 return _maxStatusValue.Cool;
259 } else if (type == ShowSearchedMemberType.AwakenMax) {
260 return _awakenMaxStatusValue.Cool;
261 } else {
262 return 0;
263 }
264 }
265 private void Initialize() {
266 //Console.WriteLine(File.ReadAllText(this.HtmlPath));
267 string[] s = File.ReadAllText(this.HtmlPath).Split('\t');
268 if (s.Length <= 26) {
269 return;
270 }
271 _cardId = Convert.ToInt32(s[(int)HtmlCol.CardId]);
272 _name = s[(int)HtmlCol.Name];
273 _rarity = ConvUtil.GetRarityFromChar(s[(int)HtmlCol.Rarity]);
274 _statusType = ConvUtil.GetStatusTypeFromText(s[(int)HtmlCol.StatusType]);
275 _lv1Stamina = Convert.ToInt32(s[(int)HtmlCol.Lv1Stamina]);
276 _bondsMax = Convert.ToInt32(s[(int)HtmlCol.BondsMax]);
277 _bondsAwakenMax = Convert.ToInt32(s[(int)HtmlCol.BondsAwakenMax]);
278 _lv1StatusValue.Smile = Convert.ToInt32(s[(int)HtmlCol.Lv1Smile]);
279 _lv1StatusValue.Pure = Convert.ToInt32(s[(int)HtmlCol.Lv1Pure]);
280 _lv1StatusValue.Cool = Convert.ToInt32(s[(int)HtmlCol.Lv1Cool]);
281 _maxStamina = Convert.ToInt32(s[(int)HtmlCol.MaxStamina]);
282 _maxStatusValue.Smile = Convert.ToInt32(s[(int)HtmlCol.MaxSmile]);
283 _maxStatusValue.Pure = Convert.ToInt32(s[(int)HtmlCol.MaxPure]);
284 _maxStatusValue.Cool = Convert.ToInt32(s[(int)HtmlCol.MaxCool]);
285 _awakenMaxStamina = Convert.ToInt32(s[(int)HtmlCol.AwakenMaxStamina]);
286 _awakenMaxStatusValue.Smile = Convert.ToInt32(s[(int)HtmlCol.AwakenMaxSmile]);
287 _awakenMaxStatusValue.Pure = Convert.ToInt32(s[(int)HtmlCol.AwakenMaxPure]);
288 _awakenMaxStatusValue.Cool = Convert.ToInt32(s[(int)HtmlCol.AwakenMaxCool]);
289 _skill.Name = s[(int)HtmlCol.SkillName];
290 _skill.RaiseType = ConvUtil.GetRaiseTypeFromText(s[(int)HtmlCol.RaiseType]);
291 _skill.RaiseCount = Convert.ToDecimal(s[(int)HtmlCol.RaiseCount]);
292 _skill.Ratio = Convert.ToDecimal(s[(int)HtmlCol.Ratio]);
293 _skill.UpType = ConvUtil.GetSkillUpTypeFromText(s[(int)HtmlCol.UpType]);
294 _skill.UpValue = Convert.ToDecimal(s[(int)HtmlCol.UpValule]);
295 _centerSkill.SourceType = ConvUtil.GetStatusTypeFromText(s[(int)HtmlCol.CenterSourceType]);
296 _centerSkill.UpType = ConvUtil.GetStatusTypeFromText(s[(int)HtmlCol.CenterUpType]);
297 _centerSkill.UpRatio = Convert.ToDecimal(s[(int)HtmlCol.CenterUpRatio]);
298 }
299 private string GetDirectory() {
300 return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
301 }
302 private string HtmlPath{
303 get{
304 return Path.Combine(GetDirectory(),"member.html");
305 }
306 }
307 private void Download() {
308 WebClient wc = new WebClient();
309 try {
310 wc.DownloadFile(Consts.SearchMemberUrl + _cardId.ToString(), this.HtmlPath);
311 } catch {
312 throw new EDownloadFailedException("ダウンロードに失敗しました");
313 }
314 }
315 }
316 }

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26