From 31ff9e346b238f66b438ec2b9acbd4caf8ad19f1 Mon Sep 17 00:00:00 2001 From: Ethan Ruszanowski Date: Fri, 1 Mar 2024 14:44:37 -0500 Subject: [PATCH] Add creature spawn chance --- database-scripts/create.sql | 82 ++++++++-------- database-scripts/spawn_chance.sql | 154 +++++++++++++++++++++++++++++- database/database.py | 4 +- scouter.db | Bin 77824 -> 77824 bytes 4 files changed, 197 insertions(+), 43 deletions(-) diff --git a/database-scripts/create.sql b/database-scripts/create.sql index d1c0add..e9bfbd6 100644 --- a/database-scripts/create.sql +++ b/database-scripts/create.sql @@ -1,54 +1,53 @@ create table creature_type ( - creature_type_id int - primary key, - type_name text not null + creature_type_id int, + type_name text not null, + primary key (creature_type_id) ); create table layout ( - layout_id int - primary key, - layout_name text not null + layout_id int, + layout_name text not null, + primary key (layout_id) ); create table moon_tier ( - moon_tier_id int - primary key, - tier_name text not null + moon_tier_id int, + tier_name text not null, + primary key (moon_tier_id) ); create table risk_level ( - risk_level_id int - primary key, - risk_level_name text not null + risk_level_id int, + risk_level_name text not null, + primary key (risk_level_id) ); create table moon ( - moon_id int - primary key, + moon_id int, moon_name text not null, - risk_level_id int not null - references risk_level, + risk_level_id int not null, cost int not null, - default_layout_id int not null - references layout, + default_layout_id int not null, map_size_multiplier real not null, min_scrap int not null, max_scrap int not null, outside_max_power int not null, inside_max_power int not null, - moon_tier_id int not null - references moon_tier + moon_tier_id int not null, + primary key (moon_id), + foreign key (risk_level_id) references risk_level, + foreign key (default_layout_id) references layout, + foreign key (moon_tier_id) references moon_tier ); create table creature ( - creature_id int - primary key, + creature_id int, creature_name text not null, creature_nickname text, health int, @@ -58,47 +57,48 @@ create table creature stun_multiplier real, door_open_speed real, hostile int not null, - creature_type_id int not null - references creature_type, - favorite_moon_id int not null - references moon + creature_type_id int not null, + favorite_moon_id int not null, + primary key (creature_id), + foreign key (creature_type_id) references creature_type, + foreign key (favorite_moon_id) references moon ); create table scrap ( - scrap_id int - primary key, + scrap_id int, scrap_name text not null, min_value int not null, max_value int not null, weight int not null, conductive int not null, - two_handed int not null + two_handed int not null, + primary key (scrap_id) ); create table spawn_chance ( - moon_id int not null - references moon, - creature_id int not null - references creature, - spawn_chance real not null + moon_id int not null, + creature_id int not null, + spawn_chance real not null, + foreign key (moon_id) references moon, + foreign key (creature_id) references creature ); create table weather ( - weather_id int - primary key, + weather_id int, weather_name text not null, - effect text + effect text, + primary key (weather_id) ); create table viable_weather ( - moon_id int not null - references moon, - weather_id int not null - references weather + moon_id int not null, + weather_id int not null, + foreign key (moon_id) references moon, + foreign key (weather_id) references weather ); diff --git a/database-scripts/spawn_chance.sql b/database-scripts/spawn_chance.sql index 1c8a0e7..f534e25 100644 --- a/database-scripts/spawn_chance.sql +++ b/database-scripts/spawn_chance.sql @@ -1 +1,153 @@ -; \ No newline at end of file +insert into main.spawn_chance (moon_id, creature_id, spawn_chance) +values (1, 10, 0), + (1, 11, 0), + (1, 12, 0), + (1, 14, 0), + (1, 16, 0), + (1, 7, 0.44), + (1, 9, 0.44), + (1, 4, 5.73), + (1, 5, 7.05), + (1, 3, 12.33), + (1, 8, 12.33), + (1, 6, 13.66), + (1, 17, 14.86), + (1, 1, 22.47), + (1, 2, 25.55), + (1, 19, 35.14), + (1, 15, 42.75), + (1, 18, 50), + (1, 13, 57.25), + (2, 10, 0), + (2, 11, 0), + (2, 12, 0), + (2, 14, 0.52), + (2, 16, 10.31), + (2, 7, 0.31), + (2, 9, 0.31), + (2, 4, 4.35), + (2, 5, 7.45), + (2, 3, 24.22), + (2, 8, 4.35), + (2, 6, 8.7), + (2, 17, 21.39), + (2, 1, 28.88), + (2, 2, 21.43), + (2, 19, 28.86), + (2, 15, 48.97), + (2, 18, 49.75), + (2, 13, 40.21), + (3, 10, 1.96), + (3, 11, 0), + (3, 12, 0), + (3, 14, 65.36), + (3, 16, 20.26), + (3, 7, 0), + (3, 9, 0), + (3, 4, 26.14), + (3, 5, 2.94), + (3, 3, 20.59), + (3, 8, 6.21), + (3, 6, 9.15), + (3, 17, 26.75), + (3, 1, 19.93), + (3, 2, 13.07), + (3, 19, 29.39), + (3, 15, 11.76), + (3, 18, 43.86), + (3, 13, 2.61), + (4, 10, 11.85), + (4, 11, 0), + (4, 12, 0), + (4, 14, 4.37), + (4, 16, 29.13), + (4, 7, 0), + (4, 9, 0.95), + (4, 4, 1.42), + (4, 5, 26.07), + (4, 3, 7.58), + (4, 8, 3.32), + (4, 6, 15.17), + (4, 17, 0), + (4, 1, 12.8), + (4, 2, 20.85), + (4, 19, 0), + (4, 15, 17.96), + (4, 18, 100), + (4, 13, 48.54), + (5, 10, 3.27), + (5, 11, 0.33), + (5, 12, 0), + (5, 14, 31.53), + (5, 16, 41.87), + (5, 7, 0), + (5, 9, 0.98), + (5, 4, 18.3), + (5, 5, 24.18), + (5, 3, 11.76), + (5, 8, 2.94), + (5, 6, 4.9), + (5, 17, 35.29), + (5, 1, 12.42), + (5, 2, 20.92), + (5, 19, 24.02), + (5, 15, 7.88), + (5, 18, 40.69), + (5, 13, 18.72), + (6, 10, 11.14), + (6, 11, 15.54), + (6, 12, 6.48), + (6, 14, 39.47), + (6, 16, 0), + (6, 7, 5.18), + (6, 9, 25.91), + (6, 4, 13.21), + (6, 5, 0), + (6, 3, 0), + (6, 8, 1.81), + (6, 6, 1.55), + (6, 17, 0), + (6, 1, 8.03), + (6, 2, 11.14), + (6, 19, 0), + (6, 15, 11.84), + (6, 18, 0), + (6, 13, 48.68), + (7, 10, 10.84), + (7, 11, 13.5), + (7, 12, 0), + (7, 14, 17.07), + (7, 16, 0), + (7, 7, 3.68), + (7, 9, 12.27), + (7, 4, 5.11), + (7, 5, 9.82), + (7, 3, 9.82), + (7, 8, 3.27), + (7, 6, 7.98), + (7, 17, 0), + (7, 1, 10.63), + (7, 2, 13.09), + (7, 19, 0), + (7, 15, 34.76), + (7, 18, 0), + (7, 13, 48.17), + (8, 10, 10.46), + (8, 11, 12.59), + (8, 12, 5.67), + (8, 14, 27.59), + (8, 16, 0), + (8, 7, 4.96), + (8, 9, 12.59), + (8, 4, 10.99), + (8, 5, 9.57), + (8, 3, 6.74), + (8, 8, 2.84), + (8, 6, 3.55), + (8, 17, 0), + (8, 1, 9.57), + (8, 2, 10.46), + (8, 19, 0), + (8, 15, 3.45), + (8, 18, 0), + (8, 13, 68.97); \ No newline at end of file diff --git a/database/database.py b/database/database.py index 0b19401..663d58d 100644 --- a/database/database.py +++ b/database/database.py @@ -73,7 +73,9 @@ def get_moon_list() -> list[str] | None: with get_connection() as connection: cursor = connection.cursor() moon_names = cursor.execute( - "select moon_name from moon order by moon_id" + "select moon_name " + "from moon " + "order by moon_id;" ).fetchall() if moon_names: diff --git a/scouter.db b/scouter.db index fb8a53fc9fcb019500b5240b67c6d502a9d8135e..61c4b0fa4d467d9712d2fe7e9e2df6ae3f5788fb 100644 GIT binary patch delta 2630 zcmYL~dyG~`8OFcMIWu!E^Uil!pyjd)yDaQ-S%d|;Pr>m&;Y{Z~U2kctNM?$#o2mYQKE=;l}8Qx68Yne@TzT z&z~xnn)9b#%5N-s(S5lCM<)4?G#%(E$tj(k2W~=>|LmmQLl5mZ&~B-<)zXn^{(NfQ zwR7mn;fvAM#-ZB3$W9G8CU|ut)&5zA@%va54%x<&A zY%qOhg_&oXP1QuENdKiV`XjwUzo75aH|dMCkG9kO)K9Bu0Zpe^zpLNUm-Tu5s(xAj zME^j4OFyUg>m7Pf_v>!GP|wghelNZfUx?p`&&I!ulOM(>;;+RA<2~_~`0ltj?v6X+ z#&~ipqW7XJ(S_)2^xNpC(TV8W(U+p9qer6$qT8bGXkpYCQTTp%HT+ZfTKKE*WcWh( z zL-4ruKX!l(`zVbe1l-<%F;f~rkX&`&KXy)}p%s)WQ5qmZeDhI6C{++*o_x~wP1c>H zR6>dV|26?39G@Pgz7wS8zDXFONIfekX+0_;VtDnC9ogPXA}t_dJ<20e;Ca~?b((V? zNp4+ZXL;>6B5{d{EYmYc6x@`VNl$|nhi%S~cG?dva?3H8OZ&jqo;vRZd)#0r9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