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
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 @@ -41,7 +41,7 @@ pub fn upsert_team(conn: &Connection, t: &Team) -> Result<(), String> {

conn.execute(
"INSERT OR REPLACE INTO teams
(id, name, short_name, country, football_nation, city, stadium_name, stadium_capacity,
(id, name, short_name, country, football_nation, city, arena_name, arena_capacity,
finance, manager_id, reputation, wage_budget, transfer_budget,
season_income, season_expenses, formation, play_style,
training_focus, training_intensity, training_schedule,
Expand All @@ -56,8 +56,8 @@ pub fn upsert_team(conn: &Connection, t: &Team) -> Result<(), String> {
t.country,
t.football_nation,
t.city,
t.stadium_name,
t.stadium_capacity,
t.arena_name,
t.arena_capacity,
t.finance,
t.manager_id,
t.reputation,
Expand Down Expand Up @@ -178,8 +178,8 @@ fn row_to_team(row: &rusqlite::Row) -> rusqlite::Result<Team> {
country: row.get(3)?,
football_nation: row.get(4)?,
city: row.get(5)?,
stadium_name: row.get(6)?,
stadium_capacity: row.get(7)?,
arena_name: row.get(6)?,
arena_capacity: row.get(7)?,
finance: row.get(8)?,
manager_id: row.get(9)?,
reputation: row.get(10)?,
Expand Down Expand Up @@ -225,7 +225,7 @@ fn row_to_team(row: &rusqlite::Row) -> rusqlite::Result<Team> {
pub fn load_all_teams(conn: &Connection) -> Result<Vec<Team>, String> {
let mut stmt = conn
.prepare(
"SELECT id, name, short_name, country, football_nation, city, stadium_name, stadium_capacity,
"SELECT id, name, short_name, country, football_nation, city, arena_name, arena_capacity,
finance, manager_id, reputation, wage_budget, transfer_budget,
season_income, season_expenses, formation, play_style,
training_focus, training_intensity, training_schedule,
Expand All @@ -251,7 +251,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, football_nation, city, stadium_name, stadium_capacity,
"SELECT id, name, short_name, country, football_nation, city, arena_name, arena_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 @@ -314,7 +314,7 @@ mod tests {
assert_eq!(loaded.football_nation, "GB");
assert_eq!(loaded.play_style, PlayStyle::Possession);
assert_eq!(loaded.finance, 5_000_000);
assert_eq!(loaded.stadium_capacity, 50000);
assert_eq!(loaded.arena_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,
stadium_name TEXT NOT NULL,
stadium_capacity INTEGER NOT NULL,
arena_name TEXT NOT NULL,
arena_capacity INTEGER NOT NULL,
finance INTEGER NOT NULL DEFAULT 1000000,
manager_id TEXT,
reputation INTEGER NOT NULL DEFAULT 500,
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, football_nation, city, stadium_name, stadium_capacity,
(id, name, short_name, country, football_nation, city, arena_name, arena_capacity,
finance, manager_id, reputation, wage_budget, transfer_budget,
season_income, season_expenses, formation, play_style,
training_focus, training_intensity, training_schedule,
Expand Down
16 changes: 8 additions & 8 deletions src-tauri/crates/domain/src/team.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ pub struct Team {
#[serde(default)]
pub football_nation: String,
pub city: String,
pub stadium_name: String,
pub stadium_capacity: u32,
pub arena_name: String,
pub arena_capacity: u32,

// Current state
pub finance: i64,
Expand Down Expand Up @@ -345,8 +345,8 @@ mod academy_team_metadata_tests {
"short_name": "FNC",
"country": "GB",
"city": "London",
"stadium_name": "Fnatic HQ",
"stadium_capacity": 5000,
"arena_name": "Fnatic HQ",
"arena_capacity": 5000,
"finance": 1000000,
"manager_id": null,
"reputation": 500,
Expand Down Expand Up @@ -1003,8 +1003,8 @@ impl Team {
short_name: String,
country: String,
city: String,
stadium_name: String,
stadium_capacity: u32,
arena_name: String,
arena_capacity: u32,
) -> Self {
let football_nation = crate::identity::normalize_football_nation_code(&country);
Self {
Expand All @@ -1014,8 +1014,8 @@ impl Team {
country,
football_nation,
city,
stadium_name,
stadium_capacity,
arena_name,
arena_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(
stadium_capacity: u32,
arena_capacity: u32,
home_match_count: i64,
attendance_pct: f64,
avg_ticket: f64,
) -> i64 {
let revenue_per_match = (stadium_capacity as f64 * attendance_pct * avg_ticket) as i64;
let revenue_per_match = (arena_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.stadium_capacity,
team.arena_capacity,
home_count,
attendance_pct,
avg_ticket,
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 stadium_name: String,
pub arena_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(),
stadium_name: format!("{} Arena", t.city),
arena_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.stadium_name.is_empty() {
let stadium = if tdef.arena_name.is_empty() {
format!("{} Arena", tdef.city)
} else {
tdef.stadium_name.clone()
tdef.arena_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",
"stadium_name": "London Arena",
"stadium_capacity": 50000,
"arena_name": "London Arena",
"arena_capacity": 50000,
"finance": 1000000,
"manager_id": null,
"reputation": 500,
Expand Down
32 changes: 16 additions & 16 deletions src-tauri/data/default_teams.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"secondary": "#ffffff"
},
"play_style": "Possession",
"stadium_name": "London Arena",
"arena_name": "London Arena",
"reputation_range": [
600,
900
Expand All @@ -32,7 +32,7 @@
"secondary": "#1e3a5f"
},
"play_style": "Attacking",
"stadium_name": "Manchester Arena",
"arena_name": "Manchester Arena",
"reputation_range": [
600,
900
Expand All @@ -52,7 +52,7 @@
"secondary": "#fbbf24"
},
"play_style": "HighPress",
"stadium_name": "Liverpool Arena",
"arena_name": "Liverpool Arena",
"reputation_range": [
500,
850
Expand All @@ -72,7 +72,7 @@
"secondary": "#ffffff"
},
"play_style": "Counter",
"stadium_name": "Newcastle Arena",
"arena_name": "Newcastle Arena",
"reputation_range": [
400,
750
Expand All @@ -92,7 +92,7 @@
"secondary": "#d4af37"
},
"play_style": "Possession",
"stadium_name": "Madrid Arena",
"arena_name": "Madrid Arena",
"reputation_range": [
700,
900
Expand All @@ -112,7 +112,7 @@
"secondary": "#1d4ed8"
},
"play_style": "Attacking",
"stadium_name": "Barcelona Arena",
"arena_name": "Barcelona Arena",
"reputation_range": [
700,
900
Expand All @@ -132,7 +132,7 @@
"secondary": "#1e3a5f"
},
"play_style": "HighPress",
"stadium_name": "Munich Arena",
"arena_name": "Munich Arena",
"reputation_range": [
700,
900
Expand All @@ -152,7 +152,7 @@
"secondary": "#000000"
},
"play_style": "Counter",
"stadium_name": "Dortmund Arena",
"arena_name": "Dortmund Arena",
"reputation_range": [
500,
800
Expand All @@ -172,7 +172,7 @@
"secondary": "#dc2626"
},
"play_style": "Attacking",
"stadium_name": "Paris Arena",
"arena_name": "Paris Arena",
"reputation_range": [
700,
900
Expand All @@ -192,7 +192,7 @@
"secondary": "#ffffff"
},
"play_style": "Balanced",
"stadium_name": "Lyon Arena",
"arena_name": "Lyon Arena",
"reputation_range": [
400,
700
Expand All @@ -212,7 +212,7 @@
"secondary": "#000000"
},
"play_style": "Defensive",
"stadium_name": "Milan Arena",
"arena_name": "Milan Arena",
"reputation_range": [
600,
850
Expand All @@ -232,7 +232,7 @@
"secondary": "#7c2d12"
},
"play_style": "Counter",
"stadium_name": "Rome Arena",
"arena_name": "Rome Arena",
"reputation_range": [
400,
700
Expand All @@ -252,7 +252,7 @@
"secondary": "#ffffff"
},
"play_style": "Attacking",
"stadium_name": "Amsterdam Arena",
"arena_name": "Amsterdam Arena",
"reputation_range": [
500,
800
Expand All @@ -272,7 +272,7 @@
"secondary": "#ffffff"
},
"play_style": "Possession",
"stadium_name": "Lisbon Arena",
"arena_name": "Lisbon Arena",
"reputation_range": [
500,
800
Expand All @@ -292,7 +292,7 @@
"secondary": "#ffffff"
},
"play_style": "Defensive",
"stadium_name": "Porto Arena",
"arena_name": "Porto Arena",
"reputation_range": [
500,
800
Expand All @@ -312,7 +312,7 @@
"secondary": "#fbbf24"
},
"play_style": "Balanced",
"stadium_name": "Brussels Arena",
"arena_name": "Brussels Arena",
"reputation_range": [
400,
700
Expand Down
Loading
Loading