mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-28 12:30:32 +00:00
Private lobby toggle donation (#1752)
## Description: Resolve #1652 1. Add the ability to toggle **gold donations** and **troop donations** for private lobbies ~2. Add relevant translations.~ 3. Refactor `canDonate` to be specific to gold and troop donations 4. Add placeholders for singleplayer mode if this is to be extended to support that too. 5. Add Tests for Donate logic ### Screenshots: <img width="1643" height="1788" alt="image" src="https://github.com/user-attachments/assets/82b93400-a1f0-45f0-8b2b-a7f78dc0c3e9" /> _Private Lobby_ ### Smoke Tests  _Testing Troop Send In Private Lobby_  _Troop Send Complete In Private Lobby_  Confirming that public teams still works ## 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 have read and accepted the CLA agreement (only required once). ## Please put your Discord username so you can be contacted if a bug or regression is found: DISCORD_USERNAME: cool_clarky --------- Co-authored-by: Scott Anderson <662325+scottanderson@users.noreply.github.com> Co-authored-by: Drills Kibo <59177241+drillskibo@users.noreply.github.com>
This commit is contained in:
co-authored by
Scott Anderson
Drills Kibo
parent
0b35c13ebb
commit
8a41919ed7
@@ -572,7 +572,7 @@ export class PlayerImpl implements Player {
|
||||
return true;
|
||||
}
|
||||
|
||||
canDonate(recipient: Player): boolean {
|
||||
canDonateGold(recipient: Player): boolean {
|
||||
if (!this.isFriendly(recipient)) {
|
||||
return false;
|
||||
}
|
||||
@@ -583,6 +583,36 @@ export class PlayerImpl implements Player {
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
if (this.mg.config().donateGold() === false) {
|
||||
return false;
|
||||
}
|
||||
for (const donation of this.sentDonations) {
|
||||
if (donation.recipient === recipient) {
|
||||
if (
|
||||
this.mg.ticks() - donation.tick <
|
||||
this.mg.config().donateCooldown()
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
canDonateTroops(recipient: Player): boolean {
|
||||
if (!this.isFriendly(recipient)) {
|
||||
return false;
|
||||
}
|
||||
if (
|
||||
recipient.type() === PlayerType.Human &&
|
||||
this.mg.config().gameConfig().gameMode === GameMode.FFA &&
|
||||
this.mg.config().gameConfig().gameType === GameType.Public
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
if (this.mg.config().donateTroops() === false) {
|
||||
return false;
|
||||
}
|
||||
for (const donation of this.sentDonations) {
|
||||
if (donation.recipient === recipient) {
|
||||
if (
|
||||
|
||||
Reference in New Issue
Block a user