Skip to content
Open
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
Binary file added .DS_Store
Binary file not shown.
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@ GOOGLE_OAUTH_AUTH_URL=https://accounts.google.com/o/oauth2/v2/auth
GOOGLE_OAUTH_TOKEN_URL=https://www.googleapis.com/oauth2/v3/token
GOOGLE_OAUTH_USER_INFO_URL=https://www.googleapis.com/oauth2/v3/userinfo


GEMINI_API_KEY_FINE_TUNED=
GEMINI_MODEL_ID=
BOMB_MAX_COUNT = 10
13 changes: 13 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@ awc = "3.0.1"
diesel-derive-enum = { version = "2.0.0-rc.0", features = ["postgres"] }
oauth2 = "4.4.2"
jsonwebtoken = "9.2.0"
tokio = { version = "1", features = ["full"] }
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM rust:1.78.0-slim AS base
FROM rust:1.82.0-slim AS base
WORKDIR /usr/src/aot-backend
RUN apt-get update -y && apt-get install -y \
libpq-dev \
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile.prod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ RUN apt-get update -y && apt-get install -y \
libpq-dev \
netcat-traditional \
pkg-config \
libssl-dev
libssl-dev \
curl
RUN cargo install cargo-chef

FROM base AS planner
Expand Down
8 changes: 8 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ services:
TZ: "Asia/Calcutta"
depends_on:
- db
healthcheck:
test: ["CMD-SHELL", "curl --fail http://localhost:8000/game/leaderboard"]
interval: 5s
timeout: 5s
retries: 3
start_period: 7s
volumes:
- ./:/usr/src/aot-backend

db:
image: postgres
Expand Down
95 changes: 39 additions & 56 deletions dummy_data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ SET row_security = off;

DELETE FROM public.artifact;
DELETE FROM public.map_spaces;
DELETE FROM public.available_blocks;
DELETE FROM public.available_attackers;
DELETE FROM public.available_emps;
DELETE FROM public.level_constraints;
DELETE FROM public.block_type;
DELETE FROM public.attacker_type;
Expand All @@ -31,7 +32,7 @@ COPY public.levels_fixture FROM stdin;
\.

COPY public.user FROM stdin;
1 Bot [email protected] bot true 0 0 1000 0 500
1 Bot [email protected] bot true 0 0 1000 0 500 false
\.

COPY public.map_layout FROM stdin;
Expand Down Expand Up @@ -120,18 +121,18 @@ COPY public.building_type FROM stdin;
\.

COPY public.defender_type FROM stdin;
1 4 50 1 10 Defender_1 1
2 4 40 1 10 Defender_2 2
3 4 30 1 10 Defender_3 3
4 4 60 2 150 Defender_1 4
5 4 50 2 250 Defender_2 5
6 4 40 2 350 Defender_3 6
7 4 70 3 -1 Defender_1 7
8 4 60 3 -1 Defender_2 8
9 4 50 3 -1 Defender_3 9
10 4 20 1 -1 Hut_Defender 19
11 4 30 2 -1 Hut_Defender 20
12 4 50 3 -1 Hut_Defender 21
1 1 5 1 10 Defender_1 1 120
2 1 4 1 10 Defender_2 2 150
3 1 3 1 10 Defender_3 3 180
4 1 6 2 150 Defender_1 4 140
5 1 7 2 250 Defender_2 5 170
6 1 8 2 350 Defender_3 6 200
7 1 9 3 -1 Defender_1 7 160
8 1 10 3 -1 Defender_2 8 190
9 1 11 3 -1 Defender_3 9 220
10 1 5 1 -1 Hut_Defender 19 100
11 1 6 2 -1 Hut_Defender 20 120
12 1 7 3 -1 Hut_Defender 21 140
\.

COPY public.emp_type FROM stdin;
Expand All @@ -153,15 +154,15 @@ COPY public.mine_type FROM stdin;
\.

