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
4 changes: 4 additions & 0 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ task:
container:
image: rust:slim-bookworm

setup_script:
- apt-get update -y
- apt-get install -y --fix-missing build-essential

build_script:
- cargo build --release

Expand Down
85 changes: 83 additions & 2 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 @@ -27,3 +27,4 @@ env_logger = "0.10.1"
futures-util = "0.3.30"
clap = "3.1"
webbrowser = "0.8.12"
mlua = { version = "0.9.4", features = ["vendored", "luajit52"] }
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Use a Rust image to build the application
FROM rust:slim-bookworm as builder

RUN apt-get update -y && \
apt-get install -y --fix-missing \
build-essential

# Copy your manifests
COPY ./Cargo.toml ./Cargo.toml
COPY ./Cargo.lock ./Cargo.lock
Expand All @@ -12,6 +16,7 @@ RUN rm src/*.rs

# Copy Deps
COPY ./src ./src
COPY ./client ./client
RUN touch ./src/main.rs
RUN touch ./src/lib.rs

Expand Down
39 changes: 39 additions & 0 deletions client/choose_bot.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!DOCTYPE html>
<html>

<link rel="stylesheet" type="text/css" href="/css/botButtons.css">

<head>
<title>Rustiator</title>
</head>

<body>
<h2>Choose Which Bot To Play</h2>
<div id="botButtons"></div>
</body>
<script src="/js/utils.js"></script>
<script>
document.addEventListener('DOMContentLoaded', fetchBots);

function fetchBots() {
fetch('/botNames')
.then(response => response.json())
.then(data => {
createButtons(data.bot_names);
})
.catch(error => console.error('Error:', error));
}

function createButtons(bots) {
const container = document.getElementById('botButtons');
bots.forEach(botName => {
let button = document.createElement('button');
button.textContent = botName;
button.onclick = function () { startGame('playerVsBot', botName); };
container.appendChild(button);
});
}

</script>

</html>
39 changes: 39 additions & 0 deletions client/choose_bot_edit.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!DOCTYPE html>
<html>

<link rel="stylesheet" type="text/css" href="/css/botButtons.css">

<head>
<title>Rustiator</title>
</head>

<body>
<h2>Choose Which Bot To Edit</h2>
<div id="botButtons"></div>
</body>
<script>
document.addEventListener('DOMContentLoaded', fetchBots);

function fetchBots() {
// TODO: the endpoint also returns the rust bot so if they try to edit it they will just get the lua template
fetch('/botNames')
.then(response => response.json())
.then(data => {
createButtons(data.bot_names);
})
.catch(error => console.error('Error:', error));
}

function createButtons(bots) {
const container = document.getElementById('botButtons');
bots.forEach(botName => {
let button = document.createElement('button');
button.textContent = botName;
button.onclick = function () { window.location.href = `editBot/${botName}`};
container.appendChild(button);
});
}

</script>

</html>
14 changes: 14 additions & 0 deletions client/css/botButtons.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#botButtons {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh; /* This makes the div take the full viewport height */
}
button {
margin: 10px; /* Adds spacing between buttons */
}

h2 {
text-align: center;
}
Loading