mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-27 13:44:16 +00:00
Improve readability of alliance acceptation logic for bots and add tests (#1049)
## Description: The method deciding whether bots should accept an alliance used to use multiple variables with negated names (notTraitor, notMalice, notTooManyAlliances). For readability, I have negated their value in order to given them a positive name (isTraitor, hasMalice, tooManyAlliances). I have also added tests for the alliances acceptation/rejection behavior of bots. - [x] I have added screenshots for all UI updates - [X] I process any text displayed to the user through translateText() and I've added it to the en.json file - [X] I have added relevant tests to the test directory - [X] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced - [X] I understand that submitting code with bugs that could have been caught through manual testing blocks releases and new features for all contributors Discord: nephty
This commit is contained in:
@@ -202,11 +202,12 @@ export class BotBehavior {
|
||||
}
|
||||
|
||||
function shouldAcceptAllianceRequest(player: Player, request: AllianceRequest) {
|
||||
const notTraitor = !request.requestor().isTraitor();
|
||||
const noMalice = player.relation(request.requestor()) >= Relation.Neutral;
|
||||
const isTraitor = request.requestor().isTraitor();
|
||||
const hasMalice = player.relation(request.requestor()) < Relation.Neutral;
|
||||
const requestorIsMuchLarger =
|
||||
request.requestor().numTilesOwned() > player.numTilesOwned() * 3;
|
||||
const notTooManyAlliances =
|
||||
requestorIsMuchLarger || request.requestor().alliances().length < 3;
|
||||
return notTraitor && noMalice && notTooManyAlliances;
|
||||
const tooManyAlliances = request.requestor().alliances().length >= 3;
|
||||
return (
|
||||
!isTraitor && !hasMalice && (requestorIsMuchLarger || !tooManyAlliances)
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user