COPY public.attacker_type FROM stdin;
1 100 4 10 1 10 Attacker_1 0
2 120 4 12 1 10 Attacker_2 0
3 80 4 8 1 10 Attacker_3 0
4 150 4 15 2 80 Attacker_1 0
5 180 4 18 2 100 Attacker_2 0
6 120 4 12 2 60 Attacker_3 0
7 200 4 20 3 -1 Attacker_1 0
8 240 4 24 3 -1 Attacker_2 0
9 160 4 16 3 -1 Attacker_3 0
1 100 1 10 1 10 Attacker_1 0
2 120 1 12 1 10 Attacker_2 0
3 80 1 8 1 10 Attacker_3 0
4 150 1 15 2 80 Attacker_1 0
5 180 1 18 2 100 Attacker_2 0
6 120 1 12 2 60 Attacker_3 0
7 200 1 20 3 -1 Attacker_1 0
8 240 1 24 3 -1 Attacker_2 0
9 160 1 16 3 -1 Attacker_3 0
\.

COPY public.block_type FROM stdin;
Expand Down Expand Up @@ -231,41 +232,21 @@ COPY public.block_type FROM stdin;
63 \N \N building 51
64 10 \N defender 0
65 11 \N defender 0
67 12 \N defender 0
66 12 \N defender 0
\.

COPY public.available_blocks FROM stdin;
0 1 \N \N block 0
1 1 \N \N block 1
2 1 \N \N block 2
3 1 \N \N block 3
4 1 \N \N block 4
5 1 \N \N block 5
6 1 \N \N block 6
7 1 \N \N block 7
8 1 \N \N block 8
9 1 \N \N block 9
10 1 \N \N block 10
11 1 \N \N block 11
12 1 \N \N block 12
13 1 \N \N block 13
14 1 \N \N block 14
15 1 \N \N block 15
46 1 \N \N block 16
47 1 \N \N block 17
48 1 \N \N block 18
55 1 \N \N block 19
\N 1 1 \N attacker 20
\N 1 2 \N attacker 21
\N 1 3 \N attacker 22
\N 1 \N 1 emp 23
\N 1 \N 2 emp 24
\N 1 \N 3 emp 25
58 1 \N \N block 26
61 1 \N \N block 27
58 1 \N \N block 28

COPY public.available_attackers FROM stdin;
1 1 1
2 1 2
3 1 3
\.

COPY public.available_emps FROM stdin;
1 1 1
2 1 2
3 1 3
\.
COPY public.map_spaces FROM stdin;
1 1 0 0 0
2 1 0 1 0
Expand Down Expand Up @@ -440,7 +421,8 @@ COPY public.map_spaces FROM stdin;
171 1 1 34 15
172 1 36 20 58
173 1 20 36 61
174 1 36 10 58
174 1 10 36 61
175 1 36 10 58
\.

COPY public.artifact FROM stdin;
Expand Down Expand Up @@ -512,4 +494,5 @@ SELECT pg_catalog.setval('public.map_layout_id_seq', 2, false);
SELECT pg_catalog.setval('public.game_id_seq', 1, false);
SELECT pg_catalog.setval('public.block_type_id_seq', 64, false);
SELECT pg_catalog.setval('public.map_spaces_id_seq', 178, false);
SELECT pg_catalog.setval('public.available_blocks_id_seq', 28, false);
SELECT pg_catalog.setval('public.available_attackers_id_seq', 4, false);
SELECT pg_catalog.setval('public.available_emps_id_seq', 4, false);
3 changes: 3 additions & 0 deletions migrations/2025-01-13-063348_defender_migration_25/down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- This file should undo anything in `up.sql`
ALTER TABLE public.defender_type
DROP COLUMN max_health;
3 changes: 3 additions & 0 deletions migrations/2025-01-13-063348_defender_migration_25/up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- Your SQL goes here
ALTER TABLE public.defender_type
ADD COLUMN max_health INT NOT NULL;
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
-- This file should undo anything in `up.sql`


