QA and tune refuge campaign battles
This commit is contained in:
@@ -8,6 +8,11 @@ const pnpmCommand = process.env.PNPM_CMD ?? 'pnpm';
|
||||
|
||||
const coreBrothers = ['liu-bei', 'guan-yu', 'zhang-fei'];
|
||||
const xuzhouFullSortie = ['liu-bei', 'guan-yu', 'zhang-fei', 'jian-yong', 'mi-zhu'];
|
||||
const caoRefugeSortie = ['liu-bei', 'guan-yu', 'zhang-fei', 'jian-yong', 'mi-zhu'];
|
||||
const sunQianSortie = ['liu-bei', 'guan-yu', 'zhang-fei', 'jian-yong', 'mi-zhu', 'sun-qian'];
|
||||
const liuBiaoSortie = ['liu-bei', 'guan-yu', 'zhang-fei', 'zhao-yun', 'sun-qian', 'mi-zhu'];
|
||||
const zhugeFirstSortie = ['liu-bei', 'zhuge-liang', 'zhao-yun', 'guan-yu', 'zhang-fei', 'sun-qian'];
|
||||
const envoySortie = ['liu-bei', 'zhuge-liang', 'sun-qian', 'zhao-yun', 'guan-yu', 'zhang-fei'];
|
||||
|
||||
const earlyCampaignBattles = [
|
||||
{ no: 1, id: 'first-battle-zhuo-commandery', selected: [], targets: ['rebel-leader'], protected: ['liu-bei'] },
|
||||
@@ -76,6 +81,79 @@ const earlyCampaignBattles = [
|
||||
}
|
||||
];
|
||||
|
||||
const refugeCampaignBattles = [
|
||||
{
|
||||
no: 11,
|
||||
id: 'eleventh-battle-xudu-refuge-road',
|
||||
selected: caoRefugeSortie,
|
||||
targets: ['xudu-road-leader-ji-ling'],
|
||||
protected: ['liu-bei']
|
||||
},
|
||||
{
|
||||
no: 12,
|
||||
id: 'twelfth-battle-xiapi-outer-siege',
|
||||
selected: caoRefugeSortie,
|
||||
targets: ['xiapi-leader-zhang-liao'],
|
||||
protected: ['liu-bei']
|
||||
},
|
||||
{
|
||||
no: 13,
|
||||
id: 'thirteenth-battle-xiapi-final',
|
||||
selected: caoRefugeSortie,
|
||||
targets: ['xiapi-final-leader-lu-bu'],
|
||||
protected: ['liu-bei']
|
||||
},
|
||||
{
|
||||
no: 14,
|
||||
id: 'fourteenth-battle-cao-break',
|
||||
selected: sunQianSortie,
|
||||
targets: ['cao-break-leader-che-zhou'],
|
||||
protected: ['liu-bei']
|
||||
},
|
||||
{
|
||||
no: 15,
|
||||
id: 'fifteenth-battle-yuan-refuge-road',
|
||||
selected: sunQianSortie,
|
||||
targets: ['yuan-refuge-leader-cai-yang'],
|
||||
protected: ['liu-bei']
|
||||
},
|
||||
{
|
||||
no: 16,
|
||||
id: 'sixteenth-battle-liu-biao-refuge',
|
||||
selected: liuBiaoSortie,
|
||||
targets: ['liu-biao-road-leader-cao-ren'],
|
||||
protected: ['liu-bei']
|
||||
},
|
||||
{
|
||||
no: 17,
|
||||
id: 'seventeenth-battle-wolong-visit-road',
|
||||
selected: liuBiaoSortie,
|
||||
targets: ['wolong-road-leader-cai-xun'],
|
||||
protected: ['liu-bei']
|
||||
},
|
||||
{
|
||||
no: 18,
|
||||
id: 'eighteenth-battle-bowang-ambush',
|
||||
selected: zhugeFirstSortie,
|
||||
targets: ['bowang-leader-xiahou-dun'],
|
||||
protected: ['liu-bei']
|
||||
},
|
||||
{
|
||||
no: 19,
|
||||
id: 'nineteenth-battle-changban-refuge',
|
||||
selected: zhugeFirstSortie,
|
||||
targets: ['changban-leader-cao-chun'],
|
||||
protected: ['liu-bei', 'zhao-yun']
|
||||
},
|
||||
{
|
||||
no: 20,
|
||||
id: 'twentieth-battle-jiangdong-envoy',
|
||||
selected: envoySortie,
|
||||
targets: ['envoy-road-leader-wen-pin'],
|
||||
protected: ['liu-bei', 'zhuge-liang', 'sun-qian']
|
||||
}
|
||||
];
|
||||
|
||||
const allRepresentativeBattles = [
|
||||
{ no: 1, id: 'first-battle-zhuo-commandery', selected: [], targets: ['rebel-leader'], protected: ['liu-bei'] },
|
||||
{
|
||||
@@ -138,7 +216,8 @@ const allRepresentativeBattles = [
|
||||
|
||||
const qaBattleSets = {
|
||||
representative: allRepresentativeBattles,
|
||||
early: earlyCampaignBattles
|
||||
early: earlyCampaignBattles,
|
||||
refuge: refugeCampaignBattles
|
||||
};
|
||||
const qaSetName = process.env.QA_SET ?? 'representative';
|
||||
const qaBattleSet = qaBattleSets[qaSetName];
|
||||
@@ -402,7 +481,14 @@ async function playBattleWithoutDebugVictory(page, battle) {
|
||||
if (vanguards.length === 0) {
|
||||
return unit.hp >= Math.ceil(unit.maxHp * 0.8);
|
||||
}
|
||||
return Boolean(vanguardInPosition && focus && targetIds.has(focus.id) && focus.hp <= Math.ceil(focus.maxHp * 0.3));
|
||||
const targetPressThreshold = protectedIds.size > 1 ? 0.12 : 0.3;
|
||||
return Boolean(
|
||||
vanguardInPosition &&
|
||||
focus &&
|
||||
targetIds.has(focus.id) &&
|
||||
focus.hp <= Math.ceil(focus.maxHp * targetPressThreshold) &&
|
||||
unit.hp >= Math.ceil(unit.maxHp * 0.7)
|
||||
);
|
||||
}
|
||||
|
||||
function canTakeAttack(unit, attack, threat = protectedIds.has(unit.id) ? incomingThreat(unit, unit) : 0) {
|
||||
@@ -412,7 +498,16 @@ async function playBattleWithoutDebugVictory(page, battle) {
|
||||
const pressProtected = shouldPressProtected(unit);
|
||||
const isTarget = targetIds.has(attack.target.id);
|
||||
const kill = attack.preview.damage >= attack.target.hp;
|
||||
if (isTarget && (threat <= Math.floor(unit.hp * (pressProtected ? 0.7 : 0.42)) || unit.hp >= Math.ceil(unit.maxHp * 0.8))) {
|
||||
if (protectedIds.size > 1 && !isTarget && unit.id === 'sun-qian') {
|
||||
return kill && liveUnits('enemy').length <= 3 && threat <= Math.floor(unit.hp * 0.12);
|
||||
}
|
||||
if (protectedIds.size > 1 && !isTarget) {
|
||||
return unit.hp >= Math.ceil(unit.maxHp * 0.75) && threat <= Math.floor(unit.hp * 0.22);
|
||||
}
|
||||
if (isTarget && (pressProtected || kill) && threat <= Math.floor(unit.hp * (pressProtected ? 0.7 : 0.42))) {
|
||||
return true;
|
||||
}
|
||||
if (isTarget && protectedIds.size === 1 && threat <= Math.floor(unit.hp * 0.3)) {
|
||||
return true;
|
||||
}
|
||||
if (kill && threat <= Math.floor(unit.hp * (pressProtected ? 0.5 : 0.32))) {
|
||||
@@ -489,10 +584,11 @@ async function playBattleWithoutDebugVictory(page, battle) {
|
||||
const focus = attack?.target ?? focusTarget(unit);
|
||||
const isProtected = protectedIds.has(unit.id);
|
||||
const shouldPress = isProtected && shouldPressProtected(unit);
|
||||
const approach = focus ? -distance(unit, focus) * (isProtected ? (shouldPress ? 42 : 5) : 36) : 0;
|
||||
const attackScore = attack ? attack.score + (targetIds.has(attack.target.id) ? 2400 : 1350) : approach;
|
||||
const allySupport = liveUnits('ally').filter((ally) => ally.id !== unit.id && distance(unit, ally) <= 2).length * 16;
|
||||
const threat = incomingThreat(unit, tile);
|
||||
const canUseAttack = attack && (!isProtected || canTakeAttack(unit, attack, threat));
|
||||
const approach = focus ? -distance(unit, focus) * (isProtected ? (shouldPress ? 42 : 5) : 36) : 0;
|
||||
const attackScore = canUseAttack ? attack.score + (targetIds.has(attack.target.id) ? 2400 : 1350) : approach;
|
||||
const allySupport = liveUnits('ally').filter((ally) => ally.id !== unit.id && distance(unit, ally) <= 2).length * 16;
|
||||
const nearestEnemyDistance = liveUnits('enemy')
|
||||
.map((enemy) => distance(unit, enemy))
|
||||
.sort((a, b) => a - b)[0] ?? 99;
|
||||
|
||||
Reference in New Issue
Block a user