36 Commits

Author SHA1 Message Date
DevelopingTom bd820425ba SAMs should target only nukes aimed at nearby targets (#1038)
## Description:

Currently, SAMs target any nuke within range. This can be frustrating
when a random SAM from another player intercepts your nuke, especially
since nukes follow a curved trajectory, leaving little room to adjust
their path.

This change modifies how SAMs intercept nukes: they will now only target
those whose impact points are near the SAM.
The “target range” is still generous, allowing players to defend against
Hydrogen bombs, while preventing random SAMs to intercept your valued
nukes.

In this example, the target was the opponent missile silo:


https://github.com/user-attachments/assets/0d8be2ac-e04d-44a4-a67e-54836cce8899



## 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:

IngloriousTom
2025-06-04 10:18:51 -07:00
Scott Anderson 40932b9f5f Fix bigint serialization error (#916)
## Description:

- JSON serialization, bigint to string handling
- JSON deserialization, string to bigint handling

## Please complete the following:

- [x] I have added screenshots for all UI updates
- [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

---------

Co-authored-by: Scott Anderson <662325+scottanderson@users.noreply.github.com>
2025-05-28 10:33:20 -07:00
Scott Anderson 8cf2d86a70 Convert stats to bigints (#909)
Fixes #880

## Description:

Convert numeric stat types to bigint, and serialize those values as
strings.

## Please complete the following:

- [x] I have added screenshots for all UI updates
- [ ] 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

---------

Co-authored-by: Scott Anderson <662325+scottanderson@users.noreply.github.com>
2025-05-27 19:13:05 -07:00
evanpelle 4d3fa6425b Bugfix: don't allow other players to move warships (#879)
## Description:
The MoveWarshipExecution now verifies that the player who requested to
move owns the warship. This prevents players from moving other players'
warships.

## Please complete the following:

- [x] I have added screenshots for all UI updates
- [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:

evan
2025-05-25 13:24:04 -07:00
Théodore Noel 5b27bee3bd Allow lowercase letters in clan name (#877)
## Description:

Added possibility to use lowercase letters in clan name.
See issue #876 

## Please complete the following:

- [x] I have added screenshots for all UI updates
- [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:

theodoreleon.aetarax
2025-05-25 14:02:13 -04:00
evanpelle d35d0f38cb refactor & update warships (#796)
## Description:
1. Refactor WarshipExecution so that it takes either attrs or a warship
unit. This makes testing much simpler as the unit test can construct a
warship and then pass it into a warship execution
2. Have MoveWarshipExecution set the patrol tile, not the move tile so
warships stay in new location instead of moving back to original
location.
3. Warships no longer target trade ships outside of its patrol range.
this prevents warships from wandering
4. Refactored & simplified WarshipExecution
5. Added more tests for warships
6. Move health modification from PlayerExecution to WarshipExecution
since Warships are the only unit that have health
7. Move fields from WarshipExecution to the Warship unit itself, this
allows other executions & components to see more data about the warship.



## Please complete the following:

- [x] I have added screenshots for all UI updates
- [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:

<DISCORD USERNAME>
2025-05-24 13:42:56 -07:00
DevelopingTom 256ac3b1b8 SAM not working against MIRV warhead (#818)
## Description:

The nukes are setting a `detonationDst` that is never used in UnitImpl.

Without the target tile, SAM launchers ignore the MIRV warheads.

Illustration with 50 SAM vs 2 warhead:

![image](https://github.com/user-attachments/assets/cac20dc6-9a28-4801-a834-364fa36b612d)



The nuke icon is also staying white while being nuked:

![image](https://github.com/user-attachments/assets/badf6630-9a5e-4491-b1b7-1008d32f5efc)


## Please complete the following:

- [x] I have added screenshots for all UI updates
- [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:

IngloriousTom
2025-05-22 23:47:06 -04:00
evanpelle 2f091bf24b reduce log spam during test: use debug logging for map generation, disable debug logging for unit tests 2025-05-17 18:32:22 -07:00
evanpelle 500b5fcfde Clean up and refactor the Unit class (#769)
## Description:

* Merged similar fields so they can be reused (eg warshipTarget =>
targetUnit)
* simplified isCooldown api
* added "touch" method to send update to UI layer
* standardized on "undefined"


## Please complete the following:

- [ ] I have added screenshots for all UI updates
- [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:

<DISCORD USERNAME>
evan

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **Refactor**
- Unified and simplified how unit targets and cooldowns are managed
across all unit types, resulting in more consistent in-game behavior for
nukes, warships, trade ships, and SAM launchers.
- Updated naming and logic for unit targeting and cooldowns, improving
clarity in status displays and interactions.
- Reorganized unit interface and streamlined cooldown handling for
smoother gameplay experience.
- **Bug Fixes**
- Corrected visual indicators for nukes and warships to accurately
reflect their targets.
- **Tests**
- Updated automated tests to align with the new cooldown and targeting
logic.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-17 17:45:10 -07:00
Scott Anderson 70745faac4 Enable strictNullChecks, eqeqeq (#436)
## Description:

Improve type safety and runtime correctness by:
1. Enabling TypeScript's
[strictNullChecks](https://www.typescriptlang.org/tsconfig/#strictNullChecks)
compiler option.
2. Replacing all loose equality operators (`==` and `!=`) with strict
equality operators (`===` and `!==`).
3. Cleaning up of type declarations, null handling logic, and equality
expressions throughout the project.

Currently, the code allows implicit assumptions that `null` and
`undefined` are interchangeable, and relies on type-coercing equality
checks that can introduce subtle bugs. These practices make it difficult
to reason about when values may be absent and hinder the effectiveness
of static analysis.

Migrating to strict null checks and enforcing strict equality
comparisons will clarify intent, reduce bugs, and make the codebase
safer and easier to maintain.

Fixes #466 

## Please complete the following:

- [x] I have added screenshots for all UI updates
- [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

---------

Co-authored-by: Scott Anderson <662325+scottanderson@users.noreply.github.com>
Co-authored-by: evanpelle <openfrontio@gmail.com>
2025-05-15 16:39:40 -07:00
DevelopingTom 3b9e94ddb9 Improve border drawing performances (#751)
## Description:
When drawing the border colors, the territory layer is using the generic
`nearbyUnit` function to check if any allied outpost is nearby.
But `nearbyUnit` is uselesly computing the distance with all units,
which is very costly specially in late games with plenty of units.

Early game (<1 min):


![image](https://github.com/user-attachments/assets/faa90c82-a7dd-43db-b2ff-1f6cd24b24cd)

Late game (> 10 min):


![image](https://github.com/user-attachments/assets/863d4d1a-6d5e-4971-a66c-461a876ca53f)

This PR adds another function tailored for this requirement.
## Improvements:
- New `hasNearbyUnit()` function stopping at the first correct unit,
rather than computing the distance with every unit
- Check the unit type before computing its distance
- Selecting the correct cells:
The previous algorithm was very generous and looking at cells uselessly.
Admittedly this is marginal but since it is called on every border pixel
change, we should squeeze the most performances out of it.



![overflow](https://github.com/user-attachments/assets/22b26c49-ba9d-4050-8ccd-9dde48913720)


Performances after (with bots):
Early:

![image](https://github.com/user-attachments/assets/f78d08d4-938c-466b-b8b3-9d1ad57b5dfb)

Late:

![image](https://github.com/user-attachments/assets/c12a8793-4039-4278-9413-07b2af5c8f3d)

Both Chrome and Firefox seems to benefit from it:
Previous behavior on chrome:
![Sans
titre](https://github.com/user-attachments/assets/e10256f7-dcc0-47c7-8878-fa0ce8a02b39)
After:
![Sans
titre-1](https://github.com/user-attachments/assets/15747e02-69fd-45a2-90f8-389250f261cd)


## Please complete the following:

- [x] I have added screenshots for all UI updates
- [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:

IngloriousTom
2025-05-15 11:25:12 -07:00
Scott Anderson f8a052a6ce Client JWT authentication (#723)
## Description:

Send JWT to the game server for verification.

## Please complete the following:

- [x] I have added screenshots for all UI updates
- [ ] 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

---------

Co-authored-by: Scott Anderson <662325+scottanderson@users.noreply.github.com>
2025-05-12 11:51:40 -07:00
evanpelle 0dc68ced31 Add pause button when replaying (#726)
## Description:

This PR does two things:

1. Allow pausing on replay
2. As part of the refactoring, in singleplayer games, LocalServer now
waits for the last turn to complete execution before sending the next
turn. Previously, low end devices would sometimes fall behind getting
the "playing the past" bug where commands were delayed. Now when a
devices cannot keep up, the entire game slows down.

## Please complete the following:

- [ ] I have added screenshots for all UI updates
- [ ] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced
- [ ] 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:

<DISCORD USERNAME>

Co-authored-by: evan <openfrontio@gmail.com>
2025-05-11 13:28:38 -07:00
evanpelle 1d0732d3d9 Refactor UnitSpecific info => AllUnitParams type union (#701)
## Description:

By using a type union we get better type safety, enforcing each unit
type have the appropriate params when initializing

## Please complete the following:

- [x] I have added screenshots for all UI updates
- [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:
evan

---------

Co-authored-by: evan <openfrontio@gmail.com>
2025-05-10 11:40:47 -07:00
evan d49272e17e teammode: bots can attack each other now to prevent them from ganging up on players 2025-05-06 09:52:13 -07:00
Loymdayddaud f700c53154 change team order to Red, Blue, Yellow, Green, Teal, Orange, Purple (#615)
## Description:
Changes the team order to Red, Blue, Yellow, Green, Orange, Purple, Teal
instead of what it originally was (Red, Blue, Teal, Purple, Yellow,
Orange, Green)
Teal and Blue look similar, so I think it's better to move them further
apart. Instead, the primary colors are chosen first.
Fixes #614

In the long run, I think it would be nice to have the teams randomly
chosen from available colors and not always in the same order - e.g. a
three-team game isn't always Red, Blue, and Yellow, it could be any mix
of the colors. However, my programming skills aren't great enough to do
that.

## Please complete the following:

- [x] I have added screenshots for all UI updates
- [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:
Spartan Oligarchy/Loymdayddaud
2025-05-02 14:01:10 -07:00
evanpelle ffc2fadc20 use otel for observability (#635)
## Description:

## Please complete the following:

- [ ] I have added screenshots for all UI updates
- [ ] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced
- [ ] 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:

<DISCORD USERNAME>

Co-authored-by: evan <openfrontio@gmail.com>
2025-05-01 11:22:56 -07:00
evanpelle d6a412aa50 implement duos (#630)
## Description:
Implement Duos team mode.
Also assign teams to nations at the start instead of assigning them
randomly on spawn. This gives more consistent team sizes

## Please complete the following:

- [x] I have added screenshots for all UI updates
- [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:

<DISCORD USERNAME>

Co-authored-by: evan <openfrontio@gmail.com>
2025-04-30 13:47:35 -07:00
evanpelle 71849b47cd better transport ship spawn (#587)
## Description:

Taken from PR #506

Improve transport source tile by considering border extremums

Only calculate better spawn tile for humans, and have the sender
calculate it and send the src tile in the intent for better performance.

## Please complete the following:

- [x] I have added screenshots for all UI updates
- [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:

<DISCORD USERNAME>
evan

Co-authored-by: evan <openfrontio@gmail.com>
2025-04-21 19:49:17 -07:00
Evan 9de072c0c6 fix failing SAM test 2025-04-18 14:26:19 -07:00
Scott Anderson 5167f67b96 Allow up to seven teams for players (#445)
## Description:

- Allow up to seven teams for players, and one for bots.
- Add team count selection to the single player dialog.
- Select random number of teams in server rotation.

Fixes #456

## Please complete the following:

- [x] I have added screenshots for all UI updates
- [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


![image](https://github.com/user-attachments/assets/cbc1ba82-9d06-4763-896c-abdce067a161)


![image](https://github.com/user-attachments/assets/9f82a0a5-c0bb-49b6-a714-2b13286a64ca)

## Please put your Discord username so you can be contacted if a bug or
regression is found:

fake.neo

---------

Co-authored-by: Scott Anderson <662325+scottanderson@users.noreply.github.com>
2025-04-15 19:02:58 -07:00
Evan c7356a7348 have Team be an enum instead of an object, this was causing equality problems. 2025-04-05 21:39:12 -07:00
Evan 924ca2c69e bugfix: humans start with zero troops on teams, also removed manpower argument to addPlayer() 2025-04-04 10:03:00 -07:00
Evan 8b6895d745 add prettier import plugin 2025-03-31 13:09:27 -07:00
Ilan Schemoul 11791719e4 nukes now reduce attacking troops and transport ships (same as rest of pop) (#350)
Co-authored-by: Evan <evanpelle@gmail.com>
2025-03-31 12:39:18 -07:00
evanpelle 6d5f218a44 sort teams based on clans (#381)
## Description:
Teams are not sorted based on clans, clan members always stay on the
same team.

## Please complete the following:

- [x] I have added screenshots for all UI updates
- [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:

<DISCORD USERNAME>
2025-03-30 19:37:48 -07:00
evanpelle ab3f4fbac1 All players must join game before spawn (#380)
## Description:
The server stores all players that have joined, and once the game starts
it sends a list of players to all clients. Players cannot join after the
game has started. Server now generated the PlayerID instead of the
client.

The is necessary for team mode, we need to know how who is playing the
game before it starts so we can properly assign teams based on clans.

## Please complete the following:

- [x] I have added screenshots for all UI updates
- [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:

evan
2025-03-30 17:04:29 -07:00
Evan 83eec17717 add clan() function on playerinfo and Player 2025-03-29 15:24:11 -07:00
Readixyee 0891637eb2 MissileSilo cooldown (#309)
changed the sam cooldown to be a general cooldown function and added a
missilesilo cooldown

The function either adds the current tick as the starting point of the
cooldown or sets the cooldown to null and updates the unit. That way
getcooldown function can be used to get back the tick the cooldown was
started and can be compared to the cooldown set in the config.

changed the sam test / added a missilesilo test

---------

Co-authored-by: evanpelle <evanpelle@gmail.com>
2025-03-29 15:19:07 -07:00
Ilan Schemoul f2193edc7c priortize ally ports and close ports (#335)
2x more likely to trade with ports belonging to an ally OR close.
3x more likely to trade with ports belonging to an ally AND close.
Add trading tests
2025-03-27 16:09:58 -07:00
Ilan Schemoul 68621f326a sam do not target twice same nuke (#270) 2025-03-21 10:17:33 -07:00
Evan 8e05268863 add region to worker metrics 2025-03-19 10:49:41 -07:00
Ilan Schemoul 40b7fe9833 feat: add warship tests (#291) 2025-03-18 20:35:31 -07:00
evanpelle cd1f8b9586 add testing infrastructure and example test (#276) 2025-03-17 12:20:23 -07:00
Evan 2df3db7292 format root dir 2025-02-12 08:38:56 -08:00
evanpelle 05f55c490f First Commit 2024-08-04 19:51:23 -07:00