diff --git a/game.sqlite b/game.sqlite index 90a750d..c13cb92 100644 Binary files a/game.sqlite and b/game.sqlite differ diff --git a/stars.py b/stars.py index e315b60..89474db 100644 --- a/stars.py +++ b/stars.py @@ -28,11 +28,14 @@ Stars have what qualities? - brightness - size - Game stats + - age? - ? + 🌑 🌒 🌓 🌔 🌕 🌖 🌗 🌘 + ♈ ♉ ♊ ♋ ♌ ♍ ♎ ♏ ♐ ♑ ♒ ♓ ''' -from random import randint, expovariate, seed, getrandbits +from random import randint, expovariate, seed, getrandbits, gauss from poisson import poisson @@ -69,6 +72,15 @@ def generate_list_of_u64_for_ids(n): TABLES = [ 'create table stars (id INTEGER PRIMARY KEY, x INTEGER, y INTEGER, radius INTEGER)', + ('''\ + create table planets ( + id INTEGER PRIMARY KEY, + ordo INTEGER,''' # The order from the star, counting from 1. + # I use "ordo" instead of "order" because "order" is a keyword + # in SQL (or at least it caused a syntax error in SQLite.) + '''star INTEGER, + FOREIGN KEY(star) REFERENCES stars(id) + )'''), ] @@ -77,6 +89,8 @@ def init_db(conn): c = conn.cursor() for values in generate_stars(WIDTH, HEIGHT, MINIMUM_DISTANCE_BETWEEN_STARS): c.execute('insert into stars values (?, ?, ?, ?)', values) + star_id = values[0] + generate_planets_for_star(c, star_id) c.close() conn.commit() @@ -106,4 +120,20 @@ def how_many_planets(): n = round(gauss(5, 5)) return n +def generate_planets_for_star(c, star_id): + n = how_many_planets() + if n < 1: + return + for ordo in range(1, n + 1): + c.execute('insert into planets(ordo, star) values (?, ?)', (ordo, star_id)) + +ROMAN_NUMBERS = [ + None, + 'I', 'II', 'III', 'IV', 'V', + 'VI', 'VII', 'VIII', 'IX', 'X', + 'XI', 'XII', 'XIII', 'XIV', 'XV', + 'XVI', 'XVII', 'XVIII', 'XIX', 'XX', + 'XXI', 'XXII', 'XXIII', 'XXIV', 'XXV', + 'XXVI', 'XXVII', 'XXVIII', 'XXIX', + ]