The target dropdown starts on the likeliest subject
One module decides where a spell most likely goes given the field (a fireball at an ice elemental, charm monster at their strongest creature, remove enchantment at the wizard only if enchanted); the bot and the dropdown both use it. The dropdown lists that subject first and marks creatures by whose they are. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5.1
parent
dd6ff93606
commit
81acbd2172
+4
-35
@@ -16,6 +16,7 @@ import {
|
||||
type TurnGestures
|
||||
} from './gestures';
|
||||
import { allowedGestures, forcedGesture } from './resolve';
|
||||
import { likelyTarget } from './targets';
|
||||
import { GESTURES, HANDS, HOSTILE_SPELLS, MAGIC_GESTURES, SPELLS, SPELL_BY_ID, isElemental, type Gesture, type Hand, type Spell, type SpellId } from './spells';
|
||||
import {
|
||||
MAX_HP,
|
||||
@@ -330,41 +331,9 @@ function foeDangerousHand(s: Situation): Hand {
|
||||
}
|
||||
|
||||
function targetFor(s: Situation, spell: Spell, choice: CastChoice): void {
|
||||
const meW = s.state.wizards[s.me];
|
||||
const foeMonsters = s.state.monsters.filter((m) => m.owner === s.foe);
|
||||
const strongestFoeMonster = [...foeMonsters].sort((a, b) => b.attack - a.attack)[0];
|
||||
const iceEl = s.state.monsters.find((m) => m.kind === 'ice_elemental');
|
||||
const fireEl = s.state.monsters.find((m) => m.kind === 'fire_elemental');
|
||||
switch (spell.id) {
|
||||
case 'fireball':
|
||||
choice.target = iceEl ? iceEl.id : s.foe;
|
||||
break;
|
||||
case 'resist_cold':
|
||||
choice.target = iceEl ? iceEl.id : s.me;
|
||||
break;
|
||||
case 'resist_heat':
|
||||
choice.target = fireEl ? fireEl.id : s.me;
|
||||
break;
|
||||
case 'charm_monster':
|
||||
choice.target = strongestFoeMonster?.id ?? s.foe;
|
||||
break;
|
||||
case 'remove_enchantment': {
|
||||
const foeW = s.state.wizards[s.foe];
|
||||
choice.target = isEnchanted(foeW) || !strongestFoeMonster ? s.foe : strongestFoeMonster.id;
|
||||
break;
|
||||
}
|
||||
case 'summon_elemental':
|
||||
choice.target = s.me;
|
||||
choice.elemental = meW.resistCold ? 'ice' : 'fire';
|
||||
break;
|
||||
case 'paralysis':
|
||||
case 'charm_person':
|
||||
choice.target = s.foe;
|
||||
choice.chosenHand = foeDangerousHand(s);
|
||||
break;
|
||||
default:
|
||||
choice.target = spell.usualTarget === 'self' ? s.me : s.foe;
|
||||
}
|
||||
choice.target = likelyTarget(s.state, s.me, spell);
|
||||
if (spell.id === 'summon_elemental') choice.elemental = s.state.wizards[s.me].resistCold ? 'ice' : 'fire';
|
||||
if (spell.id === 'paralysis' || spell.id === 'charm_person') choice.chosenHand = foeDangerousHand(s);
|
||||
if (spell.category === 'summons') choice.monsterTarget = s.foe;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user