CREATE TYPE item_category AS ENUM ('attacker', 'emp', 'block');

CREATE TABLE public.available_blocks(
block_type_id INTEGER NOT NULL,
user_id INTEGER NOT NULL,
attacker_type_id INTEGER,
emp_type_id INTEGER,
category item_category NOT NULL,
id serial NOT NULL

CONSTRAINT user_id_fk FOREIGN KEY (user_id) REFERENCES public.user(id),
CONSTRAINT attacker_id_fk FOREIGN KEY (attacker_type_id) REFERENCES public.attacker_type(id),
CONSTRAINT block_type_id_fk FOREIGN KEY (block_type_id) REFERENCES public.block_type(id),
CONSTRAINT available_blocks_id_primary PRIMARY KEY(id),
) WITH (
OIDS=FALSE
);

DROP TABLE public.available_attackers;
DROP TABLE public.available_emps;
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
-- Your SQL goes here


DROP TABLE public.available_blocks;

DROP TYPE item_category;


CREATE TABLE IF NOT EXISTS public.available_attackers (
id serial NOT NULL,
user_id INTEGER NOT NULL,
attacker_type_id INTEGER NOT NULL,
CONSTRAINT attacker_id_fk FOREIGN KEY (attacker_type_id) REFERENCES public.attacker_type(id),
CONSTRAINT user_id_fk FOREIGN KEY (user_id) REFERENCES public.user(id),
CONSTRAINT available_attackers_pk PRIMARY KEY (id)
);

CREATE TABLE IF NOT EXISTS public.available_emps (
id serial NOT NULL,
user_id INTEGER NOT NULL,
emp_type_id INTEGER NOT NULL,
CONSTRAINT emp_id_fk FOREIGN KEY (emp_type_id) REFERENCES public.emp_type(id),
CONSTRAINT user_id_fk FOREIGN KEY (user_id) REFERENCES public.user(id),
CONSTRAINT available_emp_pk PRIMARY KEY (id)
);
5 changes: 5 additions & 0 deletions migrations/2025-01-29-161348_challenges_migration/down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- This file should undo anything in `up.sql`
DROP TABLE IF EXISTS challenges;
DROP TABLE IF EXISTS challenge_maps;
DROP TABLE IF EXISTS challenges_responses;
ALTER TABLE "user" DROP COLUMN is_mod;
33 changes: 33 additions & 0 deletions migrations/2025-01-29-161348_challenges_migration/up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
-- Your SQL goes here
CREATE TABLE challenges
(
id SERIAL PRIMARY KEY,
"name" VARCHAR(255) NOT NULL,
"start" TIMESTAMP NOT NULL,
"end" TIMESTAMP NOT NULL
);

CREATE TABLE challenge_maps
(
id SERIAL PRIMARY KEY,
challenge_id INTEGER NOT NULL,
user_id INTEGER NOT NULL,
map_id INTEGER NOT NULL,
CONSTRAINT fk_chall_map_challenge FOREIGN KEY (challenge_id) REFERENCES challenges(id),
CONSTRAINT fk_chall_map_user FOREIGN KEY (user_id) REFERENCES "user"(id)
);

CREATE TABLE challenges_responses
(
id SERIAL PRIMARY KEY,
attacker_id INTEGER NOT NULL,
challenge_id INTEGER NOT NULL,
map_id INTEGER NOT NULL,
score INTEGER NOT NULL,
attempts INTEGER NOT NULL,
CONSTRAINT chall_response_attacker FOREIGN KEY (attacker_id) REFERENCES "user"(id),
CONSTRAINT chall_response_challenge FOREIGN KEY (challenge_id) REFERENCES challenges(id),
CONSTRAINT unique_attacker_challenge UNIQUE (attacker_id, challenge_id, map_id)
);

ALTER TABLE "user" ADD COLUMN is_mod BOOLEAN NOT NULL;
Loading