thetawavegame / thetawave

A physics based, space shooter game made with Rust and the Bevy engine.
https://thetawave.metalmancy.tech
MIT License
163 stars 9 forks source link

Fix/persist total shots hit to compute accuracy across all games #84

Closed varoonp123 closed 1 year ago

varoonp123 commented 1 year ago

The main menu always shows accuracy = 0%. I forgot to include that field in the ones we persist to sqlite. The changes to the tests will fail without the corresponding code change.

     Running unittests src/lib.rs (target/debug/deps/thetawave_storage-9d08f2ece7e32511)

running 1 test
2023-08-17T17:23:57.975751Z  INFO thetawave_storage::core: Created sqlite db
2023-08-17T17:23:57.976845Z  INFO thetawave_storage::plugin: Flushing mob kills to db {0: {Drone: 15}}
2023-08-17T17:23:57.977033Z  INFO thetawave_storage::user_stats: Preparing db upsert
    INSERT OR REPLACE INTO UserStat (userId, totalShotsFired, totalGamesLost)
    VALUES (?1,  ?2, ?3)
    ON CONFLICT DO UPDATE SET totalShotsFired=?2, totalGamesLost=?3 with param n_shots=15
test plugin::test::test_recover_resources_from_db_after_mock_program_restart ... FAILED

failures:

---- plugin::test::test_recover_resources_from_db_after_mock_program_restart stdout ----
thread 'plugin::test::test_recover_resources_from_db_after_mock_program_restart' panicked at 'assertion failed: `(left == right)`
  left: `UserStat { total_shots_fired: 15, total_shots_hit: 0, total_games_lost: 2 }`,
 right: `UserStat { total_shots_fired: 15, total_shots_hit: 10, total_games_lost: 2 }`', crates/thetawave_storage/src/plugin.rs:231:9