diff --git a/README.md b/README.md index efbfb44..07c257d 100644 --- a/README.md +++ b/README.md @@ -250,3 +250,18 @@ It would be fun to see if the Treeview widget could handle all the stars and planets... 12,300 planets, 1,948 stars, it should be able to handle it? + +Mon Apr 15 15:48:51 PDT 2024 + +Pop growth on homeworlds only: we want the populations that are on a +planet where that planet is in the home stellar system of the species of +the population. + +planets.star = populations.homestar + +What if in the populations table instead of the species column there is a +home system column? We can get the species name from the homestar name +as needed? + +Is there a good reason not to have the species name with the pops? Extra +space used I guess, maybe? pop.homestar.name + 'ians' diff --git a/data.py b/data.py index aefc348..5f7e171 100644 --- a/data.py +++ b/data.py @@ -62,10 +62,22 @@ TABLES = [ species TEXT, pop INTEGER, planet INTEGER, + vessel INTEGER, + station INTEGER, FOREIGN KEY(planet) REFERENCES planets(id) - )''', + check ( + ( case when planet is null then 0 else 1 end + + case when vessel is null then 0 else 1 end + + case when station is null then 0 else 1 end + ) = 1 + ) + ) + ''', ] +# Apparently this clause should constrain a pop to be +# in only one location at a time. + def initialize_db_tables(filename): conn = open_db(filename) diff --git a/game.sqlite b/game.sqlite index 85b246d..baf6bb0 100644 Binary files a/game.sqlite and b/game.sqlite differ diff --git a/population.py b/population.py index 2eea1fc..391a95f 100644 --- a/population.py +++ b/population.py @@ -52,7 +52,7 @@ def init_db(conn): 'insert into populations(species, pop, planet) values (?, ?, ?)', (people_name, INITIAL_POP, planet_id), ) - print(planet_id, bio, industrial_capacity) + # print(planet_id, bio, industrial_capacity) c.close() conn.commit() @@ -61,8 +61,8 @@ def get_name_of_planets_star(db_cursor, planet_id): # My first ever JOIN statement! Squeeeee! db_cursor.execute( '''\ - select stars.name from stars - join planets + select stars.name from + stars join planets on stars.id = planets.star and planets.id = ? ''',