攻撃側テラスタル計算
This commit is contained in:
@@ -60,13 +60,15 @@
|
|||||||
// 攻撃側タイプ
|
// 攻撃側タイプ
|
||||||
// TODO: try catchでエラーハンドリング
|
// TODO: try catchでエラーハンドリング
|
||||||
atk_type: JSON.parse(attacker.types), // 配列なのでjson parse
|
atk_type: JSON.parse(attacker.types), // 配列なのでjson parse
|
||||||
|
atk_terastype : JSON.parse(attacker.terastype),
|
||||||
// 防御側タイプ
|
// 防御側タイプ
|
||||||
def_type: JSON.parse(defender.types),
|
def_type: JSON.parse(defender.types),
|
||||||
|
def_terastype : JSON.parse(defender.terastype),
|
||||||
|
|
||||||
// 技タイプ
|
// 技タイプ
|
||||||
move_type: JSON.parse(attackData.types),
|
move_type: JSON.parse(attackData.types),
|
||||||
// 範囲の計算で使用する
|
// 範囲の計算で使用する
|
||||||
};
|
};
|
||||||
|
|
||||||
// 計算
|
// 計算
|
||||||
/*
|
/*
|
||||||
memo:計算用テストデータ
|
memo:計算用テストデータ
|
||||||
@@ -107,22 +109,55 @@
|
|||||||
// 急所補正
|
// 急所補正
|
||||||
// 乱数補正
|
// 乱数補正
|
||||||
data.minDamage = getMinDamage(data);
|
data.minDamage = getMinDamage(data);
|
||||||
// タイプ一致補正
|
// タイプ一致などの倍率
|
||||||
let type_match = false;
|
let magnification = 1 // タイプ相性倍率
|
||||||
for (let i = 0; i < data.atk_type.length && !type_match; i++) {
|
let magnification_terastype = 1 // タイプ一致補正 テラスタル含む
|
||||||
for (let j = 0; j < data.move_type.length && !type_match; j++) {
|
|
||||||
if (data.atk_type[i] === data.move_type[j]) {
|
// ポケモンのタイプとテラスタルのタイプ一致の判定
|
||||||
// タイプ一致したら判定終了
|
let is_terastype = data.atk_terastype !== 0
|
||||||
type_match = true;
|
let terastype_match = false
|
||||||
data.maxDamage = Math.trunc(data.maxDamage * 1.5);
|
if (is_terastype){
|
||||||
data.minDamage = Math.trunc(data.minDamage * 1.5);
|
terastype_match = data.atk_type.includes(data.atk_terastype)
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ポケモンのタイプと技のタイプの判定
|
||||||
|
// 1. テラスタルしてるなら、テラスタルのタイプで判定
|
||||||
|
// 2. テラスタルしていないなら、元のタイプで判定
|
||||||
|
let atk_type
|
||||||
|
if (is_terastype){
|
||||||
|
atk_type = data.atk_terastype;
|
||||||
|
} else {
|
||||||
|
atk_type = data.atk_type
|
||||||
|
}
|
||||||
|
let type_match = data.atk_type.findIndex((type) => type === data.move_type[0]) > -1
|
||||||
|
// Note:
|
||||||
|
// フライングプレスだけ格闘と飛行の2属性があるが、タイプ一致補正は格闘にだけ補正が掛かる
|
||||||
|
// data.move_type[0] = 7で格闘が取れるのでOK
|
||||||
|
|
||||||
|
// 技のタイプとテラスタルのタイプの一致判定
|
||||||
|
let movetype_match = false
|
||||||
|
if (is_terastype){
|
||||||
|
movetype_match = data.move_type.includes(data.atk_terastype)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 技のタイプ一致倍率(技のタイプが一致するかどうか)
|
||||||
|
// 本来のタイプ テラスタルタイプ 倍率
|
||||||
|
if ( type_match && is_terastype && terastype_match){
|
||||||
|
// 1. 一致する 一致する => x2
|
||||||
|
magnification_terastype = 2
|
||||||
|
} else if ((type_match && is_terastype && !terastype_match) || (type_match && !is_terastype) || (!type_match && is_terastype && movetype_match)){
|
||||||
|
// 2. 一致する 一致しない => x1.5
|
||||||
|
// 3. 一致する テラスタルなし => x1.5
|
||||||
|
// 4. 一致しない 一致する => x1.5 NG
|
||||||
|
magnification_terastype =1.5
|
||||||
|
}
|
||||||
|
// 5. 一致しない 一致しない 1
|
||||||
|
// 6. 一致しない テラスタルなし 1
|
||||||
|
// そのままなので特に処理なし
|
||||||
|
|
||||||
// 相性補正
|
// 相性補正
|
||||||
// 相性の計算の関数をとってくる
|
// 相性補正の倍率を計算
|
||||||
data = getCompatibility(data)
|
magnification = getCompatibility(data)
|
||||||
|
|
||||||
// やけど補正
|
// やけど補正
|
||||||
// 壁補正
|
// 壁補正
|
||||||
@@ -139,6 +174,13 @@
|
|||||||
// 半減木の実補正
|
// 半減木の実補正
|
||||||
// その他ダメージ補正(M twice)
|
// その他ダメージ補正(M twice)
|
||||||
// ダイマックス技などの軽減(M protect)
|
// ダイマックス技などの軽減(M protect)
|
||||||
|
|
||||||
|
// 最後に倍率かける
|
||||||
|
data.maxDamage = Math.trunc(data.maxDamage * magnification_terastype)
|
||||||
|
data.minDamage = Math.trunc(data.minDamage * magnification_terastype)
|
||||||
|
data.maxDamage = Math.trunc(data.maxDamage * magnification)
|
||||||
|
data.minDamage = Math.trunc(data.minDamage * magnification)
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
// 乱数補正
|
// 乱数補正
|
||||||
@@ -150,7 +192,10 @@
|
|||||||
return Math.trunc((data.maxDamage * 85) / 100);
|
return Math.trunc((data.maxDamage * 85) / 100);
|
||||||
}
|
}
|
||||||
// 相性計算
|
// 相性計算
|
||||||
|
// 倍率だけ返す
|
||||||
function getCompatibility(data){
|
function getCompatibility(data){
|
||||||
|
let type_magnification = 1
|
||||||
|
|
||||||
// 技のタイプの相性倍率とりだす
|
// 技のタイプの相性倍率とりだす
|
||||||
// attack_types の json の index と move_type の数字が1つずれてる
|
// attack_types の json の index と move_type の数字が1つずれてる
|
||||||
let compatibility = attack_types[data.move_type-1]
|
let compatibility = attack_types[data.move_type-1]
|
||||||
@@ -158,11 +203,9 @@
|
|||||||
// 相手のタイプ毎に倍率計算
|
// 相手のタイプ毎に倍率計算
|
||||||
for (let i = 0; i < data.def_type.length; i++){
|
for (let i = 0; i < data.def_type.length; i++){
|
||||||
// 倍率
|
// 倍率
|
||||||
let magnification = compatibility[data.def_type[i]-1] // ここもindexずれる
|
type_magnification *= compatibility[data.def_type[i]-1] // ここもindexずれる
|
||||||
data.maxDamage *= magnification
|
|
||||||
data.minDamage *= magnification
|
|
||||||
}
|
}
|
||||||
return data
|
return type_magnification
|
||||||
}
|
}
|
||||||
async function getItems(keyword) {
|
async function getItems(keyword) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user