-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
36 changed files
with
715 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: "Build CosmicKube game server" | ||
on: | ||
push: | ||
branches: | ||
- main | ||
jobs: | ||
build-server: | ||
name: "Build Game Server" | ||
runs-on: ubuntu-20.04 | ||
permissions: | ||
packages: write | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install Rust toolchain | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
default: true | ||
override: true | ||
|
||
- name: Build | ||
run: | | ||
cd backend | ||
cargo build --all --release && strip target/release/cosmic_kube && mv target/release/cosmic_kube target/release/cosmic_kube_amd64 | ||
- name: Upload Artifact | ||
uses: actions/upload-artifact@v1 | ||
with: | ||
name: server | ||
path: backend/target/release/cosmic_kube_amd64 | ||
|
||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- name: Login to DockerHub | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
# this will push the docker images to the github container registry | ||
# you will need to give actions permission to push there first | ||
- name: Build and push | ||
id: docker_build | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: . | ||
file: server.Dockerfile | ||
push: true | ||
tags: | | ||
ghcr.io/pilksoc/cosmickube:dev-latest | ||
ghcr.io/pilksoc/cosmickube:dev-${{ github.run_number }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,5 @@ pub mod space; | |
pub mod kube; | ||
pub mod player; | ||
pub mod llm; | ||
pub mod cache; | ||
|
||
type Coordinate = [u64; 2]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1 @@ | ||
|
||
// these are the structs intended for use when communicating via websockets | ||
|
||
// this is the data we expect to recieve from the player | ||
pub struct PlayerInfo { | ||
player: Player, //the player requesting the data | ||
coordinates: [u64; 2], //current player coordinates | ||
action: String, //PLACEHOLDER! we need to know what the player is doing. | ||
} | ||
|
||
// this is the data we expect to send to the player | ||
pub struct GameState { | ||
grid: String, //PLACEHOLDER! This will be the partial grid state type | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
use core::fmt; | ||
use cosmic_kube::kube::Kube; | ||
use serde::{Deserialize, Serialize}; | ||
use serde_json::json; | ||
use serde_repr::{Serialize_repr, Deserialize_repr}; | ||
|
||
// this is the data we expect to recieve from the player | ||
#[derive(Serialize, Deserialize)] | ||
pub struct PlayerInfo { | ||
player: String, //Player, //the player requesting the data | ||
coordinates: [u64; 2], //current player coordinates | ||
action: Option<Action>, // 0, block picked up 1, block placed | ||
} | ||
|
||
#[derive(Serialize_repr, Deserialize_repr)] | ||
#[repr(u8)] | ||
enum ActionType { | ||
Pickup = 0, | ||
Place = 1, | ||
} | ||
|
||
impl fmt::Display for ActionType { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
match self { | ||
ActionType::Pickup => write!(f, "pickup"), | ||
ActionType::Place => write!(f, "place"), | ||
} | ||
} | ||
} | ||
|
||
#[derive(Serialize, Deserialize)] | ||
pub struct Action { | ||
kind: ActionType, | ||
kube: Kube, | ||
} | ||
|
||
fn recalculate_game(state: PlayerInfo) -> String { | ||
// debug: log of event to server console | ||
println!("{} @ (x:{}, y:{})", state.player, state.coordinates[0], state.coordinates[1]); | ||
match state.action { | ||
Some(p) => println!("{}: {}", p.kind, p.kube.name), | ||
None => println!(""), | ||
} | ||
|
||
//send action to database to get result !!!<---- | ||
|
||
let resp = json!({ | ||
"grid" : "edited grid" | ||
}); | ||
|
||
resp.to_string() | ||
} | ||
|
||
pub fn create_response(message: &str) -> String { | ||
|
||
// Parse the string of data into serde_json::Value. | ||
let state: PlayerInfo = serde_json::from_str(message).expect("something went wrong in json parse"); | ||
|
||
recalculate_game(state) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
simplest building blocks, (you cannot craft these); | ||
-hydrogen | ||
-oxygen | ||
-nitrogen | ||
-calcium | ||
-iron | ||
-aluminium | ||
-uranium | ||
-hydrogen | ||
-sodium | ||
-chlorine | ||
-light | ||
-time | ||
-silicon | ||
|
||
hardcoded recipes: | ||
- hydrogen + oxygen = water | ||
- water + chlorine = tap water | ||
- sodium + chlorine = salt | ||
- water + salt = sea water | ||
- nitrogen + oxygen = air | ||
- iron + water = rust | ||
- silicon + aluminium = feldspar | ||
- feldspar + silicon = sand | ||
- sand + water = dirt | ||
- sand + sea water = beach | ||
- dirt + water = earth | ||
- earth + air = life | ||
- life + time = age | ||
- uranium + water = energy | ||
- sand + time = rock | ||
- rock + energy = fire | ||
- fire + sand = glass | ||
|
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
[remap] | ||
|
||
importer="texture" | ||
type="CompressedTexture2D" | ||
uid="uid://c6jm42o02gsfr" | ||
path="res://.godot/imported/box.png-52cc4e41fddadef836f9ad4dbe7936fa.ctex" | ||
metadata={ | ||
"vram_texture": false | ||
} | ||
|
||
[deps] | ||
|
||
source_file="res://assets/box.png" | ||
dest_files=["res://.godot/imported/box.png-52cc4e41fddadef836f9ad4dbe7936fa.ctex"] | ||
|
||
[params] | ||
|
||
compress/mode=0 | ||
compress/high_quality=false | ||
compress/lossy_quality=0.7 | ||
compress/hdr_compression=1 | ||
compress/normal_map=0 | ||
compress/channel_pack=0 | ||
mipmaps/generate=false | ||
mipmaps/limit=-1 | ||
roughness/mode=0 | ||
roughness/src_normal="" | ||
process/fix_alpha_border=true | ||
process/premult_alpha=false | ||
process/normal_map_invert_y=false | ||
process/hdr_as_srgb=false | ||
process/hdr_clamp_exposure=false | ||
process/size_limit=0 | ||
detect_3d/compress_to=1 |
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.