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
| using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Collections; using System.Net; using System.IO; using System.Text.RegularExpressions;
namespace HofHpViewer { class Program { private static ArrayList monsterList = new ArrayList() { new Monster("暗黑龍", "0000"), new Monster("牛頭怪", "0001"), new Monster("假英雄", "0002"), new Monster("土匪頭", "0003"), new Monster("早餐時間", "0004"), new Monster("午餐時間", "0005"), new Monster("晚餐時間", "0006"), new Monster("猴王", "0007"), new Monster("雷鳥王", "0008"), new Monster("徘徊幽靈", "0009"), new Monster("人魚將軍", "0010"), new Monster("食人魔埃德加", "0011"), new Monster("不吉鳥軍團", "0050"), new Monster("一日三餐", "0051"), new Monster("白龍王", "0052"), new Monster("海盜寶船", "2012"), new Monster("幽靈海盜船", "2013") };
static void Main(string[] args) { print("-H-O-F-HP-V-i-e-w-e-r-"); print("----------------------"); print("Author : Zeuxis Lo"); print("Version: 0.1.0 Beta"); print("----------------------\n");
Console.Title = "Hof Hp Viewer";
while (true) { print("Command List:\n"); print("e: exit program"); print("l: show monster list");
Console.Write("\nPlease enter your command: ");
String input = Console.ReadLine();
if (input.Equals("exit") || input.Equals("e")) { break; }else if (input.Equals("list") || input.Equals("l")) { while (true) { print("Monster List:\n"); printMonsterList();
Console.Write("\nPlease enter monster number to show hp (enter e to exit): ");
String input2 = Console.ReadLine();
if (input2.Equals("e") || input2.Equals("exit")) { break; }else{ try { int inputNumber = int.Parse(input2);
if (inputNumber >= 1 && inputNumber < monsterList.Count) { Monster monster = (Monster)monsterList[inputNumber - 1]; MonsterInfo monsterInfo = new MonsterInfo(monster.getFileId());
print(""); print("Your input is: " + input2); print("Monster Name : " + monster.getName()); print("Monster File : " + monster.getFileId()); print("Monster HP is : " + String.Format("{0:0,0}", int.Parse(monsterInfo.getHp()))); print("Monster SP is : " + String.Format("{0:0,0}", int.Parse(monsterInfo.getSp()))); print(""); } else { print("Can not found monster !!!!!"); } } catch (Exception e) { print("Enter error, Please enter monster number !!!!!"); } } } } }
pause(); }
private static void printMonsterList() { for (int i = 0; i < monsterList.Count; i++) { print((i+1) + " - " + ((Monster)monsterList[i]).getName()); } }
public static void pause() { Console.Write("\nPress any key to continue . . . "); Console.ReadKey(true); }
private static void print(string msg) { Console.WriteLine(msg); } }
class Monster { private string name; private string fileId;
public Monster(string name, string fileId) { this.name = name; this.fileId = fileId; }
public string getName() { return this.name; }
public string getFileId() { return this.fileId; } }
class MonsterInfo { private string number; private string lastDefeated; private string hp; private string sp;
public MonsterInfo(string fileId) { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(getMonsterFullUrl(fileId)); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); StreamReader sr = new StreamReader(response.GetResponseStream()); String html = sr.ReadToEnd();
html = Regex.Replace(html, @"[\r\n\t]", "", RegexOptions.Multiline | RegexOptions.IgnoreCase); this.number = Regex.Replace(html, @"(.*)MonsterNumber=([0-9]+)(.*)", "$2", RegexOptions.IgnoreCase | RegexOptions.Multiline); this.lastDefeated = Regex.Replace(html, @"(.*)LastDefeated=([0-9]+)(.*)", "$2", RegexOptions.IgnoreCase | RegexOptions.Multiline); this.hp = Regex.Replace(html, @"(.*)HP=([0-9]+)(.*)", "$2", RegexOptions.IgnoreCase | RegexOptions.Multiline); this.sp = Regex.Replace(html, @"(.*)SP=([0-9]+)(.*)", "$2", RegexOptions.IgnoreCase | RegexOptions.Multiline); }
private string getMonsterFullUrl(string fileId) { return "http://your_hof_url/union/" + fileId + "_Union.dat"; }
public string getNumber() { return this.number; }
public string getLastDefeated() { return this.lastDefeated; }
public string getHp() { return this.hp; }
public string getSp() { return this.sp; } } }
|