• R/O
  • SSH
  • HTTPS

ogsnet: Commit


Commit MetaInfo

Revision51 (tree)
Time2010-10-19 21:55:19
Authorpine613

Log Message

GameOn のゲームプラグインの汎用クラスを追加
AVA を汎用クラスで再定義
Soul of the Ultimate Nation のクラスを追加

Change Summary

Incremental Difference

--- trunk/Solution/GameOn/Game.cs (revision 50)
+++ trunk/Solution/GameOn/Game.cs (revision 51)
@@ -10,46 +10,33 @@
1010 {
1111 using OGSNET.Plugin;
1212
13- /** \brief AVAの起動プラグイン */
14- [Export(typeof(IPlugin))]
15- [Export(typeof(IGamePlugin))]
16- [ExportMetadata("PluginId", "GameOn.AVA")]
17- public class AVA : GamePluginBase
13+ /** brief GameOn の flashvars 汎用プラグイン */
14+ public class GameOnFlashvars : GamePluginBase
1815 {
19- /** \brief プラグインの情報を初期化する */
20- public AVA()
16+ /** \brief プラグインの開始処理 */
17+ protected override sealed void StartPlugin()
2118 {
22- this.PluginInfo =
23- new PluginInfo(new Version(1), "Alliance of Valiant Arms (GameOn) プラグイン ", "pine",
24- "Alliance of Valiant Arms (GameOn) を起動するプラグインです。");
25-
26- this.GameInfo =
27- new GameInfo("ゲームオン", "GameOn", "Alliance of Valiant Arms",
28- "http://ava.gamechu.jp/");
19+ // ログインする
20+ this.CallPlugin("GameOn", this.LoadGameStartPage);
2921 }
3022
31- /** \brief プラグインを開始する */
32- protected override void StartPlugin()
23+ /** \brief ゲームを開始するページを読み込む */
24+ private void LoadGameStartPage()
3325 {
34- this.CallPlugin("GameOn", this.LoadTopPage);
26+ this.Notice("ゲームを開始するページを読み込んでいます。");
27+ this.Navigate(this.GameStartUrl, this.GameStart);
3528 }
3629
37- /** \brief トップページを読み込む */
38- private void LoadTopPage()
39- {
40- this.StartCallback(CallbackStatus.Notice, "AVAのトップページを読み込んでいます。");
41- this.Navigate("http://ava.gamechu.jp/", this.GameStart);
42- }
43-
4430 /** \brief ゲームを開始する */
4531 private void GameStart()
4632 {
47- this.StartCallback(CallbackStatus.Notice, "ゲームを起動しています。");
33+ // Flash の要素を取得
34+ var flash = this.Document.GetElementById(this.FlashId);
4835
49- var flash = this.Document.GetElementById("flash_gamestart_loginSWF");
36+ // Flash の中のすべての param 要素を取得
5037 var elements = flash.GetElementsByTagName("param").Cast<HtmlElement>();
5138
52- // flashvars は複数有り
39+ // name 属性が flashvars な param 要素を LINQ で取得 (複数ある場合あり)
5340 var query =
5441 from A
5542 in elements
@@ -61,23 +48,109 @@
6148
6249 foreach (var value in query)
6350 {
64- var regex = new Regex("GAMESTART_LOGIN_URL=(.+)(?:$|&)"); // javascript:~ の形で入ってる
51+ // javascript:~ の形で入ってる
52+ var regex = new Regex(this.FlashvarsName + "=([^&]+)");
53+
54+ // マッチ処理
6555 var match = regex.Match(value);
6656
67- if (match.Success && match.Groups.Count == 2)
57+ // マッチした場合
58+ if (match.Success)
6859 {
60+ // ゲームを開始する
6961 this.Navigate(match.Groups[1].Value);
62+
63+ // 成功フラグを立てる
7064 success = true;
7165 break;
7266 }
7367 }
7468
69+ // 成功した場合
7570 if (success)
7671 {
77- this.StartCallback(CallbackStatus.Finish, "ゲームの起動に成功しました。");
78- } else {
79- this.StartCallback(CallbackStatus.Error, "ゲーム開始に必要なパラメーターが見つかりません。");
72+ this.Notice("ゲームの起動に成功しました。");
8073 }
74+ else
75+ {
76+ this.Notice("ゲーム開始に必要なパラメーターが見つかりません。");
77+ }
8178 }
79+
80+ /**
81+ * \brief Flash の object 要素の id
82+ *
83+ * ExternalInterface には必ず ID 属性が必要なため、開始する Flash の object 要素には必ず ID 属性がある
84+ */
85+ protected string FlashId
86+ {
87+ get;
88+ set;
89+ }
90+
91+ /**
92+ * \brief flashvars で探す名前
93+ *
94+ * FlashId の中の param 要素で name 属性が flashvars な要素の value 属性の中で検索する
95+ * value 属性が 名前=値&名前=値& ... となってるので、その名前を指定する
96+ */
97+ protected string FlashvarsName
98+ {
99+ get;
100+ set;
101+ }
102+
103+ private string GameStartUrl_ = null;
104+
105+ /** \brief ゲームを開始する URL */
106+ protected string GameStartUrl
107+ {
108+ get { return this.GameStartUrl_ ?? this.GameInfo.Url.AbsoluteUri; }
109+ set { this.GameStartUrl_ = value; }
110+ }
82111 }
112+
113+ /** \brief AVAの起動プラグイン */
114+ [Export(typeof(IPlugin))]
115+ [Export(typeof(IGamePlugin))]
116+ [ExportMetadata("PluginId", "GameOn.AVA")]
117+ public class AVA : GameOnFlashvars
118+ {
119+ /** \brief プラグインの情報を初期化する */
120+ public AVA()
121+ {
122+ this.PluginInfo =
123+ new PluginInfo(new Version(1), "Alliance of Valiant Arms (GameOn) プラグイン ", "pine",
124+ "Alliance of Valiant Arms (GameOn) を起動するプラグインです。");
125+
126+ this.GameInfo =
127+ new GameInfo("ゲームオン", "GameOn", "Alliance of Valiant Arms",
128+ "http://ava.gamechu.jp/");
129+
130+ this.FlashId = "flash_gamestart_loginSWF";
131+ this.FlashvarsName = "GAMESTART_LOGIN_URL";
132+ }
133+ }
134+
135+ /** \brief Soul of the Ultimate Nation の起動プラグイン */
136+ [Export(typeof(IPlugin))]
137+ [Export(typeof(IGamePlugin))]
138+ [ExportMetadata("PluginId", "GameOn.SUN")]
139+ public class SUN : GameOnFlashvars
140+ {
141+ /** \brief プラグインの情報を初期化する */
142+ public SUN()
143+ {
144+ this.PluginInfo =
145+ new PluginInfo(new Version(1), "Soul of the Ultimate Nation (GameOn) プラグイン ", "pine",
146+ "Soul of the Ultimate Nation (GameOn) を起動するプラグインです。");
147+
148+ this.GameInfo =
149+ new GameInfo("ゲームオン", "GameOn", "Soul of the Ultimate Nation",
150+ "http://sunonline.gamechu.jp/member/");
151+
152+ this.FlashId = "flash_start";
153+ this.FlashvarsName = "START_URL";
154+ }
155+ }
83156 }
Show on old repository browser