Skip to content

Commit 1ce1eae

Browse files
committed
Added evan recommendations
1 parent ed71be8 commit 1ce1eae

File tree

2 files changed

+57
-43
lines changed

2 files changed

+57
-43
lines changed

src/core/execution/DonateGoldExecution.ts

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,9 @@ export class DonateGoldExecution implements Execution {
4747
this.sender.canDonateGold(this.recipient) &&
4848
this.sender.donateGold(this.recipient, this.gold)
4949
) {
50-
// Prevent players from just buying a good relation by sending 1% gold. Instead, a minimum is needed, and it's random.
51-
if (this.gold >= BigInt(this.getMinGoldForRelationUpdate())) {
52-
this.recipient.updateRelation(this.sender, 50);
53-
}
50+
// Give relation points based on how much gold was donated
51+
const relationUpdate = this.calculateRelationUpdate(Number(this.gold));
52+
this.recipient.updateRelation(this.sender, relationUpdate);
5453
} else {
5554
console.warn(
5655
`cannot send gold from ${this.sender.name()} to ${this.recipient.name()}`,
@@ -59,16 +58,31 @@ export class DonateGoldExecution implements Execution {
5958
this.active = false;
6059
}
6160

62-
getMinGoldForRelationUpdate(): number {
61+
getGoldChunkSize(): number {
6362
const { difficulty } = this.mg.config().gameConfig();
64-
if (difficulty === Difficulty.Easy) return this.random.nextInt(0, 25_000);
65-
if (difficulty === Difficulty.Medium)
66-
return this.random.nextInt(25_000, 50_000);
67-
if (difficulty === Difficulty.Hard)
68-
return this.random.nextInt(50_000, 125_000);
69-
if (difficulty === Difficulty.Impossible)
70-
return this.random.nextInt(125_000, 250_000);
71-
return 0;
63+
switch (difficulty) {
64+
case Difficulty.Easy:
65+
return this.random.nextInt(1, 2_500);
66+
case Difficulty.Medium:
67+
return this.random.nextInt(2_500, 5_000);
68+
case Difficulty.Hard:
69+
return this.random.nextInt(5_000, 12_500);
70+
case Difficulty.Impossible:
71+
return this.random.nextInt(12_500, 25_000);
72+
default:
73+
return 2_500;
74+
}
75+
}
76+
77+
calculateRelationUpdate(goldSent: number): number {
78+
const chunkSize = this.getGoldChunkSize();
79+
// Calculate how many complete chunks were donated
80+
const chunks = Math.floor(goldSent / chunkSize);
81+
// Each chunk gives 5 relation points
82+
const relationUpdate = chunks * 5;
83+
// Cap at 100 relation points
84+
if (relationUpdate > 100) return 100;
85+
return relationUpdate;
7286
}
7387

7488
isActive(): boolean {

src/core/execution/DonateTroopExecution.ts

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -56,36 +56,36 @@ export class DonateTroopsExecution implements Execution {
5656

5757
getMinTroopsForRelationUpdate(): number {
5858
const { difficulty } = this.mg.config().gameConfig();
59-
60-
// ~7.7k - ~9.1k troops (for 100k troops)
61-
if (difficulty === Difficulty.Easy)
62-
return this.random.nextInt(
63-
this.sender.troops() / 13,
64-
this.sender.troops() / 11,
65-
);
66-
67-
// ~9.1k - ~11.1k troops (for 100k troops)
68-
if (difficulty === Difficulty.Medium)
69-
return this.random.nextInt(
70-
this.sender.troops() / 11,
71-
this.sender.troops() / 9,
72-
);
73-
74-
// ~11.1k - ~14.3k troops (for 100k troops)
75-
if (difficulty === Difficulty.Hard)
76-
return this.random.nextInt(
77-
this.sender.troops() / 9,
78-
this.sender.troops() / 7,
79-
);
80-
81-
// ~14.3k - ~20k troops (for 100k troops)
82-
if (difficulty === Difficulty.Impossible)
83-
return this.random.nextInt(
84-
this.sender.troops() / 7,
85-
this.sender.troops() / 5,
86-
);
87-
88-
return 0;
59+
const recipientMaxTroops = this.mg.config().maxTroops(this.recipient);
60+
61+
switch (difficulty) {
62+
// ~7.7k - ~9.1k troops (for 100k troops)
63+
case Difficulty.Easy:
64+
return this.random.nextInt(
65+
recipientMaxTroops / 13,
66+
recipientMaxTroops / 11,
67+
);
68+
// ~9.1k - ~11.1k troops (for 100k troops)
69+
case Difficulty.Medium:
70+
return this.random.nextInt(
71+
recipientMaxTroops / 11,
72+
recipientMaxTroops / 9,
73+
);
74+
// ~11.1k - ~14.3k troops (for 100k troops)
75+
case Difficulty.Hard:
76+
return this.random.nextInt(
77+
recipientMaxTroops / 9,
78+
recipientMaxTroops / 7,
79+
);
80+
// ~14.3k - ~20k troops (for 100k troops)
81+
case Difficulty.Impossible:
82+
return this.random.nextInt(
83+
recipientMaxTroops / 7,
84+
recipientMaxTroops / 5,
85+
);
86+
default:
87+
return 0;
88+
}
8989
}
9090

9191
isActive(): boolean {

0 commit comments

Comments
 (0)