Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ブラウザ三国志 自動建築スクリプト By nottisan + 5zen(自動内政改良) 2014.08.20 やばげ鯖対応
// ==UserScript==
// @name bro3_Auto_Bilder
// @namespace http://at-n2.net/
// @description ブラウザ三国志 自動建築スクリプト By nottisan + 5zen(自動内政改良)
// @icon https://raw.github.com/5zen/fake3gokushi/master/icon.png
// @include http://*.3gokushi.jp/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js
// @exclude http://*.3gokushi.jp/world/select_server_mixi_new.php*
// @exclude http://*.3gokushi.jp/maintenance*
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_xmlhttpRequest
// @grant GM_addStyle
// @grant GM_deleteValue
// @grant GM_log
// @grant GM_registerMenuCommand
// @version 2014.08.20
// ==/UserScript==
// 2012.04.22 巡回部分の修正
// 2012.04.23 ビルスクの削除部分の修正(対象施設の対象Lv以下の数+平地数がビルスク対象施設数以下の場合、対象施設名で一番レベルの低いのを削除に変更)
// 2012.04.24 2012.04.24のメンテに対応
// 2012.04.25 id="lodgment" がない場合の対応(本鯖)
// 2012.04.26 本鯖でのダイアログ表示リンクの位置を変更
// 拠点設定データ呼び出しのバグ修正
// 糧変換処理がない場合でも市場情報を保存するように修正
// 糧変換拠点情報をダイアログに表示追加
// 2012.05.01 よくわかんないけどP鯖対応(動くらしい)
// 自動造兵時に宿舎空きがない場合の処理を修正
// userscript.org に公開
// 2012.05.02 市場情報更新時に即時情報表示に切り替え
// 拠点巡回中に自動で内政武将のスキル状況の取得
// スキル使用武将と使用/回復スキル名を表示するように修正
// 2012.05.03 削除施設がレベルアップ対象になった場合処理が進まない不具合を修正
// 拠点のレベルアップ時に、拠点が削除中の場合建設しない処理を追加
// 造兵・武器防具強化情報の自動取得処理を追加
// 2012.05.04 研究所の研究中取得がおかしかったのを修正
// 造兵時のチェックが間違っていたのを修正
// 2012.05.05 造兵施設がLVMAXの場合の処理を追加
// 造兵施設での種類数によって取得処理を変更するように修正
// ブラ三ニュースけしたった(・з・)
// 2012.05.07 兵種研究が即完された場合に表示が残る不具合の修正
// 巡回しなくなっていたバグを修正
// 2012.05.08 内政チェックしなかったのを修正
// 2012.05.11 最新のGreasemonkeyで動作しないのを修正(setTimeout→unsafeWindow.setTimeout)
// 2012.05.23 本拠地の設定ページに市場情報初期化ボタンを追加
// 巡回時間を修正(2225行あたり)
// 2012.05.24 Auto_Domestic のバグ修正(過去の巡回しない原因はこれかも)
// 自動内政のスキル追加(恵風・人選眼力・訓練系・修練系)
// 市場情報をホスト名ごとに保存
// 建設完了時間>設定巡回時間 の時の巡回時間設定が間違ってたのを修正
// 巡回時間にランダムで盛っていた秒を0秒~60秒から0秒~10秒に変更
// 本拠地以外に市場があった場合に糧変換しなかったのを修正
// 市場のある拠点が巡回対象以外でも糧変換するように修正
// 内政スキル発動後に各処理が多分動作するように修正
// 2012.05.25 拠点建設設定のデータがない拠点の初期データが間違っていたのを修正
// 設定画面でNaN(Not a Number)が表示されていたのを修正
// 2012.05.27 ビルスクの設定が反映されないのを修正
// 2012.06.18 村・砦削除中の場合その拠点のみビルダー動作を停止
// 2012.09.06 鍛冶場・防具工場の情報取得部分がバグってるのでちょっと削除
// 糧変換時に ssid が必要になったので追加(他にもssidいるやも?)
// コメント欄にあった造兵部分を修正 thx.名無しさん
// 2012.09.12 改悪アップデートに対応
// 2012.09.15 使用中の内政スキル情報取得部分を修正
// 2012.09.16 回復中の内政スキル情報取得部分を修正
// 2012.09.29 資源表示部分のcssの修正
// 2012.09.30 資源表示部分のcssの修正(プルダウンメニュー・マップ画面)
// 2012.10.10 地図画面の小さな矢印が押せなかったのを修正
// 2013.01.10 糧村・資源村のスキルプリセットを修正
// ダイアログデザインをちょっと修正
// 情報表示ダイアログを非表示でも強制的に表示される現象の修正(領地画面とか)
// 2013.03.08 Firefox 19.0.2 + Greasemonkey 1.8 での動作するように修正
// 2013.12.18 拠点プリセット値変更
// 動作ログを最新から表示に変更。完了分は最大5件のみ表示
// 2013.12.26 村プリセットの追加(軍事拠点)
// 拠点設定画面レイアウト変更
// 標準巡回時間を180秒に変更
// 2014.01.30 大剣兵・盾兵・重盾兵の処理追加開始
// 2014.02.14 Firefox Ver.27 にてFirefoxごと轟沈する処理を修正
// 2014.02.19 大剣兵・盾兵・重盾兵の造兵処理追加(テストは重盾兵のみ)
// 大剣兵・盾兵・重盾兵の武器防具強化処理追加(テストは盾兵のみ)
// 武器防具追加テーブルの追加修正(一部データ不足)
// 2014.02.20 自動内政スキルに「強兵の檄文」「攻城の檄文」を追加
// 設定項目が増えたので一旦設定を初期化しました
// 糧村に銅雀台が建立されなかったのを修正
// 2014.03.06 細かいバグ修正
// 2014.03.07 盾兵・剣兵・重盾兵がある鯖ない鯖の処理分岐追加
// 2014.03.11 地味にログイン画面に表示されていたのを修正
// 2014.07.24 最新のGreasemonkeyで動作しないのを修正(unsafeWindow.setTimeout→setTimeout)
// 2014.08.20 やばげ鯖対応
var VERSION = "2014.08.20"; // バージョン情報
//*** これを変更するとダイアログのフォントスタイルが変更できます ***
var fontstyle = "bold 10px 'MS ゴシック'"; // ダイアログの基本フォントスタイル
var DEBUG = false;
// 色設定
var COLOR_FRAME = "#333333"; // 枠背景色
var COLOR_BASE = "#654634"; // 拠点リンク色
var COLOR_TITLE = "#FFCC00"; // 各BOXタイトル背景色
var COLOR_BACK = "#FFF2BB"; // 各BOX背景色
var DomesticFlg = false;
var WangRay = false; // 2014.02.19
/*!
* jQuery Cookie Plugin
* https://github.com/carhartl/jquery-cookie
*
* Copyright 2011, Klaus Hartl
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://www.opensource.org/licenses/mit-license.php
* http://www.opensource.org/licenses/GPL-2.0
*/
(function($) {
$.cookie = function(key, value, options) {
// key and at least value given, set cookie...
if (arguments.length > 1 && (!/Object/.test(Object.prototype.toString.call(value)) || value === null || value === undefined)) {
options = $.extend({}, options);
if (value === null || value === undefined) {
options.expires = -1;
}
if (typeof options.expires === 'number') {
var days = options.expires, t = options.expires = new Date();
t.setDate(t.getDate() + days);
}
value = String(value);
return (document.cookie = [
encodeURIComponent(key), '=', options.raw ? value : encodeURIComponent(value),
options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
options.path ? '; path=' + options.path : '',
options.domain ? '; domain=' + options.domain : '',
options.secure ? '; secure' : ''
].join(''));
}
// key and possibly options given, get cookie...
options = value || {};
var decode = options.raw ? function(s) { return s; } : decodeURIComponent;
var pairs = document.cookie.split('; ');
for (var i = 0, pair; pair = pairs[i] && pairs[i].split('='); i++) {
if (decode(pair[0]) === key) return decode(pair[1] || ''); // IE saves cookies with empty string as "c; ", e.g. without "=" as opposed to EOMB, thus pair[1] may be undefined
}
return null;
};
})(jQuery);
jQuery.noConflict();
j$ = jQuery;
// 造兵用
// 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8
var OPT_SOL_MAX = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
var OPT_SOL_ADD = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
var OPT_BLD_WOOD = 0;
var OPT_BLD_STONE = 0;
var OPT_BLD_IRON = 0;
var OPT_BLD_RICE = 0;
var OPT_BLD_SOL = 0;
var sort_priority = [];
var OPT_BKBG_CHK = 0;
var make_no = [];
// 兵種, No, 研究済,作成可能兵数,現在の兵数,最大兵数,現兵数との差,x,y
make_no["剣兵"] = ["剣兵" ,301, 0, 0, 0, 0, 0,0,0];
make_no["槍兵"] = ["槍兵" ,303, 0, 0, 1, 0, 0,0,0];
make_no["弓兵"] = ["弓兵" ,308, 0, 0, 2, 0, 0,0,0];
make_no["騎兵"] = ["騎兵" ,305, 0, 0, 3, 0, 0,0,0];
make_no["矛槍兵"] = ["矛槍兵" ,304, 0, 0, 4, 0, 0,0,0];
make_no["弩兵"] = ["弩兵" ,309, 0, 0, 5, 0, 0,0,0];
make_no["近衛騎兵"] = ["近衛騎兵",307, 0, 0, 6, 0, 0,0,0];
make_no["斥候"] = ["斥候" ,310, 0, 0, 7, 0, 0,0,0];
make_no["斥候騎兵"] = ["斥候騎兵",311, 0, 0, 8, 0, 0,0,0];
make_no["衝車"] = ["衝車" ,312, 0, 0, 9, 0, 0,0,0];
make_no["投石機"] = ["投石機" ,313, 0, 0, 10, 0, 0,0,0];
make_no["大剣兵"] = ["大剣兵" ,315, 0, 0, 11, 0, 0,0,0]; // 2014.01.30
make_no["盾兵"] = ["盾兵" ,316, 0, 0, 12, 0, 0,0,0]; // 2014.01.30
make_no["重盾兵"] = ["重盾兵" ,317, 0, 0, 13, 0, 0,0,0]; // 2014.01.30
// 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8
OPT_BK_LV = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
OPT_BG_LV = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
//巡回用
var tidMain2;
var tidMain3;
var nextURL;
var nextNAME;
//寄付用
var OPT_RISE_KIFU_MAX = 10000; //寄付を開始する糧の量
var OPT_RISE_KIFU = 1000; //寄付をする糧の量
//
//市場用
var OPT_RISE_MAX = 30000; //市場変換開始する糧の量
var OPT_TO_WOOD = 10000; //木に変換する糧
var OPT_TO_STONE = 10000; //石に変換する糧
var OPT_TO_IRON = 10000; //鉄に変換する糧
// @@ ADD 2011.09.28 @@
var LOAD_ROUND_TIME_10 = 10;
var LOAD_ROUND_TIME_20 = 20;
var LOAD_ROUND_TIME_30 = 30;
var LOAD_ROUND_TIME_40 = 40;
var LOAD_ROUND_TIME_50 = 50;
var LOAD_ROUND_TIME_60 = 60;
var LOAD_ROUND_TIME_70 = 70;
var LOAD_ROUND_TIME_80 = 80;
var LOAD_ROUND_TIME_90 = 90;
var LOAD_ROUND_TIME_100 = 100;
var LOAD_ROUND_TIME_110 = 110;
var LOAD_ROUND_TIME_120 = 120;
var LOAD_ROUND_TIME_130 = 130;
var LOAD_ROUND_TIME_140 = 140;
var LOAD_ROUND_TIME_150 = 150;
var LOAD_ROUND_TIME_160 = 160;
var LOAD_ROUND_TIME_170 = 170;
var LOAD_ROUND_TIME_180 = 180;
//グローバル変数
var MOUSE_DRAGGING = false;
var MOUSE_OFFSET_X;
var MOUSE_OFFSET_Y;
var MOUSE_DRAGGING_WINDOW = 0;
var ALERT_TIME;
// @@ ADD 2011.05.14 @@
var OPT_MAX_WOOD = 0; // 木の最大保持量
var OPT_MAX_STONE = 0; // 石の最大保持量
var OPT_MAX_IRON = 0; // 鉄の最大保持量
var WOOD = 101; //木の内部コード
var STONE = 102; //石の内部コード
var IRON = 103; //鉄の内部コード
var RICE = 104; //糧の内部コード
//新規作成用
var OPT_KATEMURA = 0; // 自動糧村化オプション
var OPT_DORM = 0; // 自動宿舎村化オプション 2013.12.26
var OPT_TORIDE = 0; // 自動砦化オプション
var OPT_SOUKO_MAX = 1; // 倉庫の最大数
//内政用 by nottisan
// 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 4
// 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0
var OPT_DOME = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
var OPT_BLD = "AC";
var OPT_SorH = "DD";
var OPT_MAX = 3;
var OPT_MAXLV = 6;
var OPT_ROUND_TIME1 = 180; // 巡回時間(sec)
var OPT_ROUND_TIME2 = 10; // 巡回時間(sec)
var Reload_Flg = 0;
var OPT_BUILD_VID;
//グローバル変数
//var INTERVAL = 1000; // 負荷対策 回線速度によっては正常動作しない時があります。その際は数値を増やしてください。1秒=1000
//var INTERVAL2 = 2000; // 負荷対策 回線速度によっては正常動作しない時があります。その際は数値を増やしてください。1秒=1000
var INTERVAL = 1000; // + Math.floor( Math.random() * 5000 ); // 負荷対策 回線速度によっては正常動作しない時があります。その際は数値を増やしてください。1秒=1000
var INTERVAL2 = 2000; // + Math.floor( Math.random() * 5000 ); // 負荷対策 回線速度によっては正常動作しない時があります。その際は数値を増やしてください。1秒=1000
var HOST = location.hostname; //アクセスURLホスト
var PGNAME = "_Auto_Bilder_5zen_v1.21_20140220"; //グリモン領域への保存時のPGの名前
var TIMEOUT_URL ="/false/login_sessionout.php"; //タイムアウト時のURLの一部
var g_MD="";
var SENDTFLG_TIMEOUT = 0; //タイムアウト画面
var SENDTFLG_LOGIN_MENU = 1; //ログイン画面
var SENDTFLG_LOGIN = 2; //ログイン中
var d = document;
// 保存データデリミタ
var DELIMIT1 = "#$%";
var DELIMIT2 = "&?@";
var DELIMIT3 = "{=]";
var DELIMIT4 = "|-/";
//保存データインデックス(拠点)
var IDX_XY = 0; //座標
var IDX_BASE_NAME = 1; //拠点名
var IDX_URL = 2; //拠点URL
var IDX_ACTIONS = 3; //実行中作業
var IDX_BASE_ID = 11; //拠点ID
//保存データインデックス(実行中作業)
var IDX2_STATUS = 0; //ステータス
var IDX2_TIME = 1; //完了時刻
var IDX2_TYPE = 2; //種別 C:都市画面、D:内政スキル、Fxy:施設座標
var IDX2_ALERTED = 3; //通知済フラグ
var IDX2_DELETE = 4; // 削除フラグ
var IDX2_ROTATION = 5; // 巡回フラグ
//作業種別
var TYPE_CONSTRUCTION = "C"; //建設
var TYPE_MARCH = "M"; //行軍
var TYPE_DOMESTIC = "D"; //内政
var TYPE_FACILITY = "F"; //施設
var TYPE_DELETE = "B"; //建設
var OPT_CHKBOX_AVC = 0;
// 拠 木 石 鉄 畑 倉 雀 武 防 練 槍 弓 騎 宿 車 市 訓 水 工 研 大 遠 見 平
// 点 庫 器 具 兵 兵 兵 兵 舎 兵 場 練 車 場 究 宿 征 張 地
// 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
var OPT_CHKBOX = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
var OPT_CHKBOXLV = [ 8,15,15,15,15,20,10,10,10,10,15,15,15,15,15,10,10,10,10,10,20,20,20, 0];
var OPT_MAX_LV = "2";
var OPT_FUC_NAME = ["拠点","伐採所","石切り場","製鉄所","","倉庫",
"銅雀台","鍛冶場","防具工場","練兵所","兵舎","弓兵舎",
"厩舎","宿舎","兵器工房","市場","訓練所","水車","工場",
"研究所","大宿舎","遠征訓練所","見張り台","平地"];
var OPT_FNID = new Array();
OPT_FNID["拠点"] = 0 ;
OPT_FNID["伐採所"] = 1 ;
OPT_FNID["石切り場"] = 2 ;
OPT_FNID["製鉄所"] = 3 ;
OPT_FNID[""] = 4 ;
OPT_FNID["倉庫"] = 5 ;
OPT_FNID["銅雀台"] = 6 ;
OPT_FNID["鍛冶場"] = 7 ;
OPT_FNID["防具工場"] = 8 ;
OPT_FNID["練兵所"] = 9 ;
OPT_FNID["兵舎"] = 10 ;
OPT_FNID["弓兵舎"] = 11 ;
OPT_FNID["厩舎"] = 12 ;
OPT_FNID["宿舎"] = 13 ;
OPT_FNID["兵器工房"] = 14 ;
OPT_FNID["市場"] = 15 ;
OPT_FNID["訓練所"] = 16 ;
OPT_FNID["水車"] = 17 ;
OPT_FNID["工場"] = 18 ;
OPT_FNID["研究所"] = 19 ;
OPT_FNID["大宿舎"] = 20 ;
OPT_FNID["遠征訓練所"] = 21 ;
OPT_FNID["見張り台"] = 22 ;
//OPT_FNID["修行所"] = 23 ;
//市場変換処理用
var OPT_ICHIBA = 0;
var OPT_ICHIBA_PA = 0;
if ( WangRay != true ) {
var OPT_ICHIBA_PATS = ["平均的に変換","一括変換"];
} else {
var OPT_ICHIBA_PATS = ["平均的に変換","一括変換","割合変換"];
}
//自動寄付用
var OPT_KIFU = 0;
var d = document;
var $ = function(id) { return d.getElementById(id); };
var $x = function(xp,dc) { return d.evaluate(xp, dc||d, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; };
var $a = function(xp,dc) { var r = d.evaluate(xp, dc||d, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); var a=[]; for(var i=0; i<r.snapshotLength; i++){ a.push(r.snapshotItem(i)); } return a; };
var $e = function(e,t,f) { if (!e) return; e.addEventListener(t, f, false); };
var $v = function(key) { return d.evaluate(key, document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); }; // 2013.12.18
//LvUPリンク
var LVUPLINK = "http://SITE/facility/build.php?x=urlX&y=urlY&village_id=viID&ssid=ssid_val#ptop";
var URL_SITE = "SITE";
var URL_X = "urlX";
var URL_Y = "urlY";
var URL_viID = "viID";
var URL_viSSID = "ssid_val";
//新規作成リンク
var CREATELINK = "http://SITE/facility/build.php?id=fID&x=urlX&y=urlY&village_id=viID&ssid=ssid_val";
var URL_fID = "fID"; //建物のID
var HATAKE = 215;
var SOUKO = 233;
var SUZUME = 216;
var SYUKUSYA = 242; // 宿舎 2013.12.26
var RENPEIJYO = 234; // 練兵所 2013.12.26
var KAZIBA = 232; // 鍛冶場 2013.12.26
var FACLINK = "http://SITE/facility/facility.php?x=urlX&y=urlY";
var VILLAGELINK = "http://SITE/village.php#ptop";
// 2012.04.10
var LANDLINK = "http://SITE/land.php?x=urlX&y=urlY"
var SETTLELINK = "http://SITE/facility/select_type.php?x=urlX&y=urlY&mode=build&type=fID"
var VillageData = new Array();
var OPT_VILLAGE = new Array();
var isMixi = true;
// @@ ここから @@
var DASkill = [ "■■■■",
"伐採知識","伐採技術","弓兵増強",
"石切知識","石切技術","槍兵増強",
"製鉄知識","製鉄技術","騎兵増強",
"食糧知識","食糧技術",
"農林知識","農林技術",
"加工知識","加工技術",
"富国","富国論","富国強兵",
"豊穣","美玉歌舞",
"恵風","人選眼力",
"呉の治世","王佐の才",
"練兵訓練","練兵修練",
"兵舎訓練","兵舎修練",
"弓兵訓練","弓兵修練",
"厩舎訓練","厩舎修練",
"兵器訓練","兵器修練",
"強兵の檄文","攻城の檄文"
];
// @@ ここまで @@
// 屯田機能用
var URL_PARAM = {};
// 市場変換用
var ShopURL = "";
var ShopFlg = false;
var DBG_Flg = false;
//Main
(function(){
// zIndex(重なり順序)の修正
j$("div#status div#status_left").css({"z-index":"0"});
j$("#menu_container").css({"z-index":"980"});
j$("div#map-scroll").css({"z-index":"150"});
j$("a#cur01, a#cur02, a#cur03, a#cur04, a#double-cur01, a#double-cur02, a#double-cur03, a#double-cur04").css({"z-index":"460"});
initUrlParams();
var mixi_ad_head = xpath('//div[@ID="mixi_ad_head"]', document);
if (mixi_ad_head.snapshotLength) {
mixi_ad_head.snapshotItem(0).style.display = "none";
}
var mixi_ad_groups = xpath('//div[@ID="mixi_ad_groups"]', document);
if (mixi_ad_groups.snapshotLength) {
mixi_ad_groups.snapshotItem(0).style.display = "none";
}
var mixi_ad_news = xpath('//div[@class="brNews"]', document);
if (mixi_ad_news.snapshotLength) {
mixi_ad_news.snapshotItem(0).style.display = "none";
}
addOpenLinkHtml()
if ( getStayMode() ) {
closeIniBilderBox()
openIniBilderBox()
}
// =============================================================================================
//領地画面なら拠点建設データ取得
if( location.pathname == "/land.php" && URL_PARAM.x && URL_PARAM.y ) {
getAddingVillage(document.body);
}
//拠点画面なら拠点削除データ取得
if( location.pathname == "/facility/castle.php" ) {
getDeletingVillage(document.body);
}
//バグ回避 600000=5*60*1000
// 領地画面や建築画面で停止した場合の処理
// 5分間止まっていた場合拠点画面に移動する
if(location.pathname == "/land.php" || location.pathname == "/facility/facility.php") {
setTimeout(function(){location.href = "http://"+HOST+"/village.php";},300000);
}
// =============================================================================================
//君主プロフィール画面なら都市画面URLを取得
if ((location.pathname == "/user/" || location.pathname == "/user/index.php") &&
getParameter("user_id") == "") {
getUserProf(document);
if ( getStayMode() ) {
closeIniBilderBox()
openIniBilderBox()
}
}
OPT_BUILD_VID = GM_getValue(HOST+PGNAME+"OPT_BUILD_VID" , "" );
if (location.pathname == "/village.php") {
var vID = "";
//座標を取得
var xyElem = document.evaluate('//*[@id="basepoint"]/span[@class="xy"]',document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
vId = trim(xyElem.snapshotItem(0).innerHTML.match(/(\(-?\d+,-?\d+\))/)[1]); // 2014.08.20
Load_OPT(vId);
if (OPT_BUILD_VID != getVillageID(vId)) {
GM_setValue(HOST+PGNAME+"OPT_BUILD_VID" , "" );
OPT_BUILD_VID = "";
}
getVillageActions(); // 建築情報の取得
checkVillageLength(); // 拠点数チェック 2012.04.09
settleVillages(0); // 自動拠点作成 2012.04.09
//拠点画面なら対象建築物の建築チェック
var villages = loadVillages(HOST+PGNAME);
for(var i=0; i<villages.length;i++){
var tChk1 = GM_getValue(HOST+PGNAME+"OPT_CHKBOX_AVC_"+i, true);
if ( getVillageID(vId) == getParameter2(villages[i][IDX_URL], "village_id") ){
break;
}
}
// 拠点にチェックがある場合建設処理を行う
if (tChk1){
Auto_Domestic(); // 自動内政処理 by nottisan
} else {
ichibaChange(vId); // 市場処理
autoDonate(); // 自動寄付処理
}
// 研究所情報取得
var area = new Array();
area = get_area();
var _x = -1;
var _y = -1;
var _lv = -1;
for (var i=0;i<area.length;i++){
if (area[i].name == "研究所") {
var Temp = area[i].xy.split(",");
_x = Temp[0];
_y = Temp[1];
_lv = area[i].lv;
}
}
if ( _x < 0 ) {
// 内政スキルチェック
var nText = document.evaluate('//*[@class="base-skill"]/span/a', document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
var nName = nText.snapshotItem(0).innerHTML.split(":");
if (nName[0].length != 12) {
// 内政武将がセットされている場合
// alert("内政武将は " + nName[0].trim() + " です");
j$.get("http://"+HOST+"/card/domestic_setting.php#ptop",function(x){
var htmldoc = document.createElement("html");
htmldoc.innerHTML = x;
getDomesticSkill(htmldoc); // 内政スキル使用チェック
forwardNextVillage(); // 次の拠点へ移動
});
} else {
// 内政武将がセットされていない場合
var data = getMyVillage();
data[IDX_ACTIONS] = new Array();
saveVillage(data, TYPE_DOMESTIC);
if ( getStayMode() ) {
closeIniBilderBox()
openIniBilderBox()
}
forwardNextVillage(); // 次の拠点へ移動
}
} else {
try {
// 研究所チェック
j$.get("http://"+HOST+"/facility/facility.php?x=" + _x + "&y=" + _y ,function(x){
var htmldoc = document.createElement("html");
htmldoc.innerHTML = x;
getTrainingSoldier(htmldoc);
// 内政スキルチェック
var nText = document.evaluate('//*[@class="base-skill"]/span/a', document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
var nName = nText.snapshotItem(0).innerHTML.split(":");
if (nName[0].length != 12) {
// 内政武将がセットされている場合
// alert("内政武将は " + nName[0].trim() + " です");
j$.get("http://"+HOST+"/card/domestic_setting.php#ptop",function(x){
var htmldoc = document.createElement("html");
htmldoc.innerHTML = x;
getDomesticSkill(htmldoc); // 内政スキル使用チェック
forwardNextVillage(); // 次の拠点へ移動
});
} else {
// 内政武将がセットされていない場合
var data = getMyVillage();
data[IDX_ACTIONS] = new Array();
saveVillage(data, TYPE_DOMESTIC);
if ( getStayMode() ) {
closeIniBilderBox()
openIniBilderBox()
}
forwardNextVillage(); // 次の拠点へ移動
}
});
}catch(e) {
// エラーが発生した場合次の拠点へ移動
forwardNextVillage(); // 次の拠点へ移動
}
}
}
//兵士作成画面なら作成中兵士を取得
if (location.pathname == "/facility/facility.php") {
//var actionType = TYPE_FACILITY + getParameter("x") + getParameter("y");
j$.get("http://"+HOST+"/facility/facility.php?x=" + getParameter("x") + "&y=" + getParameter("y") + "#ptop",function(x){
var htmldoc = document.createElement("html");
htmldoc.innerHTML = x;
getTrainingSoldier(htmldoc);
if ( getStayMode() ) {
closeIniBilderBox()
openIniBilderBox()
}
});
}
})();
function log() { console.log.apply(console, Array.slice(arguments)) };
function debugLog( mes ) { if (DEBUG) { console.log(mes); } };
// ===========================================================================================================
//URL読み込み
function initUrlParams() {
var matches = location.search.match(/(?:\?|&)?([^=]+)(?:=([^&]+))?/g);
if (matches) {
var param;
var key;
var data;
for(var i = 0 ; i < matches.length ; i++) {
param = matches[i].match(/(?:\?|&)?([^=]+)(?:=([^&]+))?/);
key = param[1];
data = param[2];
URL_PARAM[key] = '';
if( param.length == 3 && typeof data == 'string') {
URL_PARAM[key] = decodeURIComponent(data);
// session id
if (key.toLowerCase() == 'ssid') {
SID = key + '=' +data;
}
}
}
}
}
//拠点作成開始
function settleVillages(z){
//新規拠点作成に必要な名声があれば拠点作成
if ( checkFame() ){
//予約データ取得
var lists = cloadData(HOST+"ReserveList", "[]", true, true);
if( lists.length == 0 || z >= lists.length) {return;}
if( lists[z].status != 1 && lists[z].status != 0) {settleVillages(z+1);return;}
var mURL = LANDLINK;
mURL = mURL.replace(URL_SITE,HOST);
mURL = mURL.replace(URL_X,lists[z].x);
mURL = mURL.replace(URL_Y,lists[z].y);
var tid=setTimeout(function(){
GM_xmlhttpRequest({
method:"GET",
url:mURL,
headers:{"Content-type":"text/html"},
overrideMimeType:'text/html; charset=utf-8',
onload:function(x){
var htmldoc = document.createElement("html");
htmldoc.innerHTML = x.responseText;
//拠点を作成できるかチェック
var rmtime = htmldoc.innerHTML.match(/この領地を拠点にする/);
if ( rmtime ) { //拠点を作成できる場合作成開始
var mURL = SETTLELINK;
mURL = mURL.replace(URL_SITE,HOST);
mURL = mURL.replace(URL_X,lists[z].x);
mURL = mURL.replace(URL_Y,lists[z].y);
mURL = mURL.replace(URL_fID,lists[z].kind);
var tid=setTimeout(function(){
GM_xmlhttpRequest({
method:"GET",
url:mURL,
headers:{"Content-type":"text/html"},
overrideMimeType:'text/html; charset=utf-8',
onload:function(x){
var htmldoc = document.createElement("html");
htmldoc.innerHTML = x.responseText;
//拠点が作成開始できているか確認
if (!htmldoc.innerHTML.match(/名声が不足しています/)) {
getAddingVillage(htmldoc);
if ( getStayMode() ) {
closeIniBilderBox()
openIniBilderBox()
}
}
}
});
}, INTERVAL);
} else {
failSettleVillage(z);
settleVillages(z+1);
}
}
});
}, INTERVAL);
}
//名声チェック
function checkFame() {
//現在の名声MAX取得
var fameMAX;
// 2014.08.20 ここから
fameMAX = 0;
try {
var fameText = $x('id("status_left")/img[contains(@src,"ico_fame.gif")]').nextSibling;
if( fameText ) {
var tmp = fameText.nodeValue.match(/\s*(\d+)\s*\/\s*(\d+)/);
fameMAX = parseInt(tmp[2],10);
}
} catch(e) {
// やばげ鯖用例外処理
var fameText = $x('id("status_resources")//li[5]').innerHTML;
if( fameText ) {
var tmp = fameText.match(/&nbsp;(\d+)&nbsp;\/&nbsp;(\d+)/);
fameMAX = parseInt(tmp[2],10);
}
}
// 2014.08.20 ここまで
//拠点作成に必要な名声
var bldtbl = [17, 35, 54, 80, 112, 150, 195, 248, 310, 999];
//現在の拠点の数
//var villages = loadVillages(HOST);
//var villageLength = document.evaluate('//div[@id="lodgment"]/div/ul/li/a', document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); //拠点数-1になる
// 2012.04.25 本鯖対応
var villageLength = $a('//ul/li/a[contains(@href,"/village_change.php?village_id")]').length; //拠点数-1になる
//作成中の拠点の数
var lists = cloadData(HOST+"ReserveList", "[]", true, true);
var x = 0;
for (var i=0 ; i<lists.length ; i++) {
if(lists[i].status == 2){x++;}
}
// return (fameMAX >= bldtbl[villageLength.snapshotLength + x]);
return (fameMAX >= bldtbl[villageLength + x]);
}
function failSettleVillage(z) {
var lists = cloadData(HOST+"ReserveList", "[]", true, true);
if (lists[z].status == 1) { lists[z].status = 0;}
csaveData(HOST+"ReserveList", lists, true, true );
}
}
// 拠点数の保存情報と現状を比較&修正 2012.04.09
function checkVillageLength() {
//データ整理
var lists = cloadData(HOST+"ReserveList", "[]", true, true);
lists = checkList(lists); //時間の過ぎたものを削除
//予定時刻を過ぎていたら新規拠点情報を取得
function checkList(lists)
{
//時刻チェック
var dt = new Date();
var ntime = dt.getFullYear() + "-" +
(dt.getMonth()+101).toString().substr(-2) + "-" +
(dt.getDate()+100).toString().substr(-2) + " " +
(dt.getHours()+100).toString().substr(-2) + ":" +
(dt.getMinutes()+100).toString().substr(-2) + ":" +
(dt.getSeconds()+100).toString().substr(-2);
//リストのデータを書き換え
var flg = 0;
for(var i=0 ; i<lists.length ; i++) {
if( lists[i].time < ntime ) {
if( lists[i].status == 4 ) { lists[i].status = 5; flg = 1;} //破棄 -> 破棄完了
if( lists[i].status == 2 ) { lists[i].status = 3; flg = 1;} //作成 -> 作成完了
}
}
csaveData(HOST+"ReserveList", lists, true, true );
//拠点情報を取得&移動
if (flg == 1){
getUserProfJumpNewVillage();
} else {
checkVillageLengthDiff();
}
return lists;
}
function getUserProfJumpNewVillage(){
var tid=setTimeout(function(){
GM_xmlhttpRequest({
method:"GET",
url:"http://" + HOST + "/user/",
headers:{"Content-type":"text/html"},
overrideMimeType:'text/html; charset=utf-8',
onload:function(x){
var htmldoc = document.createElement("html");
htmldoc.innerHTML = x.responseText;
//拠点リストを更新
getUserProf(htmldoc);
if ( getStayMode() ) {
closeIniBilderBox()
openIniBilderBox()
}
//本拠地に強制ジャンプ
var villages = loadVillages(HOST+PGNAME);
var tid=setTimeout(function(){
location.href = villages[0][IDX_URL];},INTERVAL);
//新規拠点に移動
//jumpNewVillage();
}
});
}, INTERVAL);
//新規拠点画面へ移動
/*
function jumpNewVillage(){
var villages = loadVillages(HOST+PGNAME);
for (var j = villages.length-1; j >= 0; j--) {
//新規と名のつく拠点へ移動
if(villages[j][IDX_BASE_NAME].match(/新規/)){
var tid=setTimeout(function(){
location.href = villages[j][IDX_URL];},INTERVAL);
return;
}
}
}
*/
}
//拠点数が変わっていたら情報取得 @@1@@
function checkVillageLengthDiff() {
debugLog("=== Start checkVillageLengthDiff ===");
var villages = loadVillages(HOST+PGNAME);
// var villageLength = document.evaluate('//div[@id="lodgment"]/div/ul/li', document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); //拠点数
// 2012.04.25 本鯖対応
var villageLength = $a('//ul/li/a[contains(@href,"/village_change.php?village_id")]').length + 1; //拠点数
//if (villages.length != villageLength.snapshotLength) {
if (villages.length != villageLength) {
setTimeout(function(){
GM_xmlhttpRequest({
method:"GET",
url:"http://" + HOST + "/user/",
headers:{"Content-type":"text/html"},
overrideMimeType:'text/html; charset=utf-8',
onload:function(x){
var htmldoc = document.createElement("html");
htmldoc.innerHTML = x.responseText;
getUserProf(htmldoc);
if ( getStayMode() ) {
closeIniBilderBox()
openIniBilderBox()
}
var tid=setTimeout(function(){location.reload();},INTERVAL);
}
});
}, INTERVAL);
}
}
}
//Beyond系save, load関数
function csaveData(key, value, local, ev)
{
if( local ) key = location.hostname + key + PGNAME;
if( ev ) {
if (window.opera || typeof JSON != 'object') {
value = toJSON(value);
}
else {
value = JSON.stringify( value );
}
}
GM_setValue(key, value );
}
function cloadData(key, value, local, ev)
{
if( local ) key = location.hostname + key + PGNAME;
var ret = GM_getValue(key, value);
return ev ? eval('ret='+ret) : ret;
}
//-----------------------------------TonDen---------------------------------
//領地画面なら拠点建設データ取得
function getAddingVillage(htmldoc) {
var xyElem = document.evaluate('//*[@id="basepoint"]/span[@class="xy"]',
htmldoc, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
var xy = xyElem.snapshotItem(0).innerHTML.match(/(-?\d+,-?\d+)/);
var Temp = xy[0].split(",");
var x = Temp[0];
var y = Temp[1];
var rmname = htmldoc.innerHTML.match(/(現在村を建設中です|現在砦を建設中です)/ );
if( rmname ) {
var rmtime = htmldoc.innerHTML.match(/(\d+-\d+-\d+ \d+:\d+:\d+)*に完了します。/ );
if( rmname[1] == "現在村を建設中です" ) {
addList(rmtime[1], 220, 2, x, y );
}else if( rmname[1] == "現在砦を建設中です" ) {
addList(rmtime[1], 222, 2, x, y );
}
}
if(htmldoc == document.body) {
// addLink();
addLink2();
}
function addList(tim, kind, status, x, y)
{
var lists = cloadData(HOST+"ReserveList", "[]", true, true);
var flg = 0;
for(var i=0 ; i<lists.length ; i++) {
if(lists[i].x == x && lists[i].y == y ) {
lists[i].time = tim;
lists[i].kind = kind;
lists[i].status = status;
flg = 1;
}
}
if(flg == 0) {
lists.push({"x":x, "y":y, "time":tim, "kind":kind, "status":status });
}
lists.sort( function(a,b){
if(a.time > b.time) return 1;
if(a.time < b.time) return -1;
return 0;});
csaveData(HOST+"ReserveList", lists, true, true );
}
function addLink() {
//id="tMenu"にLinkを挿入
var tMenu = document.evaluate('//*[@id="tMenu"]',
htmldoc, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
if (tMenu.snapshotLength == 0) return;
//村作成予約
var villageLink = document.createElement("a");
villageLink.id = "village";
villageLink.href = "javascript:void(0);";
villageLink.innerHTML = "村建設予約";
villageLink.addEventListener("click", function() {addReserveVillages(220)}, true);
tMenu.snapshotItem(0).appendChild(villageLink);
//砦作成予約
var fortLink = document.createElement("a");
fortLink.id = "fort";
fortLink.href = "javascript:void(0);";
fortLink.innerHTML = "砦建設予約";
fortLink.addEventListener("click", function() {addReserveVillages(222)}, true);
tMenu.snapshotItem(0).appendChild(fortLink);
}
function addLink2() {
//id="tMenu"にLinkを挿入
var tMenu = document.evaluate('//div[@class="status"]',
document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
if (tMenu.snapshotLength == 0) {
var tMenu = document.evaluate('//div[@id="basepoint"]',
document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
if (tMenu.snapshotLength == 0) return;
}
var villageLink = document.createElement("span");
villageLink.style.color = "white";
villageLink.style.fontSize = "10px";
villageLink.style.textAlign = "center";
villageLink.innerHTML = "建設予約 ";
tMenu.snapshotItem(0).appendChild(villageLink);
//村作成予約
var villageLink = document.createElement("a");
villageLink.id = "village";
villageLink.style.color = "white";
villageLink.style.fontSize = "10px";
villageLink.style.textAlign = "center";
villageLink.href = "javascript:void(0);";
villageLink.innerHTML = "";
villageLink.addEventListener("click", function() {addReserveVillages(220)}, true);
tMenu.snapshotItem(0).appendChild(villageLink);
var villageLink = document.createElement("span");
villageLink.style.color = "white";
villageLink.style.fontSize = "10px";
villageLink.style.textAlign = "center";
villageLink.innerHTML = " ";
tMenu.snapshotItem(0).appendChild(villageLink);
//砦作成予約
var fortLink = document.createElement("a");
fortLink.id = "fort";
fortLink.style.color = "white";
fortLink.style.fontSize = "10px";
fortLink.style.textAlign = "center";
fortLink.href = "javascript:void(0);";
fortLink.innerHTML = "";
fortLink.addEventListener("click", function() {addReserveVillages(222)}, true);
tMenu.snapshotItem(0).appendChild(fortLink);
}
function addReserveVillages(kind) {
url = location;
var flgAdd = addList2(kind, 1, URL_PARAM.x, URL_PARAM.y);
var msg = "";
if (flgAdd == 0){
msg += "(" + URL_PARAM.x + "," + URL_PARAM.y + ")への、";
if(kind == 220){msg += "村建設予約";
}else if(kind == 222){msg += "砦建設予約";
}
msg += "を受け付けました。"
} else {
msg += "(" + URL_PARAM.x + "," + URL_PARAM.y + ")には、すでに建設予約があります。";
}
alert(msg);
if ( getStayMode() ) {
closeIniBilderBox()
openIniBilderBox()
}
}
function addList2(kind, status, x, y) //kind=220:村予約 222:砦予約
{
var lists = cloadData(HOST+"ReserveList", "[]", true, true);
var dt = new Date();
var ntime = dt.getFullYear() + "-" +
(dt.getMonth()+101).toString().substr(-2) + "-" +
(dt.getDate()+100).toString().substr(-2) + " " +
(dt.getHours()+100).toString().substr(-2) + ":" +
(dt.getMinutes()+100).toString().substr(-2) + ":" +
(dt.getSeconds()+100).toString().substr(-2);
for(var i=0 ; i<lists.length ; i++) {
if(lists[i].x == x && lists[i].y == y ) {
return;
}
}
lists.push({"x":x, "y":y, "time":ntime, "kind":kind, "status":status });
lists.sort( function(a,b){
if(a.time > b.time) return 1;
if(a.time < b.time) return -1;
return 0;});
csaveData(HOST+"ReserveList", lists, true, true );
return 0;
}
}
//拠点画面で建設予約受付
function addLinkTondenVillage() {
var xyElem = document.evaluate('//span[@class="xy"]',
document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
var xy = xyElem.snapshotItem(0).innerHTML.match(/(-?\d+,-?\d+)/);
var Temp = xy[0].split(",");
var x = Temp[0];
var y = Temp[1];
addLink();
function addLink() {
//id="tMenu"にLinkを挿入
var tMenu = document.evaluate('//div[@class="status village-bottom"]',
document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
if (tMenu.snapshotLength == 0) return;
var villageLink = document.createElement("span");
villageLink.innerHTML = " 建設予約 ";
tMenu.snapshotItem(0).appendChild(villageLink);
//村作成予約
var villageLink = document.createElement("a");
villageLink.id = "village";
villageLink.href = "javascript:void(0);";
villageLink.innerHTML = "";
villageLink.addEventListener("click", function() {addReserveVillages(220)}, true);
tMenu.snapshotItem(0).appendChild(villageLink);
var villageLink = document.createElement("span");
villageLink.innerHTML = " ";
tMenu.snapshotItem(0).appendChild(villageLink);
//砦作成予約
var fortLink = document.createElement("a");
fortLink.id = "fort";
fortLink.href = "javascript:void(0);";
fortLink.innerHTML = "";
fortLink.addEventListener("click", function() {addReserveVillages(222)}, true);
tMenu.snapshotItem(0).appendChild(fortLink);
}
function addReserveVillages(kind) {
url = location;
var flgAdd = addList2(kind, 1, x, y);
var msg = "";
if (flgAdd == 0){
msg += "(" + x + "," + y + ")への、";
if(kind == 220){msg += "村建設予約";
}else if(kind == 222){msg += "砦建設予約";
}
msg += "を受け付けました。"
} else {
msg += "(" + x + "," + y + ")には、すでに建設予約があります。";
}
alert(msg);
if ( getStayMode() ) {
closeIniBilderBox()
openIniBilderBox()
}
}
function addList2(kind, status, x, y) //kind=220:村予約 222:砦予約
{
var lists = cloadData(HOST+"ReserveList", "[]", true, true);
var dt = new Date();
var ntime = dt.getFullYear() + "-" +
(dt.getMonth()+101).toString().substr(-2) + "-" +
(dt.getDate()+100).toString().substr(-2) + " " +
(dt.getHours()+100).toString().substr(-2) + ":" +
(dt.getMinutes()+100).toString().substr(-2) + ":" +
(dt.getSeconds()+100).toString().substr(-2);
for(var i=0 ; i<lists.length ; i++) {
if(lists[i].x == x && lists[i].y == y && (lists[i].status == 0 || lists[i].status == 1)) {
return;
}
}
lists.push({"x":x, "y":y, "time":ntime, "kind":kind, "status":status });
lists.sort( function(a,b){
if(a.time > b.time) return 1;
if(a.time < b.time) return -1;
return 0;});
csaveData(HOST+"ReserveList", lists, true, true );
return 0;
}
}
//拠点画面なら拠点削除データ取得
function getDeletingVillage(htmldoc) {
var xy = getMyXY();
var Temp = xy.split(",");
var x = Temp[0];
var y = Temp[1];
var rmtime = htmldoc.innerHTML.match(/(村を削除中です。|砦を削除中です。)[^\d]*(\d+-\d+-\d+ \d+:\d+:\d+)に完了します。/);
if( rmtime ) {
if( rmtime[1] == "村を削除中です。" ) {
addList(rmtime[2], 220, 4, x, y );
}else if( rmtime[1] == "砦を削除中です。" ) {
addList(rmtime[2], 222, 4, x, y );
}
}else{
delList(1, x, y);
}
if ( getStayMode() ) {
closeIniBilderBox()
openIniBilderBox()
}
function addList(tim, kind, status, x, y)
{
var lists = cloadData(HOST+"ReserveList", "[]", true, true);
var flg = 0;
for(var i=0 ; i<lists.length ; i++) {
if(lists[i].x == x && lists[i].y == y && (lists[i].status != 0 && lists[i].status != 1 && lists[i].status != 2)) {
lists[i].time = tim;
lists[i].kind = kind;
lists[i].status = status;
flg = 1;
}
}
if(flg == 0) {
lists.push({"x":x, "y":y, "time":tim, "kind":kind, "status":status });
}
lists.sort( function(a,b){
if(a.time > b.time) return 1;
if(a.time < b.time) return -1;
return 0;});
csaveData(HOST+"ReserveList", lists, true, true );
}
function delList(kind, x, y) //kind=0:land 1:castle
{
var lists = cloadData(HOST+"ReserveList", "[]", true, true);
for(var i=0 ; i<lists.length ; i++) {
if(lists[i].x == x && lists[i].y == y ) {
if( lists[i].status == 4 && kind == 1 ) {
lists.splice(i,1);
csaveData(HOST+"ReserveList", lists, true, true );
break;
}
}
}
}
}
// =================================================================================================
function DeleteFacility(_x,_y){
var tid=setTimeout(function(){
var mURL = FACLINK;
mURL = mURL.replace(URL_SITE,HOST);
mURL = mURL.replace(URL_X,_x);
mURL = mURL.replace(URL_Y,_y);
GM_xmlhttpRequest({
method:"GET",
url: mURL,
headers:{"Content-type":"text/html"},
overrideMimeType:'text/html; charset=utf-8',
onload:function(x){
var htmldoc = document.createElement("html");
htmldoc.innerHTML = x.responseText;
var tables = document.evaluate('//*[@name="ssid"]',htmldoc, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
var ssid=tables.snapshotItem(0).value;
var c={};
c['x'] = parseInt(_x);
c['y'] = parseInt(_y);
c['ssid']=tables.snapshotItem(0).value;
c['remove']="%E5%BB%BA%E7%89%A9%E3%82%92%E5%A3%8A%E3%81%99";
j$.post("http://"+HOST+"/facility/facility.php?x=" + _x + "&y=" + _y + "#ptop",c,function(){});
var tid=setTimeout(function(){location.reload(false);},INTERVAL);
}
});
},0);
}
function autoLvup() {
debugLog("=== Start autoLvup ===");
var cost_bk_ken=[
[ 165, 135, 0, 0, 6600],
[ 251, 319, 0, 0, 8910],
[ 184, 596, 0,303,11220],
[ 351, 994, 0,604,13200],
[ 431, 828,2054, 0,15180],
[ 159, 848,4294, 0,17820],
[1397, 2301,4519, 0,19140],
[1019, 4458,7260, 0,21120],
[ 0,11558,3572, 0,23100],
[ 0,19648,6073, 0,25080],
[ 0, 0, 0, 0, 0]
];
// 槍兵
var cost_bk_yari=[
[ 1820, 3575, 0,1105,13500],
[ 3640, 7150, 0,2210,18225],
[ 0, 12870, 6552,3978,22950],
[ 0, 21879,11138,6763,27000],
[10820, 35006,17821, 0,31050],
[16230, 52510,26732, 0,36450],
[22722, 73514,37425, 0,39150],
[30675, 99243,50524, 0,43200],
[39878,129016,65681, 0,47250],
[51841,167721,85385, 0,51300],
[ 0, 0, 0, 0, 0]
];
// 矛槍兵
var cost_bk_hoko=[
[ 14000, 27500, 0, 8500,18600],
[ 28000, 55000, 0,17000,25380],
[ 0, 104500, 53200,32300,31620],
[ 0, 188100, 95760,58140,37200],
[ 98838, 319770, 162792, 0,42700],
[158141, 511632, 260467, 0,50220],
[237211, 767448, 390701, 0,53940],
[332096,1074427, 546981, 0,59520],
[431724,1396755, 711075, 0,65100],
[647587,2095133,1066613, 0,70680],
[ 0, 0, 0, 0, 0]
];
// 弓兵
var cost_bk_yumi=[
[ 3795, 0, 1173,1932,13500],
[ 7590, 0, 2346,3864,18225],
[ 13662, 0, 6995,4223,22950],
[ 23225, 0,11824,7179,27000],
[ 37161,11486,18918, 0,31050],
[ 55741,17229,28377, 0,36450],
[ 78038,39728,24121, 0,39150],
[105351,53633,32563, 0,43200],
[122015,49802,77193, 0,47250],
[178043,55031,90640, 0,51300],
[ 0, 0, 0, 0, 0]
];
// 弩兵
var cost_bk_dokyu=[
[ 30250, 0, 9350,15400,18600],
[ 60500, 0, 18700,30800,25110],
[ 114950, 0, 58520,35530,31620],
[ 206910, 0, 105336,63954,37200],
[ 351747,108722, 179071, 0,42780],
[ 562795,173955, 286514, 0,50220],
[ 844193,429771, 260932, 0,53940],
[1181870,601679, 365305, 0,59520],
[1368820,558720, 865988, 0,65100],
[2320010,717094,1181096, 0,70680],
[ 0, 0, 0, 0, 0]
];
// 騎兵
var cost_bk_uma=[
[1241,2044,4015,0,13500],
[2482,4088,8030,0,17313],
[4468,0,14454,7358,22950],
[7595,0,24572,12509,27000],
[12152,0,39315,20015,31040],
[0,18228,58973,30022,36450],
[0,42031,82562,25519,39150],
[0,56742,111458,34451,43200],
[0,73765,144895,44786,47250],
[0,95894,188364,58222,51300],
[0,0,0,0,0]
];
// 近衛騎兵
var cost_bk_konoe=[
[10200,16800,33000,0,18600],
[20400,33600,66000,0,25110],
[38760,0,125400,63840,31620],
[69768,0,225720,114912,37200],
[76745,0,488376,132559,14400],
[0,189769,613958,312561,50220],
[0,468841,920938,284653,53940],
[0,656377,1289313,398515,59520],
[0,853291,1676107,518069,65100],
[0,1279936,2514161,777104,70680],
[0,0,0,0,0]
];
// 衝車
var cost_bk_kuruma=[
[6600,2040,3360,0,17000],
[13200,4080,6720,0,22950],
[23760,7344,12096,0,28900],
[40392,12485,20536,0,34000],
[64627,19976,32901,0,39100],
[96941,29964,49352,0,45900],
[135717,41949,69092,0,49300],
[183218,56631,93274,0,54400],
[238183,73620,121257,0,59500],
[359657,111167,183098,0,64600],
[0,0,0,0,0]
];
// 投石機
var cost_bk_stone=[
[ 11050, 35750, 18200,0,24000],
[ 22100, 71500, 36400,0,32400],
[ 41990, 135850, 69160,0,40800],
[ 75582, 244530, 124488,0,48000],
[128489, 415701, 211630,0,55200],
[205583, 665122, 338607,0,64800],
[308375, 997682, 507911,0,69600],
[431724,1396755, 711075,0,76800],
[561242,1815782, 924398,0,84000],
[729614,2360517,1201718,0,91200],
[0,0,0,0,0]
];
// 大剣兵
var cost_bk_bigken=[
[ 24775, 20270, 0, 0,24000],
[ 39671, 50419, 0, 0,32400],
[ 29082, 94199, 0, 47890,40800],
[ 55488, 157137, 0, 95483,48000],
[ 68141, 130906, 324736, 0,55200],
[ 25137, 134063, 691341, 0,64800],
[213721, 352019, 691341, 0,69600],
[140799, 615977,1003138, 0,76800],
[ 0,1258370, 388899,640617,84000],
[ 0,1870636, 578195,952360,67080],
[0,0,0,0,0]
];
// 盾兵
var cost_bk_shield=[
[0,0,0,0,0], // Lv1
[0,0,0,0,0], // Lv2
[0,0,0,0,0], // Lv3
[0,0,0,0,0], // Lv4
[0,0,0,0,0], // Lv5
[0,0,0,0,0], // Lv6
[0,0,0,0,0], // Lv7
[0,0,0,0,0], // Lv8
[0,0,0,0,0], // Lv9
[0,0,0,0,0], // Lv10
[0,0,0,0,0]
];
// 重盾兵
var cost_bk_bigshield=[
[0,0,0,0,0], // Lv1
[0,0,0,0,0], // Lv2
[0,0,0,0,0], // Lv3
[0,0,0,0,0], // Lv4
[0,0,0,0,0], // Lv5
[0,0,0,0,0], // Lv6
[0,0,0,0,0], // Lv7
[0,0,0,0,0], // Lv8
[0,0,0,0,0], // Lv9
[0,0,0,0,0], // Lv10
[0,0,0,0,0]
];
// 防具工場テーブル ========================================================
// 剣兵
var cost_bg_ken=[
[ 149, 122, 0, 0, 6600],
[ 228, 285, 0, 0, 8910],
[ 168, 534, 0, 273,11220],
[ 310, 900, 0, 544,13200],
[ 373, 745,1864, 0,15180],
[ 539, 1431,2801, 0,17820],
[1265, 2063,4067, 0,19140],
[1949, 6304,3209, 0,21120],
[ 0,10288,3253,5371,23100],
[ 0,17683,5466,9002,25080],
[0,0,0,0,0]
];
// 槍兵
var cost_bg_yari=[
[ 1638, 3218, 0, 995,13500],
[ 3276, 6435, 0,1989,18225],
[ 0, 11583, 5897,3580,22950],
[ 0, 19691,10025,6086,27000],
[ 9738, 31506,16039, 0,31050],
[14607, 47259,24059, 0,36450],
[20450, 66162,33683, 0,39150],
[27608, 89319,45471, 0,43200],
[35890,116115,59113, 0,51300],
[46657,150949,76847, 0,55350],
[0,0,0,0,0]
];
// 矛槍兵
var cost_bg_hoko=[
[ 12600, 24750, 0, 7650, 18600],
[ 25200, 49500, 0,15300, 25110],
[ 0, 94050, 47880,29070, 31620],
[ 0, 169290, 86184,52326, 37200],
[ 88954, 287793, 146513, 0, 42780],
[142327, 460469, 234420, 0, 50220],
[213490, 690703, 351631, 0, 53940],
[298886, 966984, 492283, 0, 59520],
[388552,1257080, 639968, 0, 65100],
[545116,1762197,1121087, 0,358680],
[0,0,0,0,0]
];
// 弓兵
var cost_bg_yumi=[
[ 3416, 0, 1056,1739,13500],
[ 6831, 0, 2111,3478,22950],
[ 12296, 0, 6260,3801,27000],
[ 20903, 0,10641,6461,31050],
[ 33445,10337,17026, 0,36450],
[ 50167,15506,25540, 0,39150],
[ 70234,35756,21709, 0,43200],
[ 94816,48270,29307, 0,47250],
[108917,44822,70371, 0,51300],
[160238,49528,81576, 0,55350],
[0,0,0,0,0]
];
// 弩級
var cost_bg_dokyu=[
[ 27225, 0, 8415,13860,18600],
[ 54450, 0, 16830,27720,25110],
[ 103455, 0, 52668,31977,31620],
[ 186219, 0, 94802,57559,37200],
[ 316572, 97850, 161164, 0,42780],
[ 506516,156559, 257863, 0,50220],
[ 759774,386794, 234839, 0,53940],
[1063683,541511, 328775, 0,59520],
[1221881,502832, 789446, 0,65100],
[2088009,645385,1062986, 0,70680],
[0,0,0,0,0]
];
// 騎兵
var cost_bg_uma=[
[ 1117, 1840, 3614, 0,13500],
[ 2234, 3679, 7227, 0,18225],
[ 4021, 0, 13009, 6623,22950],
[ 6835, 0, 22115,11258,27000],
[10937, 0, 35384,18013,31050],
[ 0,16405, 53075,27020,36450],
[ 0,37828, 74305,22967,43200],
[ 0,51068,100312,31006,47250],
[ 0,66388,130406,40307,51300],
[ 0,86305,169528,52399,55350],
[0,0,0,0,0]
];
// 近衛騎兵
var cost_bg_konoe=[
[ 9180, 15120, 29700, 0,18600],
[ 6156, 10134, 19908, 0,25110],
[ 7830, 0, 25344, 12900,31620],
[ 8952, 0, 28962, 14742,37200],
[20979, 0, 67878, 34560,42780],
[ 0, 27279, 88245, 44919,50220],
[ 0, 78324, 153852, 47556,53940],
[ 0, 590740,1160381,358663,59520],
[ 0, 767962,1508496,466262,65100],
[ 0,1151943,2262744,699394,70680],
[0,0,0,0,0]
];
// 斥候
var cost_bg_sek=[
[ 1638, 995, 0, 3218, 6600],
[ 3276, 1989, 0, 6435, 8910],
[ 6224, 3779, 0, 12227,11220],
[ 0, 6802, 11204, 22008,13200],
[ 0,11564, 19047, 37413,15180],
[ 0,18502, 30475, 59861,17820],
[27754, 0, 45712, 89791,19140],
[38855, 0, 63997,125708,21120],
[50512, 0, 83916,163420,23100],
[65665, 0,108154,212446,25080],
[0,0,0,0,0]
];
// 斥候騎兵
var cost_bg_sekuma=[
[ 9180,15120, 29700, 0,18600],
[ 6156,10134, 19908, 0,25110],
[ 7830, 0, 25344, 12900,31620],
[ 8952, 0, 28962, 14742,37200],
[ 20979, 0, 67878, 34560,42780],
[ 0,27279, 88245, 44919,50220],
[ 0,78324,153852, 47556,53940],
[ 53135, 0, 87517,171908,43200],
[ 69076, 0,113772,223480,47250],
[104304, 0,171795,337455,51300],
[0,0,0,0,0]
];
// 衝車
var cost_bg_kuruma=[
[ 5940, 1836, 3024,0,17000],
[ 11880, 3672, 6048,0,22950],
[ 21384, 6610, 10886,0,28900],
[ 36353, 11236, 10886,0,34000],
[ 58164, 17978, 29611,0,39100],
[ 87247, 26967, 44417,0,45900],
[122145, 37754, 62183,0,49300],
[164896, 50968, 83947,0,54400],
[214365, 66258,109131,0,59500],
[ 63561,198334,326634,0,64600],
[0,0,0,0,0]
];
// 投石機
var cost_bg_stone=[
[ 9945, 32175, 16380,0,24000],
[ 19890, 64350, 32760,0,32400],
[ 37791, 122265, 62244,0,40800],
[ 68024, 220077, 112039,0,48000],
[115640, 374131, 190467,0,55200],
[185025, 598609, 304747,0,64800],
[277537, 897914, 457120,0,69600],
[388552,1257080, 639968,0,76800],
[505118,1634204, 831958,0,84000],
[656653,2124465,1081546,0,91200],
[0,0,0,0,0]
];
// 大剣兵
var cost_bg_bigken=[
[0,0,0,0,0], // Lv1
[0,0,0,0,0], // Lv2
[0,0,0,0,0], // Lv3
[0,0,0,0,0], // Lv4
[0,0,0,0,0], // Lv5
[0,0,0,0,0], // Lv6
[0,0,0,0,0], // Lv7
[0,0,0,0,0], // Lv8
[0,0,0,0,0], // Lv9
[0,0,0,0,0], // Lv10
[0,0,0,0,0]
];
// 盾兵
var cost_bg_shield=[
[0,0,0,0,0], // Lv1
[0,0,0,0,0], // Lv2
[0,0,0,0,0], // Lv3
[0,0,0,0,0], // Lv4
[0,0,0,0,0], // Lv5
[0,0,0,0,0], // Lv6
[0,0,0,0,0], // Lv7
[0,0,0,0,0], // Lv8
[0,0,0,0,0], // Lv9
[0,0,0,0,0], // Lv10
[0,0,0,0,0]
];
// 重盾兵
var cost_bg_bigshield=[
[0,0,0,0,0], // Lv1
[0,0,0,0,0], // Lv2
[0,0,0,0,0], // Lv3
[0,0,0,0,0], // Lv4
[0,0,0,0,0], // Lv5
[0,0,0,0,0], // Lv6
[0,0,0,0,0], // Lv7
[0,0,0,0,0], // Lv8
[0,0,0,0,0], // Lv9
[0,0,0,0,0], // Lv10
[0,0,0,0,0]
];
var costs = [];
costs["鍛冶場剣兵"] = cost_bk_ken;
costs["鍛冶場槍兵"] = cost_bk_yari;
costs["鍛冶場矛槍兵"] = cost_bk_hoko;
costs["鍛冶場弓兵"] = cost_bk_yumi;
costs["鍛冶場弩兵"] = cost_bk_dokyu;
costs["鍛冶場騎兵"] = cost_bk_uma;
costs["鍛冶場近衛騎兵"] = cost_bk_konoe;
costs["鍛冶場衝車"] = cost_bk_kuruma;
costs["鍛冶場投石機"] = cost_bk_stone;
costs["鍛冶場大剣兵"] = cost_bk_bigken; // 2014.02.19
costs["鍛冶場盾兵"] = cost_bk_shield; // 2014.02.19
costs["鍛冶場重盾兵"] = cost_bk_bigshield; // 2014.02.19
costs["防具工場剣兵"] = cost_bg_ken;
costs["防具工場槍兵"] = cost_bg_yari;
costs["防具工場矛槍兵"] = cost_bg_hoko;
costs["防具工場弓兵"] = cost_bg_yumi;
costs["防具工場弩兵"] = cost_bg_dokyu;
costs["防具工場騎兵"] = cost_bg_uma;
costs["防具工場近衛騎兵"] = cost_bg_konoe;
costs["防具工場斥候"] = cost_bg_sek;
costs["防具工場斥候騎兵"] = cost_bg_sekuma;
costs["防具工場衝車"] = cost_bg_kuruma;
costs["防具工場投石機"] = cost_bg_stone;
costs["防具工場大剣兵"] = cost_bg_bigken; // 2014.02.19
costs["防具工場盾兵"] = cost_bg_shield; // 2014.02.19
costs["防具工場重盾兵"] = cost_bg_bigshield; // 2014.02.19
var make_loop = function(loop) {
if (loop == 2) {
return;
} else {
if (loop == 0) { var type = "鍛冶場"; }
if (loop == 1) { var type = "防具工場"; }
if (OPT_BKBG_CHK == 0) { return; }
var UnitID = [];
UnitID["剣兵"] = [301];
UnitID["槍兵"] = [303];
UnitID["矛槍兵"] = [304];
UnitID["騎兵"] = [305];
UnitID["近衛騎兵"] = [307];
UnitID["弓兵"] = [308];
UnitID["弩兵"] = [309];
UnitID["斥候"] = [310];
UnitID["斥候騎兵"] = [311];
UnitID["衝車"] = [312];
UnitID["投石機"] = [313];
UnitID["大剣兵"] = [315];
UnitID["盾兵"] = [316];
UnitID["重盾兵"] = [317];
var _x = -1;
var _y = -1;
var _lv = -1;
var area = new Array();
area = get_area();
for (var i=0;i<area.length;i++){
if (area[i].name == type) {
var Temp = area[i].xy.split(",");
_x = Temp[0];
_y = Temp[1];
_lv = area[i].lv;
}
}
if ( _x < 0 ) {
return;
}
var tid=setTimeout(function(){
var mURL = FACLINK;
mURL = mURL.replace(URL_SITE,HOST);
mURL = mURL.replace(URL_X,_x);
mURL = mURL.replace(URL_Y,_y);
GM_xmlhttpRequest({
method:"GET",
url: mURL,
headers:{"Content-type":"text/html"},
overrideMimeType:'text/html; charset=utf-8',
onload:function(x){
var htmldoc = document.createElement("html");
htmldoc.innerHTML = x.responseText;
// 鍛冶場・防具工場情報の取得
getTrainingSoldier(htmldoc);
if ( getStayMode() ) {
closeIniBilderBox()
openIniBilderBox()
}
var actionsElem = document.evaluate('//th[@class="mainTtl6"]', htmldoc, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
// var actionsElem2 = document.evaluate('//b[@class="f14"]', htmldoc, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
var actionsElem2 = document.evaluate('//b[contains(@class,"f14")]', htmldoc, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
var actionsElem3 = document.evaluate('//td[@class="center"]' ,htmldoc, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
var actionsElem4 = document.evaluate('//td[@class="cost"]' ,htmldoc, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
var htmldoc2 = document.createElement("html");
var actionsElem7 = document.evaluate('//*[@colspan="4"]', htmldoc, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
var Buki = Array();
var x = -1;
if ( htmldoc.innerHTML.lastIndexOf("を強化する") != -1 ) {
for (var i=0;i<actionsElem2.snapshotLength;i++){
// htmldoc2.innerHTML = actionsElem4.snapshotItem(i).innerHTML;
// var actionsElem5 = document.evaluate('//span[@class="normal"]' ,htmldoc2, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
// var actionsElem6 = document.evaluate('//span[@class="max90"]' ,htmldoc2, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
var BG_Name = actionsElem.snapshotItem(i+1).innerHTML;
var BG_LvNm = actionsElem2.snapshotItem(i).innerHTML.substring(actionsElem2.snapshotItem(i).innerHTML.lastIndexOf("&nbsp;&nbsp;")+12);
var BG_UID = UnitID[BG_Name];
var BG_Lv = actionsElem2.snapshotItem(i).innerHTML.substring(3,actionsElem2.snapshotItem(i).innerHTML.lastIndexOf("&nbsp;")-6);
var BG_WOOD = costs[type + BG_Name][BG_Lv][0];
var BG_STONE = costs[type + BG_Name][BG_Lv][1];
var BG_IRON = costs[type + BG_Name][BG_Lv][2];
var BG_RICE = costs[type + BG_Name][BG_Lv][3];
var BG_TIME = costs[type + BG_Name][BG_Lv][4];
var BG_Go = (actionsElem3.snapshotItem(i+1).innerHTML.lastIndexOf("を強化する") != -1);
/*
if (BG_Lv != 10) {
var BG_WOOD = actionsElem5.snapshotItem(0).innerHTML;
var BG_STONE = actionsElem5.snapshotItem(1).innerHTML;
var BG_IRON = actionsElem6.snapshotItem(0).innerHTML;
var BG_RICE = actionsElem5.snapshotItem(2).innerHTML;
var BG_TIME = actionsElem7.snapshotItem(i).innerHTML;
var BG_Go = (actionsElem3.snapshotItem(i+1).innerHTML.lastIndexOf("を強化する") != -1);
} else {
var BG_WOOD = 0;
var BG_STONE = 0;
var BG_IRON = 0;
var BG_RICE = 0;
var BG_TIME = 0;
var BG_Go = false;
}
*/
if (type == "鍛冶場") {
var BG_GoLv = OPT_BK_LV[ ( UnitID[actionsElem.snapshotItem(i+1).innerHTML][0] - 300 ) ];
} else {
var BG_GoLv = OPT_BG_LV[ ( UnitID[actionsElem.snapshotItem(i+1).innerHTML][0] - 300 ) ];
}
if ( checkBKLvup(BG_WOOD,BG_STONE,BG_IRON,BG_RICE,BG_Go,BG_Lv,BG_GoLv) ){
x++;
Buki[x] = [BG_Name,BG_Lv,BG_LvNm,BG_UID,BG_TIME];
}
}
Buki.sort( function(a, b) { if (a[4] > b[4]) return 1; if (a[4] < b[4]) return -1; return 0;});
if (x != -1) {
// 武器強化処理
var c={};
c['x'] = parseInt(_x);
c['y'] = parseInt(_y);
c['unit_id'] = parseInt(Buki[0][3]);
j$.post("http://"+HOST+"/facility/facility.php?x=" + parseInt(_x) + "&y=" + parseInt(_y) + "#ptop",c,function(){});
// var tid=setTimeout(function(){location.reload(false);},0);
}
}
make_loop(loop + 1);
function checkBKLvup(hwood,hstone,hiron,hrice,hgo,hnlv,hslv) {
var wood = parseInt( $("wood").innerHTML, 10 );
var stone = parseInt( $("stone").innerHTML, 10 );
var iron = parseInt( $("iron").innerHTML, 10 );
var rice = parseInt( $("rice").innerHTML, 10 );
// var temp = (parseInt(hwood) + 99);
if (parseInt(hnlv) >= parseInt(hslv)) { return false; }
if ((parseInt(hwood) + OPT_BLD_WOOD ) > wood ) { return false; }
if ((parseInt(hstone) + OPT_BLD_STONE) > stone) { return false; }
if ((parseInt(hiron) + OPT_BLD_IRON ) > iron ) { return false; }
if ((parseInt(hrice) + OPT_BLD_RICE ) > rice ) { return false; }
if (hgo == false) { return false; }
return true;
}
}
});
},0);
}
}
make_loop(0);
}
function setVillageFacility() {
debugLog("=== Start setVillageFacility ===");
var cnt=0;
var vID = "";
var del=0;
var delX = 0;
var delY = 0;
//座標を取得
var xyElem = document.evaluate('//*[@id="basepoint"]/span[@class="xy"]', document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
vId = trim(xyElem.snapshotItem(0).innerHTML.match(/(\(-?\d+,-?\d+\))/)[1]); // 2014.08.20
//建設情報を取得
var actionsElem = document.evaluate('//*[@id="actionLog"]/ul/li', document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
// 削除施設情報の取得
for (var i = 0; i < actionsElem.snapshotLength; i++) {
var paItem = actionsElem.snapshotItem(i);
//ステータス
var buildStatusElem = document.evaluate('./span[@class="buildStatus"]/a', paItem, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
if (buildStatusElem.snapshotLength > 0) {
//施設建設数
cnt++;
// 削除数カウント
if( buildStatusElem.snapshotItem(0).parentNode.parentNode.textContent.indexOf("削除") >= 0 ){
if(buildStatusElem.snapshotItem(0).href.match(/.*\/.*(\d+).*(\d+)/)){
delX = parseInt(RegExp.$1);
delY = parseInt(RegExp.$2);
}
del++;
}
}
}
for (var i = 0; i < actionsElem.snapshotLength; i++) {
var paItem = actionsElem.snapshotItem(i);
//ステータス
var buildStatusElem = document.evaluate('./span[@class="buildStatus"]/a', paItem, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
if (buildStatusElem.snapshotLength > 0) {
//建物削除等に対応 2010.10.25 byおぜがづ
for(var j=0; j<buildStatusElem.snapshotLength;j++){
if(buildStatusElem.snapshotItem(j).parentNode.innerHTML.match(RegExp("(建設中|建設準備中)"))) {
//施設建設数
cnt++;
}
}
//施設建設数
//cnt++;
}
}
Load_OPT(vId); //LvUP対象の取得
//建設予約ができるかどうか
if((cnt - del) >= 1) return;
// 糧村化
if(OPT_KATEMURA == 1) {
var area_all = new Array();
area_all = get_area_all();
var hatake = 0; //畑の総数
var souko = 0; //倉庫の総数
var suzume = 0; //雀の総数
var heichi = 0; //平地の総数
var suzume_Flag = 0;
var n = -1;
for(var i=0;i < area_all.length;i++){
if(area_all[i].name == "平地"){heichi++;n=i;}
else if(area_all[i].name.match(/\s.*?(\d+)/)){hatake++;if(parseInt(RegExp.$1)>=5){suzume_Flag=1;}}
else if(area_all[i].name.match(/倉庫/)){souko++;}
else if(area_all[i].name.match(/銅雀台/)){suzume++;}
}
if(heichi>0){ //平地が余っていたら
var tmp = heichi;
if (WangRay != true) {
if(suzume != 1){ // 雀がまだ建っていなければ
tmp -= 1; // 平地の数をマイナス1
}
}
if(souko < OPT_SOUKO_MAX){ // 倉庫がまだ最大数建っていなければ
tmp -= (OPT_SOUKO_MAX - souko); // 平地の数をマイナス
}
if(tmp > 0){ //それでも平地が余っていれば
if(Chek_Sigen(new lv_sort("",0,"")) != 1){ // 資源チェック
createFacility(HATAKE, area_all); // 畑を建てる
Reload_Flg = 0;
return;
};
} else if(souko < OPT_SOUKO_MAX){ //倉庫が建てられる平地があれば
if(Chek_Sigen(new lv_sort("倉庫",0,"")) != 1){ //資源チェック
createFacility(SOUKO, area_all); //倉庫を建てる
Reload_Flg = 0;
return;
}
} else if(suzume != 1 && suzume_Flag == 1){ //雀がまだ建っていなければ
if (WangRay != true) {
if(Chek_Sigen(new lv_sort("銅雀台",0,"")) != 1){ //資源チェック
createFacility(SUZUME, area_all); //雀を建てる
Reload_Flg = 0;
return;
}
}
}
}
//建てられるスペースがなければ通常の処理を続ける
}
var area = new Array();
area = get_area();
area.sort(cmp_areas);
area.sort(cmp_lv);
Reload_Flg = 0;
// 拠点の状況を調査(削除中なら処理しない)
j$.get("http://"+HOST+"/facility/facility.php?x=3&y=3#ptop",function(x){
var htmldoc = document.createElement("html");
htmldoc.innerHTML = x;
var rmtime = htmldoc.innerHTML.match(/(村を削除中です。|砦を削除中です。)[^\d]*(\d+-\d+-\d+ \d+:\d+:\d+)に完了します。/);
if (rmtime) {
// 削除中のため何もしない
return;
}
for(i=0;i<area.length;i++){
var tmpName1 = area[i].name;
switch (tmpName1) {
case "":
case "":
case "":
tmpName1 = "拠点"; //
chkFlg = 1;
break;
}
if(parseInt(area[i].lv) >= parseInt(OPT_CHKBOXLV[OPT_FNID[tmpName1]])){
continue;
} //指定Lv以上ならメインに戻る
//建築物名分回す
OPT_FUC_NAME.push("","","");
if(OPT_CHKBOX[0] == 1) {
OPT_CHKBOX.push(1,1,1);
OPT_CHKBOXLV.push(OPT_CHKBOXLV[0],OPT_CHKBOXLV[0],OPT_CHKBOXLV[0]);
} else {
OPT_CHKBOX.push(0,0,0);
OPT_CHKBOXLV.push(0,0,0);
}
OPT_CHKBOX.push
for(var ii=0;ii<OPT_FUC_NAME.length;ii++){
//ソートしたLvの低い順に比較する
if(area[i].name == OPT_FUC_NAME[ii]){
//建築指示が有るか確認する。
if(parseInt(OPT_CHKBOX[ii]) == 1){
if(parseInt(area[i].lv) >= parseInt(OPT_CHKBOXLV[ii])){
break;
}
//建築に必要な資源が有るかどうかチェック
var ret = Chek_Sigen(area[i]);
if(ret == 1){
//30分後にリロードするかどうか
Reload_Flg = 1;
break;
}
var Temp = area[i].xy.split(",");
var c = {};
if( (del != 0) && (parseInt(Temp[0]) == delX) && (parseInt(Temp[1]) == delY) ){
// 削除施設とレベルアップ施設が一致したらスキップ
continue;
}
// 拠点以外のレベルアップ処理
c['x']=parseInt(Temp[0]);
c['y']=parseInt(Temp[1]);
c['village_id']=getVillageID(vId);
c['ssid']=j$.cookie('SSID');
j$.post("http://"+HOST+"/facility/build.php",c,function(){});
var tid=setTimeout(function(){location.reload(false);},INTERVAL);
GM_setValue(HOST+PGNAME+"OPT_BUILD_VID" , getVillageID(vId) );
var nowTime = new Date();
Reload_Flg = 0;
return;
}
}
}
}
});
if(Reload_Flg == 1){
//10分後にリロードし、再度建築できるかチェックする。
var tid=setTimeout(function(){location.reload();},60000);
}
}
// 2011.09.06 宿舎(畑) 自動ビルド&スクラッチ
function setVillageFacility2() {
var cnt=0;
var del=0;
var delX = 0;
var delY = 0;
var vID = "";
//座標を取得
var xyElem = document.evaluate('//*[@id="basepoint"]/span[@class="xy"]',
document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
vId = trim(xyElem.snapshotItem(0).innerHTML.match(/(\(-?\d+,-?\d+\))/)[1]); // 2014.08.20
//建設情報を取得
var actionsElem = document.evaluate('//*[@id="actionLog"]/ul/li',
document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
for (var i = 0; i < actionsElem.snapshotLength; i++) {
var paItem = actionsElem.snapshotItem(i);
//ステータス
var buildStatusElem = document.evaluate('./span[@class="buildStatus"]/a',
paItem, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
if (buildStatusElem.snapshotLength > 0) {
//施設建設数
cnt++;
// 削除数カウント
if( buildStatusElem.snapshotItem(0).parentNode.parentNode.textContent.indexOf("削除") >= 0 ){
if(buildStatusElem.snapshotItem(0).href.match(/.*\/.*(\d+).*(\d+)/)){
delX = parseInt(RegExp.$1);
delY = parseInt(RegExp.$2);
}
del++;
}
}
}
var results = document.evaluate('//area', document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
var area = new Array();
for(var i=0,n=0; i<results.snapshotLength; i++){
if(results.snapshotItem(i).alt.match(/(.*?)\s.*?(\d+)/)){
strURL = results.snapshotItem(i).href;
area[n] = new lv_sort(RegExp.$1,RegExp.$2,getURLxy(strURL));
n++;
}
else if(results.snapshotItem(i).alt == "平地"){
// 平地の座標を拾う
strURL = results.snapshotItem(i).href;
area[n] = new lv_sort("平地",0,getURLxy(strURL));
n++;
}
}
if( OPT_SorH == "DD" ){
//宿舎が処理対象の場合、エリアリストに練兵所(宿舎建設条件)があるかをチェック
var cntv = 0;
for(var i=0;i<area.length;i++){
if(area[i].name == "練兵所"){
cntv++;
break;
}
}
if(cntv == 0) return;
}
// 施設情報のレベルソート
area.sort(cmp_lv2);
Load_OPT(vId); //LvUP対象の取得
// 削除中かチェック
if( (del == 0) ){
// 削除中でなければ、削除できる施設があるか調べる @@
var TargetName = "";
if (OPT_SorH == "DD") { TargetName = "宿舎"; }
if (OPT_SorH == "HH") { TargetName = ""; }
var TargetCount = 0;
var BlankCount = 0;
// 対象レベル以下の宿舎(畑)と平地の数をカウントする
for (i=0;i<area.length;i++){
if (area[i].name == TargetName && parseInt(area[i].lv) <= OPT_MAXLV) { TargetCount += 1; }
if (area[i].name == "平地") { TargetCount += 1; }
}
if (TargetCount < OPT_MAX){
// 対象となる宿舎(畑)と平地の合計が指定数に満たない場合
area.sort(cmp_lv);
for (i=0;i<area.length;i++){
if ((area[i].name == TargetName) && (parseInt(area[i].lv) >= OPT_MAXLV)) {
// 削除
var Temp = area[i].xy.split(",");
DeleteFacility(Temp[0],Temp[1]);
JSSleep(2);
Reload_Flg = 0;
return;
}
}
} else {
// 普通に削除処理を実行
for (i=0;i<area.length;i++){
if ((area[i].name == TargetName) && (parseInt(area[i].lv) == OPT_MAXLV)) {
// 削除
var Temp = area[i].xy.split(",");
DeleteFacility(Temp[0],Temp[1]);
JSSleep(2);
Reload_Flg = 0;
return;
}
}
}
}
area.sort(cmp_lv2);
//建設予約ができるかどうか
if((cnt - del) >= 1) return;
//if(cnt == 2) return;
// 平地建設条件がある場合、対象施設数がOPT_MAX以上かチェックする
var yct = 0;
if( OPT_SorH == "DD" ){
for(i=0;i<area.length;i++){
if(area[i].name == "宿舎"){
// @@ Lv6以下の数だけを数える 2011.06.22 5zen
if(area[i].lv < (OPT_MAXLV + 1)){
yct++;
}
}
}
}
if( OPT_SorH == "HH" ){
for(i=0;i<area.length;i++){
if(area[i].name == ""){
// @@ Lv6以下の数だけを数える 2011.06.22 5zen
if(area[i].lv < (OPT_MAXLV + 1)){
yct++;
}
}
}
}
Reload_Flg = 0;
for(i=0;i<area.length;i++){
if( OPT_SorH == "DD" ){
if((area[i].name != "宿舎") && (area[i].name != "平地")){
// 平地と宿舎以外スキップ
continue;
}
}
else if( OPT_SorH == "HH" ){
if((area[i].name != "") && (area[i].name != "平地")){
// 平地と畑以外スキップ
continue;
}
}
if( yct >= OPT_MAX ){
if( OPT_SorH == "DD" ){
if(area[i].name != "宿舎"){
// 宿数がすでにOPT_MAX以上なら、平地は無視
continue;
}
}
if( OPT_SorH == "HH" ){
if(area[i].name != ""){
// 畑数がすでにOPT_MAX以上なら、平地は無視
continue;
}
}
}
// if(parseInt(area[i].lv) >= OPT_MAXLV){break;} //指定Lv以上ならメインに戻る
//建築物名分回す
for(var ii=0;ii<OPT_FUC_NAME.length;ii++){
//ソートしたLvの低い順に比較する
if(area[i].name == OPT_FUC_NAME[ii]){
//建築に必要な資源が有るかどうかチェック
var ret = Chek_Sigen(area[i]);
if(ret == 1){
//30分後にリロードするかどうか
Reload_Flg = 1;
break;
}
var Temp = area[i].xy.split(",");
var c={};
if( (del != 0) && (parseInt(Temp[0]) == delX) && (parseInt(Temp[1]) == delY) ){
// 削除施設とレベルアップ施設が一致したらスキップ
continue;
}
// add 2011.12.14
if (area[i].lv > (OPT_MAXLV - 1)) {
continue;
}
if( area[i].name != "平地"){
c['x']=parseInt(Temp[0]);
c['y']=parseInt(Temp[1]);
c['village_id']=getVillageID(vId);
c['ssid']=j$.cookie('SSID');
j$.post("http://"+HOST+"/facility/build.php",c,function(){});
var tid=setTimeout(function(){location.reload(false);},INTERVAL);
} else {
if( OPT_SorH == "DD" ){
c['x']=parseInt(Temp[0]);
c['y']=parseInt(Temp[1]);
c['id']=SYUKUSYA;
c['village_id']=getVillageID(vId);
c['ssid']=j$.cookie('SSID');
j$.post("http://"+HOST+"/facility/build.php",c,function(){});
var tid=setTimeout(function(){location.reload(false);},INTERVAL);
} else {
c['x']=parseInt(Temp[0]);
c['y']=parseInt(Temp[1]);
c['id']=215;
c['village_id']=getVillageID(vId);
c['ssid']=j$.cookie('SSID');
j$.post("http://"+HOST+"/facility/build.php",c,function(){});
var tid=setTimeout(function(){location.reload(false);},INTERVAL);
}
}
GM_setValue(HOST+PGNAME+"OPT_BUILD_VID" , getVillageID(vId) );
Reload_Flg = 0;
return;
}
}
}
if(Reload_Flg == 1){
//30分後にリロードし、再度建築できるかチェックする。
var tid=setTimeout(function(){location.reload();},1800000);
}
return;
}
//////////////////////////////////////////////////////////////////////////////////////////
//施設一覧取得
function get_area(){
var results = document.evaluate('//area', document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
var area = new Array();
for(var i=0,n=0; i<results.snapshotLength; i++){
if(results.snapshotItem(i).alt.match(/(.*?)\s.*?(\d+)/)){
var strURL = results.snapshotItem(i).href;
area[n] = new lv_sort(RegExp.$1,RegExp.$2,getURLxy(strURL));
n++;
}
}
return area;
}
function get_area_all(){
var results = document.evaluate('//area', document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
var area = new Array();
for(var i=0,n=0; i<results.snapshotLength; i++){
var strURL = results.snapshotItem(i).href;
area[n] = new areas(results.snapshotItem(i).alt,getURLxy(strURL));
n++;
}
return area;
}
//施設建設
function createFacility(f, area){
area.sort(cmp_areas);
for(var i=0;i<area.length;i++){
if(area[i].name == "平地"){ //一番最初に見つかった平地に建設
var Temp = area[i].xy.split(",");
/*
var mURL = CREATELINK;
mURL = mURL.replace(URL_SITE,HOST);
mURL = mURL.replace(URL_X,Temp[0]);
mURL = mURL.replace(URL_Y,Temp[1]);
mURL = mURL.replace(URL_viID,getVillageID(vId));
mURL = mURL.replace(URL_fID,f);
mURL = mURL.replace(URL_viSSID,j$.cookie('SSID')); // 2012.04.24 ssid 追加
var tid=setTimeout(function(){location.href = mURL;},INTERVAL);
*/
var c = {};
c['x']=parseInt(Temp[0]);
c['y']=parseInt(Temp[1]);
c['village_id']=getVillageID(vId);
c['id']=f;
c['ssid']=j$.cookie('SSID');
j$.post("http://"+HOST+"/facility/build.php",c,function(){});
var tid=setTimeout(function(){location.reload(false);},INTERVAL);
return;
}
}
}
function areas(name,xy){
this.name = name;
this.xy = xy;
}
//比較する関数
function cmp_areas(a,b){
if(a.xy > b.xy){return 1;} else {return -1;}
}
// 次拠点移動
function forwardNextVillage(){
// 巡回停止中ならスキップ 2012.01.24
if (GM_getValue(HOST+PGNAME+"AutoFlg", true) == false) { return; }
var nowTime = new Date();
var nextTime = getNextTime(location.hostname, nowTime);
var waitTime = nextTime - nowTime;
var roundTime = 0;
// @@ add 2011.10.04 @@
if (tidMain2 != undefined) { clearInterval(tidMain2); }
if ((ShopFlg == true) && (ShopURL != "")) {
roundTime = 10 * 1000;
tidMain2=setTimeout(function(){location.href = ShopURL;},roundTime);
}
// 建築済みで次建築がセットされていない未巡回の拠点への移動(2拠点同時に完了した場合に使う処理)
var villages = loadVillages(location.hostname + PGNAME);
for (var i = 0; i < villages.length; i++) {
var actions = sortAction(villages[i][IDX_ACTIONS]);
var nowTime = new Date();
for (var j = 0; j < actions.length; j++) {
var actionDiv = createActionDiv(actions[j], nowTime, villages[i][IDX_XY], location.hostname);
if (!actionDiv) continue;
var actionTime = new Date(actions[j][IDX2_TIME]);
var moveFlg = 0;
if ( actionTime < nowTime && actions[j][IDX2_ROTATION] == 0 && actions[j][IDX2_TYPE] == TYPE_CONSTRUCTION){
for (var x = j + 1; x < actions.length; x++){
actionTime = new Date(actions[x][IDX2_TIME]);
if ( actionTime > nowTime && actions[x][IDX2_ROTATION] == 0 && actions[x][IDX2_TYPE] == TYPE_CONSTRUCTION){
moveFlg = 1;
break;
}
}
if ( !(x < actions.length) ) {
actions[j][IDX2_ROTATION] = 1;
}
if (moveFlg == 0) {
var data = new Array();
data[IDX_BASE_NAME] = villages[i][IDX_BASE_NAME];
data[IDX_XY] = villages[i][IDX_XY];
data[IDX_ACTIONS] = actions;
if (location.pathname == "/village.php") {
var vcURL = villages[i][IDX_URL];
if(vcURL!=undefined){
saveVillages(HOST+PGNAME, villages);
roundTime = 5 * 1000;
tidMain2=setTimeout(function(){location.href = vcURL;},roundTime);
}
}
}
}
}
}
if ( tidMain2 == undefined ) {
//一番早い作業完了時刻を取得
var startTime = new Date("2099/12/31 23:59:59");
var nextTime = startTime;
var baseTime = new Date();
nextURL = "";
// 次回建設終了予定の検索
for (var i = 0; i < villages.length; i++) {
var actions = villages[i][IDX_ACTIONS];
for (var j = 0; j < actions.length; j++) {
var actionTime = new Date(actions[j][IDX2_TIME]);
if (actionTime > baseTime && actionTime < nextTime && actions[j][IDX2_TYPE] == TYPE_CONSTRUCTION) {
var type = actions[j][IDX2_TYPE].charAt(0);
nextTime = actionTime;
nextURL = villages[i][IDX_URL];
nextNAME = villages[i][IDX_BASE_NAME];
}
}
}
var nTime = (nextTime - nowTime);
var vcURL = nextVillageURL(getVillageID(vId));
if(vcURL!=undefined){
if (nextURL == "") {
// 次回建築完了予定がない場合は通常巡回処理
roundTime = parseInt(OPT_ROUND_TIME1) * 1000;
tidMain2=setTimeout(function(){location.href = vcURL;},roundTime);
} else {
if (parseInt(OPT_ROUND_TIME1) * 1000 > nTime) {
// 巡回時間より前に建築が終わる拠点がある場合
// 2011.12.06 即時変更をやめて10秒後に修正
// tidMain2=setTimeout(function(){location.href = nextURL;},(nextTime - nowTime));
// tidMain2=setTimeout(function(){location.href = nextURL;},10 * 1000);
roundTime = (nextTime - nowTime + 10000);
tidMain2=setTimeout(function(){location.href = nextURL;},roundTime);
} else {
// 通常巡回処理
roundTime = parseInt(OPT_ROUND_TIME1) * 1000;
tidMain2=setTimeout(function(){location.href = vcURL;},roundTime);
}
}
}
}
debugLog("nTime:" + nTime / 1000 + "sec RoundTime:" + (roundTime / 1000) + "sec forwardNextVillage:" + vcURL + " " + roundTime);
}
//比較する関数
function cmp_time(a,b){
if(a.xy > b.xy){return 1;} else {return -1;}
}
// 次拠点URL取得
function nextVillageURL(vId2){
var villages = loadVillages(HOST+PGNAME);
var nextIndex = 0;
var chkNextVID = new Array();
for(var i=0; i<villages.length;i++){
var tChk1 = GM_getValue(HOST+PGNAME+"OPT_CHKBOX_AVC_"+i, true);
if(tChk1==true){
chkNextVID.push(villages[i][IDX_URL]);
}
}
// 現在の拠点のインデックスを検索 2012.01.24 逆順処理追加
for(var i=0; i<chkNextVID.length;i++){
var url = chkNextVID[i];
if(vId2 == getParameter2(chkNextVID[i], "village_id")){
if (getReverseMode() == false) {
// 正巡回
if(i+1 < chkNextVID.length){
nextIndex = i+1;
}else{
nextIndex = 0;
}
} else {
// 逆巡回
if(i-1 < 0){
nextIndex = chkNextVID.length-1;
} else {
nextIndex = i-1;
}
}
break;
}
}
return chkNextVID[nextIndex];
}
// URLパラメタ取得
function getParameter2(url, key) {
var str = url.split("?");
if (str.length < 2) {
return "";
}
var params = str[1].split("&");
for (var i = 0; i < params.length; i++) {
var keyVal = params[i].split("=");
if (keyVal[0] == key && keyVal.length == 2) {
return decodeURIComponent(keyVal[1]);
}
}
return "";
}
//建築物の格納用
function lv_sort(name,lv,xy){
this.name = name;
this.lv = lv;
this.xy = xy;
}
//比較する関数
function cmp_lv(a,b){
return a.lv - b.lv;
}
function cmp_lv2(a,b){
return b.lv - a.lv;
}
//拠点IDの取得
function getVillageID(vId){
//villages
var villages = loadVillages(HOST+PGNAME);
for(var i=0; i<villages.length;i++){
if(villages[i][IDX_XY] == vId){
var vURL = villages[i][IDX_URL];
var temp = vURL.split("?");
var temp2 = temp[1].split("=");
return temp2[1];
}
}
}
function getURLxy(strURL){
if(strURL == ""){ return "";}
var strTemp = "";
strTemp = strURL;
var Temp = strTemp.split("?");
var Temp2 = Temp[1].split("&");
var Temp3 = Temp2[0].split("=");
var Temp4 = Temp2[1].split("=");
var Temp5 = Temp4[1].split("#"); // 2013.12.18
return Temp3[1] + "," +Temp5[0]; // 2013.12.18
}
//リンクHTML追加
function addOpenLinkHtml() {
if (location.hostname[0] == "s" || location.hostname[0] == "h" || location.hostname[0] == "p") {
// var sidebar = d.evaluate('//*[@class="copyright"]',d, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
var sidebar = d.evaluate('//*[@class="sideBoxHead"]/h3/strong',d, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
} else {
var sidebar = d.evaluate('//a[@title="拠点"]',d, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
}
if (sidebar.snapshotLength == 0){
sidebar = d.evaluate('//*[@class="xy"]',d