Reject self targeting battle intents
This commit is contained in:
@@ -52,6 +52,7 @@ try {
|
|||||||
['too long battle log entry', { battleLog: ['x'.repeat(97)] }],
|
['too long battle log entry', { battleLog: ['x'.repeat(97)] }],
|
||||||
['invalid attackIntents', { attackIntents: [{ attackerId: 'liu-bei' }] }],
|
['invalid attackIntents', { attackIntents: [{ attackerId: 'liu-bei' }] }],
|
||||||
['unknown attack intent unit id', { attackIntents: [{ attackerId: 'liu-bei', targetId: 'ghost-unit' }] }],
|
['unknown attack intent unit id', { attackIntents: [{ attackerId: 'liu-bei', targetId: 'ghost-unit' }] }],
|
||||||
|
['self-targeting attack intent', { attackIntents: [{ attackerId: 'liu-bei', targetId: 'liu-bei' }] }],
|
||||||
['duplicate attack intent attacker id', { attackIntents: [{ attackerId: 'liu-bei', targetId: 'rebel-1' }, { attackerId: 'liu-bei', targetId: 'rebel-1' }] }],
|
['duplicate attack intent attacker id', { attackIntents: [{ attackerId: 'liu-bei', targetId: 'rebel-1' }, { attackerId: 'liu-bei', targetId: 'rebel-1' }] }],
|
||||||
['invalid units array', { units: {} }],
|
['invalid units array', { units: {} }],
|
||||||
['invalid unit exp threshold', { units: patchUnit(0, { exp: 100 }) }],
|
['invalid unit exp threshold', { units: patchUnit(0, { exp: 100 }) }],
|
||||||
|
|||||||
@@ -210,6 +210,7 @@ function isAttackIntentArray(value: unknown, options: BattleSaveValidationOption
|
|||||||
isRecord(intent) &&
|
isRecord(intent) &&
|
||||||
typeof intent.attackerId === 'string' &&
|
typeof intent.attackerId === 'string' &&
|
||||||
typeof intent.targetId === 'string' &&
|
typeof intent.targetId === 'string' &&
|
||||||
|
intent.attackerId !== intent.targetId &&
|
||||||
isKnownUnitId(intent.attackerId, options) &&
|
isKnownUnitId(intent.attackerId, options) &&
|
||||||
isKnownUnitId(intent.targetId, options)
|
isKnownUnitId(intent.targetId, options)
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user