mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 21:24:14 +00:00
Duo partner SP always same: randomize players before team assignment (#1051)
## Description: See report here: https://discord.com/channels/1284581928254701718/1378762423175221319 In Singleplayer Teams > Duos, your duo partner will be the same every time. In World map for example, it will always Norway. Fix: randomizing Nation players before their team assignment. This is done for all Team modes in Singleplayer and Multiplayer. Other behaviour is unchanged. Clan-players keep their own assignment logic, and Human non-clan player assignment stays the same. The human in singleplayer Duos mode lands in Team 1 everytime but with a different Nation as other team member. BEFORE    AFTER  ## Please complete the following: - [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 ## Please put your Discord username so you can be contacted if a bug or regression is found: tryout33
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import { PlayerInfo, Team } from "./Game";
|
||||
import { PseudoRandom } from "../PseudoRandom";
|
||||
import { simpleHash } from "../Util";
|
||||
import { PlayerInfo, PlayerType, Team } from "./Game";
|
||||
|
||||
export function assignTeams(
|
||||
players: PlayerInfo[],
|
||||
@@ -56,7 +58,19 @@ export function assignTeams(
|
||||
}
|
||||
|
||||
// Then, assign non-clan players to balance teams
|
||||
for (const player of noClanPlayers) {
|
||||
let nationPlayers = noClanPlayers.filter(
|
||||
(player) => player.playerType === PlayerType.FakeHuman,
|
||||
);
|
||||
if (nationPlayers.length > 0) {
|
||||
// Shuffle only nations to randomize their team assignment
|
||||
const random = new PseudoRandom(simpleHash(nationPlayers[0].id));
|
||||
nationPlayers = random.shuffleArray(nationPlayers);
|
||||
}
|
||||
const otherPlayers = noClanPlayers.filter(
|
||||
(player) => player.playerType !== PlayerType.FakeHuman,
|
||||
);
|
||||
|
||||
for (const player of otherPlayers.concat(nationPlayers)) {
|
||||
let team: Team | null = null;
|
||||
let teamSize = 0;
|
||||
for (const t of teams) {
|
||||
|
||||
Reference in New Issue
Block a user