Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ jobs:
name = path.name
if not (name.endswith(allowed_suffixes) or name.endswith(allowed_double_suffixes)):
continue
destination = out_dir / f"olmanager-{version}-{platform}-{name}"
destination = out_dir / f"{name}"
shutil.copy2(path, destination)
copied.append(destination)

Expand Down
24 changes: 12 additions & 12 deletions src-tauri/crates/db/src/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,23 @@ fn migrate_manager_avatar_path(tx: &Transaction<'_>) -> HookResult {
}

fn migrate_stadium_to_arena(tx: &Transaction<'_>) -> HookResult {
add_column_if_missing(tx, "teams", "arena_name", "TEXT")?;
add_column_if_missing(tx, "teams", "stadium_name", "TEXT")?;
// Only migrate data if the legacy column exists (old save files)
if column_exists(tx, "teams", "stadium_name")? {
tx.execute(
"UPDATE teams SET arena_name = COALESCE(stadium_name, 'Unknown Arena') WHERE arena_name IS NULL",
"UPDATE teams SET stadium_name = COALESCE(stadium_name, 'Unknown Arena') WHERE stadium_name IS NULL",
[],
)?;
}
Ok(())
}

fn migrate_stadium_to_arena_capacity(tx: &Transaction<'_>) -> HookResult {
add_column_if_missing(tx, "teams", "arena_capacity", "INTEGER")?;
add_column_if_missing(tx, "teams", "stadium_capacity", "INTEGER")?;
// Only migrate data if the legacy column exists (old save files)
if column_exists(tx, "teams", "stadium_capacity")? {
tx.execute(
"UPDATE teams SET arena_capacity = COALESCE(stadium_capacity, 0) WHERE arena_capacity IS NULL",
"UPDATE teams SET stadium_capacity = COALESCE(stadium_capacity, 0) WHERE stadium_capacity IS NULL",
[],
)?;
}
Expand Down Expand Up @@ -119,8 +119,8 @@ fn migrate_audit_teams_legacy(tx: &Transaction<'_>) -> HookResult {
/// V42 pre-hook: normalize teams schema so the rebuild SQL can run on
/// very old/branch-divergent saves that still use stadium_* names.
fn migrate_prepare_teams_for_v42(tx: &Transaction<'_>) -> HookResult {
add_column_if_missing(tx, "teams", "arena_name", "TEXT")?;
add_column_if_missing(tx, "teams", "arena_capacity", "INTEGER")?;
add_column_if_missing(tx, "teams", "stadium_name", "TEXT")?;
add_column_if_missing(tx, "teams", "stadium_capacity", "INTEGER")?;
add_column_if_missing(
tx,
"teams",
Expand All @@ -130,24 +130,24 @@ fn migrate_prepare_teams_for_v42(tx: &Transaction<'_>) -> HookResult {

if column_exists(tx, "teams", "stadium_name")? {
tx.execute(
"UPDATE teams SET arena_name = COALESCE(arena_name, stadium_name, 'Unknown Arena')",
"UPDATE teams SET stadium_name = COALESCE(stadium_name, stadium_name, 'Unknown Arena')",
[],
)?;
} else {
tx.execute(
"UPDATE teams SET arena_name = COALESCE(arena_name, 'Unknown Arena')",
"UPDATE teams SET stadium_name = COALESCE(stadium_name, 'Unknown Arena')",
[],
)?;
}

if column_exists(tx, "teams", "stadium_capacity")? {
tx.execute(
"UPDATE teams SET arena_capacity = COALESCE(arena_capacity, stadium_capacity, 0)",
"UPDATE teams SET stadium_capacity = COALESCE(stadium_capacity, stadium_capacity, 0)",
[],
)?;
} else {
tx.execute(
"UPDATE teams SET arena_capacity = COALESCE(arena_capacity, 0)",
"UPDATE teams SET stadium_capacity = COALESCE(stadium_capacity, 0)",
[],
)?;
}
Expand Down Expand Up @@ -374,9 +374,9 @@ pub fn all_migrations() -> Migrations<'static> {
M::up("SELECT 1;"),
// V34: Add profile_image_url to staff (no-op: already handled by V29 hook)
M::up("SELECT 1;"),
// V35: Rename stadium_name to arena_name for LoL terminology
// V35: Rename stadium_name to stadium_name for LoL terminology
M::up_with_hook("SELECT 1;", migrate_stadium_to_arena),
// V36: Rename stadium_capacity to arena_capacity for LoL terminology
// V36: Rename stadium_capacity to stadium_capacity for LoL terminology
M::up_with_hook("SELECT 1;", migrate_stadium_to_arena_capacity),
// V37: Rename legacy football stat tables to _deprecated_ prefix
M::up(include_str!("sql/v037_rename_legacy_stats.sql")),
Expand Down
16 changes: 8 additions & 8 deletions src-tauri/crates/db/src/repositories/team_repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub fn upsert_team(conn: &Connection, t: &Team) -> Result<(), String> {

conn.execute(
"INSERT OR REPLACE INTO teams
(id, name, short_name, country, city, arena_name, arena_capacity,
(id, name, short_name, country, city, stadium_name, stadium_capacity,
finance, manager_id, reputation, wage_budget, transfer_budget,
season_income, season_expenses, formation, play_style,
training_focus, training_intensity, training_schedule,
Expand All @@ -63,8 +63,8 @@ pub fn upsert_team(conn: &Connection, t: &Team) -> Result<(), String> {
t.short_name,
t.country,
t.city,
t.arena_name,
t.arena_capacity,
t.stadium_name,
t.stadium_capacity,
t.finance,
t.manager_id,
t.reputation,
Expand Down Expand Up @@ -210,8 +210,8 @@ fn row_to_team(row: &rusqlite::Row) -> rusqlite::Result<Team> {
short_name: row.get(2)?,
country: row.get(3)?,
city: row.get(4)?,
arena_name: row.get(5)?,
arena_capacity: row.get(6)?,
stadium_name: row.get(5)?,
stadium_capacity: row.get(6)?,
finance: row.get(7)?,
manager_id: row.get(8)?,
reputation: row.get(9)?,
Expand Down Expand Up @@ -272,7 +272,7 @@ fn row_to_team(row: &rusqlite::Row) -> rusqlite::Result<Team> {
/// Load all teams.
pub fn load_all_teams(conn: &Connection) -> Result<Vec<Team>, String> {
log::info!("[team_repo] load_all_teams: preparing query...");
let query = "SELECT id, name, short_name, country, city, arena_name, arena_capacity,
let query = "SELECT id, name, short_name, country, city, stadium_name, stadium_capacity,
finance, manager_id, reputation, wage_budget, transfer_budget,
season_income, season_expenses, formation, play_style,
training_focus, training_intensity, training_schedule,
Expand Down Expand Up @@ -364,7 +364,7 @@ pub fn load_all_teams(conn: &Connection) -> Result<Vec<Team>, String> {
pub fn load_team(conn: &Connection, id: &str) -> Result<Option<Team>, String> {
let mut stmt = conn
.prepare(
"SELECT id, name, short_name, country, city, arena_name, arena_capacity,
"SELECT id, name, short_name, country, city, stadium_name, stadium_capacity,
finance, manager_id, reputation, wage_budget, transfer_budget,
season_income, season_expenses, formation, play_style,
training_focus, training_intensity, training_schedule,
Expand Down Expand Up @@ -429,7 +429,7 @@ mod tests {
assert_eq!(loaded.short_name, "TST");
assert_eq!(loaded.play_style, PlayStyle::Possession);
assert_eq!(loaded.finance, 5_000_000);
assert_eq!(loaded.arena_capacity, 50000);
assert_eq!(loaded.stadium_capacity, 50000);
}

#[test]
Expand Down
4 changes: 2 additions & 2 deletions src-tauri/crates/db/src/sql/v001_initial_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ CREATE TABLE teams (
short_name TEXT NOT NULL,
country TEXT NOT NULL,
city TEXT NOT NULL,
arena_name TEXT NOT NULL,
arena_capacity INTEGER NOT NULL,
stadium_name TEXT NOT NULL,
stadium_capacity INTEGER NOT NULL,
finance INTEGER NOT NULL DEFAULT 1000000,
manager_id TEXT,
reputation INTEGER NOT NULL DEFAULT 500,
Expand Down
6 changes: 3 additions & 3 deletions src-tauri/crates/db/src/sql/v035_stadium_to_arena.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- V35: Rename stadium_name to arena_name for LoL terminology
-- V35: Rename stadium_name to stadium_name for LoL terminology
-- This handles old saves that still have stadium_name
ALTER TABLE teams ADD COLUMN arena_name TEXT;
UPDATE teams SET arena_name = COALESCE(stadium_name, 'Unknown Arena') WHERE arena_name IS NULL;
ALTER TABLE teams ADD COLUMN stadium_name TEXT;
UPDATE teams SET stadium_name = COALESCE(stadium_name, 'Unknown Arena') WHERE stadium_name IS NULL;
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
-- V36: Rename stadium_capacity to arena_capacity for LoL terminology
ALTER TABLE teams ADD COLUMN arena_capacity INTEGER;
UPDATE teams SET arena_capacity = COALESCE(stadium_capacity, 0) WHERE arena_capacity IS NULL;
-- V36: Rename stadium_capacity to stadium_capacity for LoL terminology
ALTER TABLE teams ADD COLUMN stadium_capacity INTEGER;
UPDATE teams SET stadium_capacity = COALESCE(stadium_capacity, 0) WHERE stadium_capacity IS NULL;
6 changes: 3 additions & 3 deletions src-tauri/crates/db/src/sql/v042_drop_dead_team_columns.sql
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ CREATE TABLE teams_new (
short_name TEXT NOT NULL,
country TEXT NOT NULL,
city TEXT NOT NULL,
arena_name TEXT NOT NULL,
arena_capacity INTEGER NOT NULL DEFAULT 0,
stadium_name TEXT NOT NULL,
stadium_capacity INTEGER NOT NULL DEFAULT 0,
finance INTEGER NOT NULL DEFAULT 1000000,
manager_id TEXT,
reputation INTEGER NOT NULL DEFAULT 500,
Expand Down Expand Up @@ -72,7 +72,7 @@ CREATE TABLE teams_new (

INSERT INTO teams_new SELECT
id, name, short_name, country, city,
arena_name, arena_capacity,
stadium_name, stadium_capacity,
finance, manager_id, reputation,
wage_budget, transfer_budget, season_income, season_expenses,
formation, play_style,
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/crates/db/tests/academy_team_persistence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ fn legacy_team_rows_load_as_main_without_academy_metadata() {
db.conn()
.execute(
r#"INSERT INTO teams
(id, name, short_name, country, city, arena_name, arena_capacity,
(id, name, short_name, country, city, stadium_name, stadium_capacity,
finance, reputation, formation, play_style,
team_kind)
VALUES
Expand Down
20 changes: 10 additions & 10 deletions src-tauri/crates/domain/src/team.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ pub struct Team {
pub short_name: String,
pub country: String,
pub city: String,
pub arena_name: String,
pub arena_capacity: u32,
pub stadium_name: String,
pub stadium_capacity: u32,

// Current state
pub finance: i64,
Expand Down Expand Up @@ -393,8 +393,8 @@ mod academy_team_metadata_tests {
"short_name": "FNC",
"country": "GB",
"city": "London",
"arena_name": "Fnatic HQ",
"arena_capacity": 5000,
"stadium_name": "Fnatic HQ",
"stadium_capacity": 5000,
"finance": 1000000,
"manager_id": null,
"reputation": 500,
Expand Down Expand Up @@ -424,8 +424,8 @@ mod academy_team_metadata_tests {
"short_name": "G2",
"country": "DE",
"city": "Berlin",
"arena_name": "G2 Arena",
"arena_capacity": 10000,
"stadium_name": "G2 Arena",
"stadium_capacity": 10000,
"finance": 1000000,
"manager_id": null,
"reputation": 500,
Expand Down Expand Up @@ -1207,17 +1207,17 @@ impl Team {
short_name: String,
country: String,
city: String,
arena_name: String,
arena_capacity: u32,
stadium_name: String,
stadium_capacity: u32,
) -> Self {
Self {
id,
name,
short_name,
country,
city,
arena_name,
arena_capacity,
stadium_name,
stadium_capacity,
finance: 1_000_000,
manager_id: None,
reputation: 500,
Expand Down
6 changes: 3 additions & 3 deletions src-tauri/crates/ofm_core/src/finances.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ pub fn calc_cash_runway_weeks(balance: i64, projected_weekly_net: i64) -> Option
}

pub fn calc_matchday(
arena_capacity: u32,
stadium_capacity: u32,
home_match_count: i64,
attendance_pct: f64,
avg_ticket: f64,
) -> i64 {
let revenue_per_match = (arena_capacity as f64 * attendance_pct * avg_ticket) as i64;
let revenue_per_match = (stadium_capacity as f64 * attendance_pct * avg_ticket) as i64;

revenue_per_match * home_match_count
}
Expand Down Expand Up @@ -318,7 +318,7 @@ pub fn process_weekly_finances(game: &mut Game) {
let attendance_pct = rng.random_range(15..=30) as f64 / 100.0;
let avg_ticket = rng.random_range(4..=8) as f64;
let total_revenue =
calc_matchday(team.arena_capacity, home_count, attendance_pct, avg_ticket);
calc_matchday(team.stadium_capacity, home_count, attendance_pct, avg_ticket);

team.finance += total_revenue;
team.season_income += total_revenue;
Expand Down
4 changes: 2 additions & 2 deletions src-tauri/crates/ofm_core/src/generator/definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub struct TeamDef {
#[serde(default = "default_play_style")]
pub play_style: String,
#[serde(default)]
pub arena_name: String,
pub stadium_name: String,
#[serde(default)]
pub reputation_range: Option<[u32; 2]>,
#[serde(default)]
Expand Down Expand Up @@ -119,7 +119,7 @@ pub(super) fn default_teams_definition() -> TeamsDefinition {
secondary: t.colors.1.to_string(),
},
play_style: t.play_style.to_string(),
arena_name: format!("{} Arena", t.city),
stadium_name: format!("{} Arena", t.city),
reputation_range: Some([300, 900]),
finance_range: Some([500_000, 10_000_000]),
})
Expand Down
4 changes: 2 additions & 2 deletions src-tauri/crates/ofm_core/src/generator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ pub fn generate_world(
} else {
tdef.short_name.clone()
};
let stadium = if tdef.arena_name.is_empty() {
let stadium = if tdef.stadium_name.is_empty() {
format!("{} Arena", tdef.city)
} else {
tdef.arena_name.clone()
tdef.stadium_name.clone()
};

let rep_range = tdef.reputation_range.unwrap_or([300, 900]);
Expand Down
4 changes: 2 additions & 2 deletions src-tauri/crates/ofm_core/src/generator/world_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ mod tests {
"short_name": "LFC",
"country": "GB",
"city": "London",
"arena_name": "London Arena",
"arena_capacity": 50000,
"stadium_name": "London Arena",
"stadium_capacity": 50000,
"finance": 1000000,
"manager_id": null,
"reputation": 500,
Expand Down
Loading
Loading