feat: chemistry calculation engine #7
Reference in New Issue
Block a user
Delete Branch "feat/chemistry-engine"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Adds the foundation for FIFA-style team chemistry calculation.
src/services/chemistry.rsmodule withcalculate_chemistry(cards: &[CardDefinition]) -> ChemistryResultCloses #1
What still needs to be done before merging
This PR is a scaffold — the service logic is complete but it is not yet wired into the HTTP layer. The following tasks remain:
Register the module in
src/services/mod.rs:Wire into
POST /squadinsrc/routes/squad.rs:SquadPlayer'sowned_card_idto aCardDefinition(viacard_db), callcalculate_chemistry(&resolved_cards)and include the result in the response JSON.Wire into
GET /squad— same approach, return the chemistry block alongside the squad.Add
GET /squad/chemistryendpoint insrc/routes/squad.rsthat returns onlyChemistryResultfor the active squad.Add formation position penalty — the current implementation does link scoring only; subtract 1 from a player whose
position_overrideorposition_indexmaps to a different position slot than their natural position.Add integration tests in
tests/chemistry.rs:GET /squad, assertchemistry.totalis within the expected range.Run
cargo clippy -- -D warningsafter wiring to catch any unused-import or dead-code warnings.Test plan
cargo test -p openfut-core chemistrypassesPOST /squadresponse body containschemistrykeyGET /squadresponse body containschemistrykeyGET /squad/chemistryreturns{ total, per_player }onlycargo clippy -- -D warningscleanView command line instructions
Checkout
From your project repository, check out a new branch and test the changes.