「シム/オブジェクト」の編集履歴(バックアップ)一覧はこちら
「シム/オブジェクト」(2012/11/05 (月) 20:56:38) の最新版変更点
追加された行は緑色になります。
削除された行は赤色になります。
#javascript(){{
<script language="JavaScript"><!--
//////////////////////////////////////////////////
function num(arg){
if (isNaN(arg)) return 0;
return arg-0;
}
function _debug(msg,lbl){
// return;
dbg = $('#debugmsg');
if(!dbg.length){
$('body').append('<div id="debugmsg" style="display:none;"></div>');
dbg = $('#debugmsg');
}
if(dbg) dbg.html(dbg.html()+(lbl?'['+lbl+'] '+msg:msg)+"<br />\n");
if (lbl) console.log('['+lbl+'] '+msg);
if ('object' ==typeof msg) console.dir(msg);
}
//////////////////////////////////////////////////
function to_local_key(key){
var ret = '';
switch(key){
// スロットに保存しないキーを列挙
case 'slot':
case 'fs':
break;
default:
var t = $('#slot');
// var t = document.getElementById('slot');
if (t && t.length){
ret = t.val();
if ('0'==ret) ret = '';
}
}
ret = ret?ret+'/'+key:key;
return ret;
}
//////////////////////////////////////////////////
var local_data = {};
function save_local(name,value){
name = to_local_key(name);
// _debug(value,name);
if (undefined==value){
delete_local(name);
}
switch(true){
case $.browser.mozilla:
case $.browser.opera:
case $.browser.safari:
case $.browser.msie:
return localStorage.setItem(name,value);
break;
default:
return localStorage.setItem(name,value);
}
return null;
}
//////////////////////////////////////////////////
function load_local(name,defval){
name = to_local_key(name);
switch(true){
case $.browser.mozilla:
case $.browser.opera:
case $.browser.safari:
case $.browser.msie:
ret = localStorage.getItem(name);
break;
default:
ret = localStorage.getItem(name);
}
// _debug(ret,name);
if (ret) return ret;
return defval;
}
//////////////////////////////////////////////////
function delete_local(name){
name = to_local_key(name);
localStorage.removeItem(name);
}
//////////////////////////////////////////////////
function clear_local(){
localStorage.clear();
}
//////////////////////////////////////////////////
function keep_max(max,chk){
if(max && chk){
for(var i in max){
if (max[i] < chk[i]) max[i] = chk[i];
}
}
return max;
}
//////////////////////////////////////////////////
//////////////////////////////////////////////////
//////////////////////////////////////////////////
//////////////////////////////////////////////////
//////////////////////////////////////////////////
// スキルオブジェクト
var skls = {};
function CSkill(skcode){
if (!skcode) return ;
if (skls[skcode]) return skls[skcode];
var skl = skills[skcode];
if (!skl) return ;
skls[skcode] = this;
this.code = skcode;
this.name = skl[2];
}
function Skill(skcode){
if (!skcode) return null;
if (skls[skcode]) return skls[skcode];
var ins = new CSkill(skcode);
if (ins.code) return skls[skcode] = ins;
return null;
}
function getSkill(skcode){return Skill(skcode);}
function get_skill(skcode){return Skill(skcode);}
//////////////////////////////////////////////////
// ユニットクラスオブジェクト
function CJobclass(clcode,unit){
if (!clcode) return ;
if (jobs[clcode]) return jobs[clcode];
var cls = classes[clcode];
if (!cls) return ;
//////////////////////////////////////////////////
this.adj_params = function(type,adj){
var ret = null;
var prm = null;
switch(type){
case 'limit': prm = this.params.limit; break;
case 'buffer': prm = this.params.buffer; break;
case 'basic': prm = this.params.basic; break;
case 'enhance': prm = this.params.enhance; break;
}
if (prm){
ret = {};
for(var idx in prm){
ret[idx] = prm[idx] + num(adj[idx]);
}
}
return ret;
}
//////////////////////////////////////////////////
this.label = function(sex){
switch(this.code){
case 'C014': return 2==sex?'シスター':'僧侶';
case 'C119': if (2==sex) return 'バトルシスター'; // 女性の場合はバトルモンク→バトルシスターに修正
}
return this.name;
}
//////////////////////////////////////////////////
var label = classes['code'];
jobs[clcode] = this;
this.code = clcode;
this.type = cls[0];
this.name = cls[1];
this.maxLv = cls[2];
var key = '';
switch(this.type){
case 0: key = 'upperJobClasses'; break; // 下級職
case 1: key = 'lowerJobClasses'; break; // 上級職
case 2: // 特殊職
}
if (key){
this[key] = {};
if(cls[3] && cls[3].length){
ccd = cls[3];
this[key][ccd] = Jobclass(ccd);
}
if(cls[4] && cls[4].length){
ccd = cls[4];
this[key][ccd] = Jobclass(ccd);
}
}
this.sex = cls[5];
this.skills = {};
for(i=6;i<=7;i++){
if(cls[i] && cls[i].length){
skcode = cls[i];
this.skills[skcode] = Skill(skcode);
}
}
this.weapons = {};
var lst = label[8];
for(var idx in lst){
var v = lst[idx];
if (v) this.weapons[v] = cls[8][idx];
}
this.params = {limit:{},basic:{},buffer:{},enhance:{}};
var lst = label[9];
for(var idx in lst){
var v = lst[idx];
if (v){
this.params.limit[v] = cls[ 9][idx]; // 上限値
this.params.basic[v] = cls[10][idx]; // 最低パラメータ
this.params.buffer[v] = this.params.limit[v] - this.params.basic[v];
this.params.enhance[v] = cls[11][idx]; // ダブル時強化パラメータ
}
}
return this;
}
var jobs = {};
function Jobclass(clcode,unit){
if (!clcode) return ;
if (jobs[clcode]) return jobs[clcode];
var ins = new CJobclass(clcode);
if (ins.code) return jobs[clcode] = ins;
return null;
}
function getJobclass(clcode,unit){return Jobclass(clcode,unit);}
function get_jobclass(clcode,unit){return Jobclass(clcode,unit);}
//////////////////////////////////////////////////
// ユニットパラメータオブジェクト
function CParams(type,prm){
// _debug(typeof prm);
// _debug(prm);
var lst = ['hp','str','mgc','skl','spd','luk','def','mdf'];
var i = 0;
var sum = 0;
switch(type){
case 'adj': lst = ['str','mgc','skl','spd','luk','def','mdf']; break;
case 'init': lst = ['Lv','hp','str','mgc','skl','spd','luk','def','mdf','mov']; break;
default:
}
for(var idx in lst){
this[lst[idx]] = prm[idx];
sum += prm[idx];
}
switch(type){
case 'adj': this.sum = sum; break;
}
return this;
}
function Params(type,prm){return new CParams(type,prm);}
// var Unit_count=0;
//////////////////////////////////////////////////
// ユニットオブジェクト
function CUnit(code,spscode,vpcode){
// _debug('['+code+']'+spscode+':'+vpcode,'CUnit');
//////////////////////////////////////////////////
this.toString = function(){
return '[' + this.code + ']'
+ this.name;
}
//////////////////////////////////////////////////
this.toBoolean = function(){return this.code?true:false;}
this.valid = function(){
return this.code?true:false;
}
//////////////////////////////////////////////////
this.class = function(type){
var ret = '';
switch(type){
case 'sex': return this.sex==1?'male':'female'; break;
case 'gen': return this.gen==1?'gen1':'gen2'; break;
case 'fam': return this.children.fixed?'parent':'';
// case 'num': return 0==num(value)?' neutral ':(0<value?' positive ':' negative '); break;
// case 'cls':
// ret = value;
// var ini_cls = this.u.init_class;
// if (ini_cls && ini_cls.code==value) ret +=' ini';
//
// var key = 'acq/'+this.u.code+'/'+value;
// if (load_local(key)) ret +=' acquired';
// break;
case 'unit':
ret = this.code;
ret += ' '+this.class('sex',this);
ret += ' '+this.class('gen',this);
ret += ' '+this.class('fam',this);
}
return ret;
}
//////////////////////////////////////////////////
// 自由親を設定する
this.set_variable_parent = function(vpcode,vpvpcode){
if (1==this.gen) return null;
if (!vpcode) return null;
if (this.parents.variable && this.parents.variable.code==vpcode) return this;
this.parents.variable = null; // 自由親をリセット
var vp = Unit(vpcode);
if (!vp) return null;
var index = vpcode;
if (vpvpcode) index += '.'+vpvpcode;
// _debug('['+this.code+']'+vpcode+':'+vpvpcode,'set_variable_parent');
vp.set_variable_parent(vpvpcode); // 自由親に、自由祖父母を設定しておく
this.parents.variable = vp; // 一時的に自分の自由親を上書き
if (this.variations[index]) return this.variations[index]; // 既に設定済み(すぐに参照可能)
if (vp.valid()){
this.variations[vpcode] = {limit_adj:{},stuff_cls:{},skills:{}};
var p = this.variations[index]; // ポインタ
// 上限値補正継承
for(var idx in this.variations.init.limit_adj){
p.limit_adj[idx] = num(this.variations.init.limit_adj[idx]) + (vp.limit_adj[idx]);
}
// 習得可能スキルコピー
for(var idx in this.variations.init.skills){
p.skills[idx] = this.variations.init.skills[idx];
}
// 転職可能クラスコピー
for(var idx in this.stuff.class){ // 親の継承クラスのフラグを確認
p.stuff_cls[idx] = this.stuff.class[idx];
this.add_skill(2,idx,p.skills);
}
// 転職可能クラス継承
for(var idx in vp.stuff.inherit_flg){ // 親の継承クラスのフラグを確認
var flg = vp.stuff.inherit_flg[idx];
var inheritable = false;
switch(flg){
case -1: break; // マイナスは継承不可
case 1: case 2: inheritable = true; break; // 継承可能
case 3: if (1==this.sex)inheritable = true; break; // 息子にのみ継承
case 4: if (2==this.sex)inheritable = true; break; // 娘にのみ継承
case 9: // クロムのロードのみ。考慮不要
}
if (inheritable){
p.stuff_cls[idx] = Jobclass(idx);
this.add_skill(2,idx,p.skills);
}else{ // 自由親の習得スキル継承チェックは別途行う
// this.add_skill(2+vp.sex,idx,p.skills);
}
}
// 自由親の習得可能スキルを継承(継承できないクラス用)
var type = 2+vp.sex;
for(var idx in vp.skills){
this.add_skill(type,idx,p.skills);
}
}
return this;
}
//////////////////////////////////////////////////
this.set_spouse = function(spscode,vpcode){
if (!spscode) return null;
var f = false;
if (vpcode){ // 自由親が指定されている場合はまず自分の自由親を設定
// if (!this.set_variable_parent(vpcode)){
// if (this.spouse && this.spouse.code == spscode) return null; // 変化なし
f = true;
// }
}
// _debug('['+this.code+']'+spscode+':'+vpcode,'set_spouse');
// 配偶者を処理
if (f || !this.spouse || this.spouse.code != spscode){
if (this.spouse = Unit(spscode)){
this.spouse.set_spouse(this.code);
// this.spouse = spouse;
this.children.variable = null;
this.spouse.children.variable = null;
// 固定子供がいる場合は配偶者の情報を上乗せ
if (this.children.fixed){
this.children.fixed.set_variable_parent(spscode);
this.spouse.children.variable = this.children.fixed;
}
if (this.spouse.children.fixed){
this.spouse.children.fixed.set_variable_parent(this.code,vpcode); // 配偶者の子供には自分のコードと自分の自由親のコードを指定
this.children.variable = this.spouse.children.fixed;
}
}
}
}
//////////////////////////////////////////////////
// このユニットに配偶者を指定して子供(配列オブジェクト)を取得する
this.get_children = function(spouse_code){
ret = {}; // 子供がいなくてもオブジェクトを返す
if (spouse_code){ // 配偶者が指定されている場合
spouse = Unit(spouse_code); // 配偶者コードから配偶者情報を取得
}else{
// spouse =
}
if (this.children.fixed){ // 固定の子供がいる場合
}
if (spouse_code){ // 配偶者が指定されている場合
spouse = Unit(spouse_code); // 配偶者コードから配偶者情報を取得
if (spouse && spouse.length){
}
}
return ret;
}
//////////////////////////////////////////////////
this.prop = function(name){
var ret = null;
var vp = this.parents.variable;
var index = '';
if (vp){
index = vp.code;
if (vp.parents.variable) index += '.'+vp.parents.variable.code;
}
// _debug(vp);
switch(name){
case 'limit_adj':
switch(this.code){
case 'U2013': case 'U2014':
// マークの上限補正値を取得する際、自由親が子世代なら祖父母世代の自由親の分を考慮して返す
if (vp){
ret = {};
if (vp.parents.variable){
vpvp = vp.parents.variable;
for(var idx in vpvp.limit_adj){
ret[idx] = num(vpvp.limit_adj[idx]) - ('sum'==idx?7:1); // 祖父母世代の補正を加算(マークが3代目の場合はボーナスがなくなるので、各ステータスから1ずつ引いておく)
}
}
for(var idx in vp.limit_adj){
ret[idx] = num(ret[idx]) + num(this.limit_adj[idx]) + num(vp.limit_adj[idx]); // 親世代の補正を加算
}
}
}
if (ret) break;
case 'skills':
if (vp && vp.valid){
ret = this.variations[vp.code][name];
}else{
ret = this[name];
}
break;
case 'stuff_cls':
if (vp && vp.valid){
ret = this.variations[vp.code].stuff_cls;
}else{
ret = this.stuff.class;
}
break;
default:
ret = this[name];
}
return ret;
}
//////////////////////////////////////////////////
this.add_skill = function(type,code,p){
if (!code) return;
if (!this.skills) this.skills = {};
if (!p) p = this.skills;
var skls = {};
switch(typeof code){
case 'string':
if (4==code.length){
var cls = CJobclass(code);
var i = 0;
for(var idx in cls.skills) if (cls.skills[idx]) skls[i++] = cls.skills[idx].code;
if (cls.upperJobClasses) for(var idx in cls.upperJobClasses) this.add_skill(type,idx,p);
}else{
skls[0] = code;
}
case 'object':
var i=0;
for(var idx in code.skills) if (code.skills[idx]) skls[i++] = code.skills[idx].code;
if (code.upperJobClasses) for(var idx in code.upperJobClasses) this.add_skill(type,idx,p);
}
for(var idx in skls){
switch(type){
case 3: case 4: // 継承出来ないスキルの設定
switch(skls[idx]){
case 'C206S1': // 魔防+10
case 'C206S2': // 居合一閃
case 'C204S2': // 特別な踊り
case 'C208S1': // 愛の叫び
case 'C208S2': // 絆
case 'C001S1': // デュアルアタック+
case 'C001S2': // カリスマ
continue; // 上記スキルの場合は継承不可
case 'C101S2': // 王の器
if (2==this.sex) continue; break;
case 'C101S1': // 天空
if (1==this.sex) continue; break;
}
}
if (!p[skls[idx]] || type <p[skls[idx]]) p[skls[idx]] = type;
}
}
//////////////////////////////////////////////////
// プロパティ設定
if (!code) return null;
var label = chars['code'];
var base = chars[code];
if (!base) return;
if (!units[code] || units[code].valid()){
units[code] = this;
this.code = code; // 内部コード
this.id = base[0]; // 内部ID
this.generation = base[1]; // 世代
this.gen = base[1]; // 世代
this.name = base[2]; // ユニット名
this.sex = base[3]; // 性別
this.init_class = Jobclass(base[4]); // 初期クラス
this.init_param = Params('init',base[5]); // 初期パラメータ
this.limit_adj = Params('adj',base[6]); // 上限値補正
this.weapon_levels = {}; // 初期武器レベル
var weapons = base[7];
var lst = label[7];
for(var idx in lst){
this.weapon_levels[lst[idx]] = num(weapons[idx]);
}
this.skills = {}; // 習得可能スキル
this.init_skills = {}; // 初期スキル
lst = base[8]?base[8].split(','):[];
for(var idx in lst){
var skcode = lst[idx];
this.add_skill(1,skcode); // 初期スキル
this.init_skills[skcode] = Skill(skcode); // lst[idx];
}
this.add_skill(2,'C300S1'); // 全能力+2
this.add_skill(2,'C300S2'); // エリート
// 素質
this.stuff = {flg:{},class:{},inherit:{}}
lst = base[9];
for(var idx in lst){
var v = lst[idx];
var clcode = label[9][idx];
this.stuff.flg[clcode] = v;
if (!v) continue;
switch(v){
case 1: // 転職可能クラス
case 2: // 初期クラス
var jc = Jobclass(clcode); // lst[idx];
this.add_skill(2,jc);
this.stuff.class[clcode] = jc;
case -1: // 転職不可クラス
}
}
// 素質(継承)
this.stuff.inherit = {};
this.stuff.inherit_flg = {};
lst = base[12];
for(var idx in lst){
var v = lst[idx];
var clcode = label[12][idx];
this.stuff.inherit_flg[clcode] = v;
if (!v) continue;
switch(v){
case 1: // 転職可能クラス
case 2: // 初期クラス
this.stuff.inherit[clcode] = Jobclass(clcode); // lst[idx];
case -1: // 転職不可クラス
switch(clcode){
case 'C207': // オーバーロード
this.add_skill(3,'C999S2'); // 覇王
break;
// case 'C204': // 踊り子
// this.add_skill(4,'C204S1'); // 幸運+4
}
}
}
// 配偶者一覧
this.spouses = {};
lst = base[13];
for(var idx in lst){
var v = lst[idx];
if (!v) continue;
// this.spouses[v] = Unit(v);
this.spouses[idx] = v;
}
this.variations = {init:{}};
this.variations.init.limit_adj = this.limit_adj;
this.variations.init.stuff_cls = this.stuff.class;
this.variations.init.skills = this.skills;
// 親・子供処理
this.children = {fixed:null,variable:null};
this.parents = {fixed:null,variable:null};
if (base[10]) this.children.fixed = Unit(base[10]); // 固定子供
if (base[11]){
var p = this.parents.fixed = Unit(base[11]); // 固定親
for(var idx in p.stuff.class){
this.add_skill(2+p.sex,idx); // 継承限定スキル
}
}
// 支援会話設定
var cvr = conversations[this.code];
if (cvr){
// _debug(cvr,'conversations');
this.conversations = cvr;
}
}// if (units[code]){
// ここまで、ユニット固定の情報処理
// 自由親が指定されている場合
// _debug(this.generation+':'+vpcode,this.name);
// _debug(ret,name);
// if (1<this.generation && vpcode) this.set_variable_parent(vpcode);
// this.set_spouse(spscode,vpcode);
//////////////////////////////////////////////////
this.get_name = function(prop_name){
switch(prop_name){
case 'sex': return 1==this.sex?'male':'female';
case 'gen': return 1==this.gen?'gen1':'gen2';
}
return '';
}
//////////////////////////////////////////////////
}
var units = {};
function Unit(code,spscode,vpcode){
if (!code) return null;
var index = code;
if (!units[index]){
var ins = new CUnit(code,spscode,vpcode);
if (ins.code) units[index] = ins;
}
var u = units[index];
var f = false;
if (!u) return null;
if (1<u.generation && vpcode){
if (!u.parents.variable || u.parents.variable.code!=vpcode){
u.set_variable_parent(vpcode);
f = true; // 親が変化したため、配偶者に子供がいる場合は配偶者情報を再設定する
}
}
if (spscode){
if (f || !u.spouse || u.spouse.code!=spscode){ // 指定した配偶者が設定されていない場合
// _debug('['+code+']'+spscode+':'+vpcode,'Unit');
u.set_spouse(spscode,vpcode);
}
}
return u;
}
function getUnit(code,spscode,vpcode){return Unit(code,spscode,vpcode);}
function get_unit(code,spscode,vpcode){return Unit(code,spscode,vpcode);}
////////////////////////////////////////////////////////////////////////////////////////////////////
function CBlock(id){
var d = $('#'+id);
if (!d.length) return ;
this.d = d;
//////////////////////////////////////////////////
this.clearFormat = function(){
var d = this.d;
this.name.removeClass('male female gen1 gen2');
d.find('.skill').removeClass('iht dis ena iht1 bold acq');
}
//////////////////////////////////////////////////
this.clear = function(){
this.clearFormat();
var d = this.d;
// this.name.html(' ').removeClass('male female gen1 gen2');
this.name.html(' ');
d.hide();
// d.find('.skill').removeClass('iht dis ena iht1 bold acq');
d.find('.num').removeClass('maxval');
clear_selectors = ['.name'];
for(var idx in clear_selectors){
selector = clear_selectors[idx];
tmp = this.d.find(selector);
if (tmp){
tmp.html(' ');
}
}
this.lmtadj.html('<td class="num str">0</td><td class="num mgc">0</td><td class="num skl">0</td><td class="num spd">0</td><td class="num luk">0</td><td class="num def">0</td><td class="num mdf">0</td><td class="num bold">0</td>');
d.find('.class_stuff').empty();
d.find('.class_buf').empty();
return this;
}
//////////////////////////////////////////////////
this.init = function(){
this.d.hide();
var base = $('#chara_info');
var d = this.d;
this.valid = true;
this.id = id;
this.name = d.find('.name').text('');
this.lmtadj = d.find('.lmtadj');
this.skills = d.find('.skills').html(base.find('.skills').html());
this.classes = {};
this.classes.stuff = d.find('.class_stuff').empty();
this.classes.buf = d.find('.class_buf').empty();
this.sum = {};
this.sum.lowerclasses = d.find('.sumlowcls').text('');;
this.sum.upperclasses = d.find('.sumupcls').text('');;
if (this.skills.length){
this.skill = {};
for(var idx in skills){
var blk = d.find('.'+idx);
if (blk.length) this.skill[idx] = blk;
}
}
this.clear();
return this;
}
//////////////////////////////////////////////////
this.init();
//////////////////////////////////////////////////
this.class = function(type,value){
var ret = '';
switch(type){
case 'sex': return ('object'==typeof value && 1==value.sex)||value==1?'male':'female'; break;
case 'gen': return ('object'==typeof value && 1==value.gen)||value==1?'gen1':'gen2'; break;
case 'fam': return value.children.fixed?'parent':'';
case 'num': return 0==num(value)?' neutral ':(0<value?' positive ':' negative '); break;
case 'cls':
ret = value;
var ini_cls = this.u.init_class;
if (ini_cls && ini_cls.code==value) ret +=' ini';
var key = 'acq/'+this.u.code+'/'+value;
if (load_local(key)) ret +=' acquired';
break;
case 'unit':
// _debug(value,type);
ret = this.class('sex',value.sex);
ret += ' '+this.class('gen',value.gen);
ret += ' '+this.class('fam',value);
}
return ret;
}
//////////////////////////////////////////////////
this.setSkill = function(type,code){
if (!code) return;
var t = null;
if (code.match(/^C\d\d\d$/)){ // クラスコードの場合
var jc = Jobclass(code);
if (jc){
t = [];
for(var idx in jc.skills) if (idx) t.push(idx);
}
}else if(code.match(/^C\d\d\dS\d$/)){ // スキルコードの場合
t = [code];
}
if (t){
var cls = type;
for(var idx in t){
var skcode = t[idx];
var p = this.skill[skcode];
if (p){
switch(type){
case 'enable': case 'ena': add_class = 'ena'; break;
case 'disable': case 'dis': add_class = 'dis'; break;
case 'inherit': case 'iht': case 'iht1':
p.removeClass('iht dis ena iht1');
add_class = 'iht1'==type?'iht1':'iht';
break;
case 'acquired': case 'acq': add_class = 'acq'; break;
case 'forget': case 'fgt': p.removeClass('acq'); break;
}
p.addClass(cls);
}
}
}
}
//////////////////////////////////////////////////
this.setUnit = function(u){
this.init();
// this.clear();
if (!u) return ;
this.u = u;
var d = this.d;
var adj = u.prop('limit_adj')
this.name.text(u.name)
.addClass(u.get_name('sex'))
.addClass(u.get_name('gen'))
.attr('code',u.code);
if (adj){
var html = '';
for(var idx in adj){
html += '<td class="num str'+this.class('num',adj[idx])+'">'+num(adj[idx])+'</td>';
}
}
// 上限値補正表示
this.lmtadj.html(html);
// スキル表示
var skls = u.prop('skills');
for(var idx in skls){
var cls = '';
switch(skls[idx]){
case 1: case 2: cls = 'ena'; break;
case 3: cls = 'iht1'; break;
case 4: cls = 'iht'; break;
}
this.setSkill(cls,idx);
}
// 素質表示
var stfs = u.prop('stuff_cls');
var tr = [];
var row = 0;
var col = 0;
// var lst = chars['code'][9];
// for(var i in lst){
// idx = lst[i];
for(var idx in classes){
if (!stfs[idx]) continue;
var inf = stfs[idx];
if (inf.upperJobClasses){
for(var ccd in inf.upperJobClasses){
tr[row++] = {0:inf.code,1:ccd};
}
}else{
tr[row++] = 2==inf.type?{0:null,1:inf.code}:{0:inf.code,1:null};
}
}
var pn = ['hp','str','mgc','skl','spd','luk','def','mdf']; // 表示する項目一覧
var emp = '<tr><td colspan="9" class=""></td>';
var vs = [
{adj:'limit',prop:'stuff',pn:['hp','str','mgc','skl','spd','luk','def','mdf']}
,{adj:'buffer',prop:'buf',pn:['hp','str','mgc','skl','spd','luk','def','mdf']}
];
var rstr=[['',''],['','']];
var maxs = [{},{}]; // [[0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0]];
for(var k in vs){
for(var l in vs[k].pn){
var pn=vs[k].pn[l];
maxs[k][pn] = 0;
}
}
var sumcls = [0,0];
for(var i=0;i<tr.length;i++){
var r = tr[i];
rstr=[['',''],['','']];
for(var j=0;j<2;j++){ // 下級職->上級職 loop
var rs = 1; // rowspan
if (!r[j]){
for(var k in vs) rstr[k][j] = emp;
}else if (i==0 || (tr[i-1] && tr[i-1][j]!=r[j])){
var rs = (tr[i+1] && tr[i+1][j]==r[j])?2:1;
var jc = Jobclass(r[j]);
var cls1 = this.class('cls',jc.code);
var cls2 = cls1.replace('acquired','');
var atr_class = '';
for(var k in vs){ // 出力するビューの分ループ(標準では上限値一覧と伸び代一覧)
rstr[k][j] = rstr[1][j] = '<td rowspan="'+rs+'" class="'+cls1+' class_name'+atr_class+'">'+jc.label(u.sex)+'</td>';
var lmt = jc.adj_params(vs[k].adj,adj);
maxs[k] = keep_max(maxs[k],lmt);
for(var n in vs[k].pn){ idx = vs[k].pn[n]; // パラメータループ
rstr[k][j] += '<td rowspan="'+rs+'" class="'+cls2+' num '+idx+' n'+lmt[idx]+atr_class+'">'+lmt[idx]+'</td>';
}
}
sumcls[j]++;
}else{ // 空のとき
}
}
for(var k in vs){ // ビューごとの表示処理
this.classes[vs[k].prop].append('<tr>'+rstr[k][0]+rstr[k][1]+'</tr>');
}
}
for(var k in vs){ // ビューごとの表示処理
var v = this.classes[vs[k].prop];
for(var n in vs[k].pn){ idx = vs[k].pn[n];
var c_pn = '.'+idx;
var c_n = '.n'+maxs[k][idx];
v.find('.num' + c_pn + c_n).addClass('maxval');
}
}
this.sum.lowerclasses.text(sumcls[0]);
this.sum.upperclasses.text(sumcls[1]);
d.show();
}
}
var blocks = {};
function Block(id){
if (!id) return null;
if (!blocks[id]){
var ins = new CBlock(id);
if (ins && ins.valid) return blocks[id] = ins;
}
var p = blocks[id];
if (p && p.d){
return p;
}
return null;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
function CViewSupportLevel(){
this.lst_Lv = {1:'C',2:'B',3:'A',4:'S'};
//////////////////////////////////////////////////
this.init = function(){
this.valid = true; // オブジェクト有効フラグ
this.d = $('#conversations');
this.name = this.d.find('.char_name');
this.tables = {
'sm':this.d.find('.same_generation')
,'pc':this.d.find('.parent_child')
,'sb':this.d.find('.sibling')
};
this.levels = {
'sm':this.d.find('.same_generation .support_levels')
,'pc':this.d.find('.parent_child .support_levels')
,'sb':this.d.find('.sibling .support_levels')
};
this.clear();
}
//////////////////////////////////////////////////
this.clear = function(){
this.name.text(' ').attr('class','char_name center');
for(var idx in this.levels){
this.levels[idx].empty();
this.tables[idx].hide();
}
}
//////////////////////////////////////////////////
this.getSuppotLevel = function(type,code1,code2){
var key = 'splv/'+type+'/'+(code1<code2?code1+code2:code2+code1);
var ret = num(load_local(key,0));
// _debug(ret,key);
return ret;
}
//////////////////////////////////////////////////
this.setSuppotLevel = function(type,code1,code2,level){
var key = 'splv/'+type+'/'+(code1<code2?code1+code2:code2+code1);
// _debug(level,key);
if (!level){
delete_local(key);
}else{
save_local(key,level);
}
var actor = this.u.code;
var target = actor==code1?code2:code1;
}
//////////////////////////////////////////////////
this.putCharList = function(defcode){
sel = $('#sel_chara');
sel.empty();
var cnt = 0;
for(var code in conversations){
if (code=='code') continue;
var selected = '';
var u = Unit(code);
if (!u) continue;
if (code==defcode) selected = ' selected="selected" ';
sel.append('<option class="'+u.class('unit')+'" value="'+u.code+'"'+selected+'>'+u.name+'</option>');
cnt++;
}
sel.attr('size',cnt);
}
//////////////////////////////////////////////////
this.display = function(unit){
this.clear();
if (!unit) return null;
if ('string'==typeof unit && unit.match(/^U\d\d\d\d$/)){
this.u = Unit(unit);
}else{
this.u = unit;
}
if (!this.u) return null;
this.name.text(this.u.name).addClass(this.u.class('unit'));
if (this.levels){
// _debug(this.levels);
var lists = ['sm','pc','sb']; // 同世代,親子,兄弟
for(var i in lists){
var type = lists[i];
var tbl = this.tables[type];
var t = this.levels[type];
var cnt = 0;
// _debug(t,type);
lst_unit = this.u.conversations[type];
if (lst_unit){
// _debug(lst_unit);
for(var code in lst_unit){
var f = lst_unit[code];
var tu = Unit(code);
if (tu){
var splv = this.getSuppotLevel(type,this.u.code,code);
// _debug(splv);
var tr = '<tr code="'+tu.code+'" class="sp_target '+tu.class('gen')+'"><td class="name '+tu.class('unit')+'">'+tu.name+'</td>';
for(var lv in this.lst_Lv){
var lbl = this.lst_Lv[lv];
var dis = splv<lv?' dis ':''; // 無効表示用クラス
if (lv<4 || 2==f){ // f が1の場合Lv3(A)まで、2の場合Lv4(S)まで。
tr += '<td class="sl_ sl_'+lbl+dis+'" lv="'+lv+'" type="'+type+'">'+lbl+'</td>';
}else{
tr += '<td style="background-color:#000000;"></td>';
}
}
tr += '</tr>';
t.append(tr);
cnt++;
}
}
if (cnt) tbl.show();
}
}
}
}
//////////////////////////////////////////////////
this.init();
//////////////////////////////////////////////////
$('.sl_').live('click',(function(e){
var t = $(this);
var code = $('#sel_chara').val();
var code2 = t.parents('.sp_target').attr('code');
var type = t.attr('type');
var lv = num(t.attr('lv'));
var flg = t.hasClass('dis'); // 切り替え後の状態を取得(有効にするな1、無効にするなら0になる)
// _debug(code2+' : Lv'+lv+' '+flg,code);
if (!flg){
lv--;
}
var p = t.parent();
for(i=1;i<=4;i++){ // 最初の要素はユニット名なのでスルー
var c = p.find('[lv='+i+']');
if (c.length){
if (i<=lv){
c.removeClass('dis');
}else{
c.addClass('dis');
}
}
}
var v = ViewSupportLevel('support_levels');
v.setSuppotLevel(type,code,code2,lv);
$('#sel_chara').focus();
e.stopPropagation();
return false;
}));
}
var views = {};
function ViewSupportLevel(key){
var key = 'support_levels';
if (!views[key]){
views[key] = new CViewSupportLevel();
}
return views[key];
}
//-->
</script>
}}
#javascript(){{
<script language="JavaScript"><!--
//////////////////////////////////////////////////
//////////////////////////////////////////////////
function num(arg){
if (isNaN(arg)) return 0;
return arg-0;
}
function _debug(msg,lbl){
// return;
dbg = $('#debugmsg');
if(!dbg.length){
$('body').append('<div id="debugmsg" style="display:none;"></div>');
dbg = $('#debugmsg');
}
if(dbg) dbg.html(dbg.html()+(lbl?'['+lbl+'] '+msg:msg)+"<br />\n");
if (lbl) console.log('['+lbl+'] '+msg);
if ('object' ==typeof msg) console.dir(msg);
}
//////////////////////////////////////////////////
function to_local_key(key){
var ret = '';
switch(key){
// スロットに保存しないキーを列挙
case 'slot':
case 'fs':
break;
default:
var t = $('#slot');
// var t = document.getElementById('slot');
if (t && t.length){
ret = t.val();
if ('0'==ret) ret = '';
}
}
ret = ret?ret+'/'+key:key;
return ret;
}
//////////////////////////////////////////////////
var local_data = {};
function save_local(name,value){
name = to_local_key(name);
// _debug(value,name);
if (undefined==value){
delete_local(name);
}
switch(true){
case $.browser.mozilla:
case $.browser.opera:
case $.browser.safari:
return localStorage.setItem(name,value);
break;
case $.browser.msie:
if (9<=$.browser.version){
return localStorage.setItem(name,value);
}
break;
default:
return localStorage.setItem(name,value);
}
return null;
}
//////////////////////////////////////////////////
function load_local(name,defval){
var ret = defval;
name = to_local_key(name);
switch(true){
case $.browser.mozilla:
case $.browser.opera:
case $.browser.safari:
ret = localStorage.getItem(name);
break;
case $.browser.msie:
if (9<=$.browser.version){
ret = localStorage.getItem(name);
}
break;
default:
ret = localStorage.getItem(name);
}
// _debug(ret,name);
if (ret) return ret;
return defval;
}
//////////////////////////////////////////////////
function delete_local(name){
name = to_local_key(name);
localStorage.removeItem(name);
}
//////////////////////////////////////////////////
function clear_local(){
localStorage.clear();
}
//////////////////////////////////////////////////
function keep_max(max,chk){
if(max && chk){
for(var i in max){
if (max[i] < chk[i]) max[i] = chk[i];
}
}
return max;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
function CBlock(id){
var d = $('#'+id);
if (!d.length) return ;
this.d = d;
//////////////////////////////////////////////////
this.clearFormat = function(){
var d = this.d;
this.name.removeClass('male female gen1 gen2');
d.find('.skill').removeClass('iht dis ena iht1 bold acq');
}
//////////////////////////////////////////////////
this.clear = function(){
this.clearFormat();
var d = this.d;
// this.name.html(' ').removeClass('male female gen1 gen2');
this.name.html(' ');
d.hide();
// d.find('.skill').removeClass('iht dis ena iht1 bold acq');
d.find('.num').removeClass('maxval');
clear_selectors = ['.name'];
for(var idx in clear_selectors){
selector = clear_selectors[idx];
tmp = this.d.find(selector);
if (tmp){
tmp.html(' ');
}
}
this.lmtadj.html('<td class="num str">0</td><td class="num mgc">0</td><td class="num skl">0</td><td class="num spd">0</td><td class="num luk">0</td><td class="num def">0</td><td class="num mdf">0</td><td class="num bold">0</td>');
d.find('.class_stuff').empty();
d.find('.class_buf').empty();
d.find('.class_weapon').empty();
return this;
}
//////////////////////////////////////////////////
this.init = function(){
this.d.hide();
var base = $('#chara_info');
var d = this.d;
this.valid = true;
this.id = id;
this.name = d.find('.name').text('');
this.lmtadj = d.find('.lmtadj');
this.skills = d.find('.skills').html(base.find('.skills').html());
this.classes = {};
this.classes.stuff = d.find('.class_stuff').empty();
this.classes.buf = d.find('.class_buf').empty();
this.classes.weapon = d.find('.class_weapon').empty();
this.sum = {};
this.sum.lowerclasses = d.find('.sumlowcls').text('');;
this.sum.upperclasses = d.find('.sumupcls').text('');;
if (this.skills.length){
this.skill = {};
for(var idx in skills){
var blk = d.find('.'+idx);
if (blk.length) this.skill[idx] = blk;
}
}
this.clear();
return this;
}
//////////////////////////////////////////////////
this.init();
//////////////////////////////////////////////////
this.cls = function(type,value){
var ret = '';
switch(type){
case 'sex': return ('object'==typeof value && 1==value.sex)||value==1?'male':'female'; break;
case 'gen': return ('object'==typeof value && 1==value.gen)||value==1?'gen1':'gen2'; break;
case 'fam': return value.children.fixed?'parent':'';
case 'num': return 0==num(value)?' neutral ':(0<value?' positive ':' negative '); break;
case 'cls':
ret = value;
var ini_cls = this.u.init_class;
if (ini_cls && ini_cls.code==value) ret +=' ini';
var key = 'acq/'+this.u.code+'/'+value;
if (load_local(key)) ret +=' acquired';
break;
case 'unit':
// _debug(value,type);
ret = this.cls('sex',value.sex);
ret += ' '+this.cls('gen',value.gen);
ret += ' '+this.cls('fam',value);
}
return ret;
}
//////////////////////////////////////////////////
this.setSkill = function(type,code){
if (!code) return;
var t = null;
if (code.match(/^C\d\d\d$/)){ // クラスコードの場合
var jc = Jobclass(code);
if (jc){
t = [];
for(var idx in jc.skills) if (idx) t.push(idx);
}
}else if(code.match(/^C\d\d\dS\d$/)){ // スキルコードの場合
t = [code];
}
if (t){
var cls = type;
for(var idx in t){
var skcode = t[idx];
var p = this.skill[skcode];
if (p){
switch(type){
case 'enable': case 'ena': add_class = 'ena'; break;
case 'disable': case 'dis': add_class = 'dis'; break;
case 'inherit': case 'iht': case 'iht1':
p.removeClass('iht dis ena iht1');
add_class = 'iht1'==type?'iht1':'iht';
break;
case 'acquired': case 'acq': add_class = 'acq'; break;
case 'forget': case 'fgt': p.removeClass('acq'); break;
}
p.addClass(cls);
}
}
}
}
//////////////////////////////////////////////////
this.setUnit = function(u){
this.init();
// this.clear();
if (!u) return ;
this.u = u;
var d = this.d;
var adj = u.prop('limit_adj')
this.name.text(u.name)
.addClass(u.get_name('sex'))
.addClass(u.get_name('gen'))
.attr('code',u.code);
if (adj){
var html = '';
for(var idx in adj){
html += '<td class="num str'+this.cls('num',adj[idx])+'">'+num(adj[idx])+'</td>';
}
}
// 上限値補正表示
this.lmtadj.html(html);
// スキル表示
var skls = u.prop('skills');
for(var idx in skls){
var cls = '';
switch(skls[idx]){
case 1: case 2: cls = 'ena'; break;
case 3: cls = 'iht1'; break;
case 4: cls = 'iht'; break;
}
this.setSkill(cls,idx);
}
// 素質表示
var stfs = u.prop('stuff_cls');
var tr = [];
var row = 0;
var col = 0;
// var lst = chars['code'][9];
// for(var i in lst){
// idx = lst[i];
for(var idx in classes){
if (!stfs[idx]) continue;
var inf = stfs[idx];
if (inf.upperJobClasses){
for(var ccd in inf.upperJobClasses){
tr[row++] = {0:inf.code,1:ccd};
}
}else{
tr[row++] = 2==inf.type?{0:null,1:inf.code}:{0:inf.code,1:null};
}
}
// var pn = ['hp','str','mgc','skl','spd','luk','def','mdf']; // 表示する項目一覧
var emp = '<tr><td colspan="9" class=""></td>';
var vs = [
{adj:'limit',prop:'stuff',pn:['hp','str','mgc','skl','spd','luk','def','mdf']}
,{adj:'buffer',prop:'buf',pn:['hp','str','mgc','skl','spd','luk','def','mdf']}
,{adj:'weapon',prop:'weapon',pn:['swd','lnc','axe','bow','bok','wan','stn','dmy']}
];
var rstr=[['',''],['',''],['','']];
var maxs = [{},{},{}]; // [[0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0]];
for(var k in vs){
for(var l in vs[k].pn){
var pn=vs[k].pn[l];
maxs[k][pn] = 0;
}
}
var sumcls = [0,0];
for(var i=0;i<tr.length;i++){
var r = tr[i];
rstr=[['',''],['',''],['','']];
for(var j=0;j<2;j++){ // 下級職->上級職 loop
var rs = 1; // rowspan
if (!r[j]){
for(var k in vs) rstr[k][j] = emp;
}else if (i==0 || (tr[i-1] && tr[i-1][j]!=r[j])){
var rs = (tr[i+1] && tr[i+1][j]==r[j])?2:1;
var jc = Jobclass(r[j]);
var cls1 = this.cls('cls',jc.code);
var cls2 = cls1.replace('acquired','');
var atr_class = '';
// _debug(vs.toSource(),vs);
for(var k in vs){ // 出力するビューの分ループ(標準では上限値一覧と伸び代一覧)
// _debug(k.toSource(),'k');
rstr[k][j] = '<td rowspan="'+rs+'" class="'+cls1+' class_name'+atr_class+'">'+jc.label(u.sex)+'</td>';
switch(k){
case 0:case '0':case 'limit':case 1:case '1':case 'buffer':
case 'hp':case 'str':case 'mgc':case 'skl':case 'spd':case 'luk':case 'def':case 'mdf':
// _debug(k,'パラメータ表示');
var lmt = jc.adj_params(vs[k].adj,adj);
// _debug(lmt,'パラメータ');
maxs[k] = keep_max(maxs[k],lmt);
for(var n in vs[k].pn){
idx = vs[k].pn[n]; // パラメータループ
rstr[k][j] += '<td rowspan="'+rs+'" class="'+cls2+' num '+idx+' n'+lmt[idx]+atr_class+'">'+lmt[idx]+'</td>';
}
// if ('1'==k)_debug(rstr[k][j],'rstr[k][j]');
break;
case 2:case '2':case 'weapon':
case 'swd':case 'lnc':case 'axe':case 'bow':case 'bok':case 'wan':case 'stn':
// _debug(k,'使用武器表示');
// _debug(vs[k].adj,'vs[k].adj');
var wpn = jc.adj_params(vs[k].adj,null);
// _debug(wpn,'使用武器');
for(var n in vs[k].pn){
idx = vs[k].pn[n];
wval = 0<wpn[idx]?'○':'';
// _debug(wpn[idx],'wpn[idx]');
// _debug(wval,idx);
rstr[k][j] += '<td rowspan="'+rs+'" class="'+cls2+' num '+idx+' '+atr_class+'">'+wval+'</td>';
}
}
}
sumcls[j]++;
}else{ // 空のとき
}
}
// _debug(this.classes.toSource(),'this.classes');
for(var k in vs){ // ビューごとの表示処理
this.classes[vs[k].prop].append('<tr>'+rstr[k][0]+rstr[k][1]+'</tr>');
}
}
// _debug(rstr,'rstr');
for(var k in vs){ // ビューごとの表示処理
var v = this.classes[vs[k].prop];
for(var n in vs[k].pn){
idx = vs[k].pn[n];
var c_pn = '.'+idx;
var c_n = '.n'+maxs[k][idx];
v.find('.num' + c_pn + c_n).addClass('maxval');
}
}
this.sum.lowerclasses.text(sumcls[0]);
this.sum.upperclasses.text(sumcls[1]);
d.show();
}
}
var blocks = {};
function Block(id){
if (!id) return null;
if (!blocks[id]){
var ins = new CBlock(id);
if (ins && ins.valid) return blocks[id] = ins;
}
var p = blocks[id];
if (p && p.d){
return p;
}
return null;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
function CViewSupportLevel(){
this.lst_Lv = {1:'C',2:'B',3:'A',4:'S'};
//////////////////////////////////////////////////
this.init = function(){
this.valid = true; // オブジェクト有効フラグ
this.d = $('#conversations');
this.name = this.d.find('.char_name');
this.tables = {
'sm':this.d.find('.same_generation')
,'pc':this.d.find('.parent_child')
,'sb':this.d.find('.sibling')
};
this.levels = {
'sm':this.d.find('.same_generation .support_levels')
,'pc':this.d.find('.parent_child .support_levels')
,'sb':this.d.find('.sibling .support_levels')
};
this.clear();
}
//////////////////////////////////////////////////
this.clear = function(){
this.name.text(' ').attr('class','char_name center');
for(var idx in this.levels){
this.levels[idx].empty();
this.tables[idx].hide();
}
}
//////////////////////////////////////////////////
this.getSuppotLevel = function(type,code1,code2){
var key = 'splv/'+type+'/'+(code1<code2?code1+code2:code2+code1);
var ret = num(load_local(key,0));
// _debug(ret,key);
return ret;
}
//////////////////////////////////////////////////
this.setSuppotLevel = function(type,code1,code2,level){
var key = 'splv/'+type+'/'+(code1<code2?code1+code2:code2+code1);
// _debug(level,key);
if (!level){
delete_local(key);
}else{
save_local(key,level);
}
var actor = this.u.code;
var target = actor==code1?code2:code1;
}
//////////////////////////////////////////////////
this.putCharList = function(defcode){
sel = $('#sel_chara');
sel.empty();
var cnt = 0;
for(var code in conversations){
if (code=='code') continue;
var selected = '';
var u = Unit(code);
if (!u) continue;
if (code==defcode) selected = ' selected="selected" ';
sel.append('<option class="'+u.cls('unit')+'" value="'+u.code+'"'+selected+'>'+u.name+'</option>');
cnt++;
}
sel.attr('size',cnt);
}
//////////////////////////////////////////////////
this.display = function(unit){
this.clear();
if (!unit) return null;
if ('string'==typeof unit && unit.match(/^U\d\d\d\d$/)){
this.u = Unit(unit);
}else{
this.u = unit;
}
if (!this.u) return null;
this.name.text(this.u.name).addClass(this.u.cls('unit'));
if (this.levels){
// _debug(this.levels);
var lists = ['sm','pc','sb']; // 同世代,親子,兄弟
for(var i in lists){
var type = lists[i];
var tbl = this.tables[type];
var t = this.levels[type];
var cnt = 0;
// _debug(t,type);
lst_unit = this.u.conversations[type];
if (lst_unit){
// _debug(lst_unit);
for(var code in lst_unit){
var f = lst_unit[code];
var tu = Unit(code);
if (tu){
var splv = this.getSuppotLevel(type,this.u.code,code);
// _debug(splv);
var tr = '<tr code="'+tu.code+'" class="sp_target '+tu.cls('gen')+'"><td class="name '+tu.cls('unit')+'">'+tu.name+'</td>';
for(var lv in this.lst_Lv){
var lbl = this.lst_Lv[lv];
var dis = splv<lv?' dis ':''; // 無効表示用クラス
if (lv<4 || 2==f){ // f が1の場合Lv3(A)まで、2の場合Lv4(S)まで。
tr += '<td class="sl_ sl_'+lbl+dis+'" lv="'+lv+'" type="'+type+'">'+lbl+'</td>';
}else{
tr += '<td style="background-color:#000000;"></td>';
}
}
tr += '</tr>';
t.append(tr);
cnt++;
}
}
if (cnt) tbl.show();
}
}
}
}
//////////////////////////////////////////////////
this.init();
//////////////////////////////////////////////////
$('.sl_').live('click',(function(e){
var t = $(this);
var code = $('#sel_chara').val();
var code2 = t.parents('.sp_target').attr('code');
var type = t.attr('type');
var lv = num(t.attr('lv'));
var flg = t.hasClass('dis'); // 切り替え後の状態を取得(有効にするな1、無効にするなら0になる)
// _debug(code2+' : Lv'+lv+' '+flg,code);
if (!flg){
lv--;
}
var p = t.parent();
for(i=1;i<=4;i++){ // 最初の要素はユニット名なのでスルー
var c = p.find('[lv='+i+']');
if (c.length){
if (i<=lv){
c.removeClass('dis');
}else{
c.addClass('dis');
}
}
}
var v = ViewSupportLevel('support_levels');
v.setSuppotLevel(type,code,code2,lv);
$('#sel_chara').focus();
e.stopPropagation();
return false;
}));
}
var views = {};
function ViewSupportLevel(key){
var key = 'support_levels';
if (!views[key]){
views[key] = new CViewSupportLevel();
}
return views[key];
}
//-->
</script>
}}
表示オプション
横に並べて表示:
変化行の前後のみ表示: