Merge pull request #1781 from danielyxie/dev

gang with 0 territory cannot fight
This commit is contained in:
hydroflame 2021-11-24 17:58:37 -05:00 committed by GitHub
commit c2b58ffcce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 67 additions and 61 deletions

24
dist/vendor.bundle.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -190,13 +190,15 @@ export class Gang {
} }
// Then process territory // Then process territory
for (let i = 0; i < GangConstants.Names.length; ++i) { const gangs = GangConstants.Names.filter((g) => AllGangs[g].territory > 0);
const others = GangConstants.Names.filter((e) => { if (gangs.length > 1) {
return e !== GangConstants.Names[i]; for (let i = 0; i < gangs.length; ++i) {
const others = gangs.filter((e) => {
return e !== gangs[i];
}); });
const other = getRandomInt(0, others.length - 1); const other = getRandomInt(0, others.length - 1);
const thisGang = GangConstants.Names[i]; const thisGang = gangs[i];
const otherGang = others[other]; const otherGang = others[other];
// If either of the gangs involved in this clash is the player, determine // If either of the gangs involved in this clash is the player, determine
@ -210,7 +212,10 @@ export class Gang {
const thisChance = thisPwr / (thisPwr + otherPwr); const thisChance = thisPwr / (thisPwr + otherPwr);
function calculateTerritoryGain(winGang: string, loseGang: string): number { function calculateTerritoryGain(winGang: string, loseGang: string): number {
const powerBonus = Math.max(1, 1 + Math.log(AllGangs[winGang].power / AllGangs[loseGang].power) / Math.log(50)); const powerBonus = Math.max(
1,
1 + Math.log(AllGangs[winGang].power / AllGangs[loseGang].power) / Math.log(50),
);
const gains = Math.min(AllGangs[loseGang].territory, powerBonus * 0.0001 * (Math.random() + 0.5)); const gains = Math.min(AllGangs[loseGang].territory, powerBonus * 0.0001 * (Math.random() + 0.5));
return gains; return gains;
} }
@ -244,6 +249,7 @@ export class Gang {
} }
} }
} }
}
processExperienceGains(numCycles = 1): void { processExperienceGains(numCycles = 1): void {
for (let i = 0; i < this.members.length; ++i) { for (let i = 0; i < this.members.length; ++i) {