Compare commits

...

6 Commits

Author SHA1 Message Date
Bel LaPointe
02b74c8ee5 doesnt work 2025-03-31 19:08:38 -06:00
Bel LaPointe
42831b71a1 update godot naming 2025-03-31 18:51:27 -06:00
Bel LaPointe
8e3cecdc6a gmon aliases mon 2025-03-31 18:46:42 -06:00
Bel LaPointe
e94a802034 gmon aliases mon 2025-03-31 18:46:28 -06:00
Bel LaPointe
9130797eec rust to gmon imports purerust to mon 2025-03-31 18:39:25 -06:00
Bel LaPointe
61f7299e42 comments 2025-03-24 21:10:58 -06:00
12 changed files with 74 additions and 30 deletions

View File

@@ -237,6 +237,18 @@ version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2" checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2"
[[package]]
name = "gmon"
version = "0.1.0"
dependencies = [
"futures",
"godot",
"mon",
"native_db",
"native_model",
"serde",
]
[[package]] [[package]]
name = "godot" name = "godot"
version = "0.2.4" version = "0.2.4"
@@ -344,6 +356,10 @@ version = "2.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
[[package]]
name = "mon"
version = "0.1.0"
[[package]] [[package]]
name = "nanoserde" name = "nanoserde"
version = "0.1.37" version = "0.1.37"
@@ -436,17 +452,6 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
[[package]]
name = "mon"
version = "0.1.0"
dependencies = [
"futures",
"godot",
"native_db",
"native_model",
"serde",
]
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.93" version = "1.0.93"

View File

@@ -1,5 +1,5 @@
[package] [package]
name = "mon" name = "gmon"
version = "0.1.0" version = "0.1.0"
edition = "2024" edition = "2024"
@@ -9,6 +9,7 @@ godot = "0.2.4"
native_db = "0.8.1" native_db = "0.8.1"
native_model = "0.4.20" native_model = "0.4.20"
serde = "1.0.218" serde = "1.0.218"
mon = { path = "../mon" }
[lib] [lib]
crate-type = ["cdylib"] crate-type = ["cdylib"]

26
src/gmon/src/battle.rs Normal file
View File

@@ -0,0 +1,26 @@
use ::mon::*;
use godot::classes::{ISprite2D, Sprite2D};
use godot::prelude::*;
pub type Instance = mon::battle::Instance;
pub type Team = mon::battle::Team;
pub type Event = mon::battle::Event;
pub type Move = mon::battle::Move;
#[derive(GodotClass)]
#[class(base=Sprite2D)]
struct Engine {
instance: mon::battle::Engine,
base: Base<Sprite2D>,
}
#[godot_api]
impl ISprite2D for Engine {
fn init(base: Base<Sprite2D>) -> Self {
Self {
instance: mon::battle::Engine::new(),
base: base,
}
}
}

9
src/gmon/src/lib.rs Executable file
View File

@@ -0,0 +1,9 @@
use godot::prelude::*;
struct MyExtension;
#[gdextension]
unsafe impl ExtensionLibrary for MyExtension {}
pub mod battle;
pub mod mon;

5
src/gmon/src/mon.rs Normal file
View File

@@ -0,0 +1,5 @@
use ::mon::*;
pub type Instance = mon::mon::Instance;
pub type Species = mon::mon::Species;
pub type Dex = mon::mon::Dex;

View File

@@ -4,11 +4,11 @@ compatibility_minimum = 4.1
reloadable = true reloadable = true
[libraries] [libraries]
linux.debug.x86_64 = "res://../rust/target/debug/libmon.so" linux.debug.x86_64 = "res://../gmon/target/debug/libgmon.so"
linux.release.x86_64 = "res://../rust/target/release/libmon.so" linux.release.x86_64 = "res://../gmon/target/release/libgmon.so"
windows.debug.x86_64 = "res://../rust/target/debug/mon.dll" windows.debug.x86_64 = "res://../gmon/target/debug/gmon.dll"
windows.release.x86_64 = "res://../rust/target/release/mon.dll" windows.release.x86_64 = "res://../gmon/target/release/gmon.dll"
macos.debug = "res://../rust/target/debug/libmon.dylib" macos.debug = "res://../gmon/target/debug/libgmon.dylib"
macos.release = "res://../rust/target/release/libmon.dylib" macos.release = "res://../gmon/target/release/libgmon.dylib"
macos.debug.arm64 = "res://../rust/target/debug/libmon.dylib" macos.debug.arm64 = "res://../gmon/target/debug/libgmon.dylib"
macos.release.arm64 = "res://../rust/target/release/libmon.dylib" macos.release.arm64 = "res://../gmon/target/release/libgmon.dylib"

1
src/mon/src/lib.rs Executable file
View File

@@ -0,0 +1 @@
pub mod mon;

View File

@@ -511,6 +511,7 @@ mod mon_tests {
assert_eq!(0, engine.teams()[1].mons()[1].damage()); assert_eq!(0, engine.teams()[1].mons()[1].damage());
assert_eq!(0, engine.teams()[1].mons()[2].damage()); assert_eq!(0, engine.teams()[1].mons()[2].damage());
// team1mon0 wears down team0mon1
for i in 2..engine.teams()[0].mons()[1].mon.dex.hp() { for i in 2..engine.teams()[0].mons()[1].mon.dex.hp() {
engine engine
.enqueue(battle::Move::Attack(1, 0)) .enqueue(battle::Move::Attack(1, 0))
@@ -519,6 +520,7 @@ mod mon_tests {
assert_eq!(i, engine.teams()[0].mons()[1].damage()); assert_eq!(i, engine.teams()[0].mons()[1].damage());
} }
// team1mon0 downs team0mon1
engine engine
.enqueue(battle::Move::Attack(1, 0)) .enqueue(battle::Move::Attack(1, 0))
.expect("failed to kill"); .expect("failed to kill");
@@ -531,6 +533,7 @@ mod mon_tests {
); );
assert!(!engine.teams()[0].mons()[1].out); assert!(!engine.teams()[0].mons()[1].out);
// team0 must swap
assert!(engine.enqueue(battle::Move::Attack(0, 1)).is_err()); assert!(engine.enqueue(battle::Move::Attack(0, 1)).is_err());
assert!(engine.enqueue(battle::Move::Pass(0)).is_err()); assert!(engine.enqueue(battle::Move::Pass(0)).is_err());
engine engine
@@ -539,6 +542,7 @@ mod mon_tests {
assert!(engine.enqueue(battle::Move::Attack(1, 0)).is_err()); assert!(engine.enqueue(battle::Move::Attack(1, 0)).is_err());
assert_eq!(0, engine.exec().len()); assert_eq!(0, engine.exec().len());
// team1mon0 wears down team0mon0
for i in 7..engine.teams()[0].mons()[0].mon.dex.hp() { for i in 7..engine.teams()[0].mons()[0].mon.dex.hp() {
engine engine
.enqueue(battle::Move::Attack(1, 0)) .enqueue(battle::Move::Attack(1, 0))
@@ -547,6 +551,9 @@ mod mon_tests {
assert_eq!(i, engine.teams()[0].mons()[0].damage()); assert_eq!(i, engine.teams()[0].mons()[0].damage());
} }
// team1mon0 downs team0mon0
// team0 loses
// team1 wins
engine engine
.enqueue(battle::Move::Attack(1, 0)) .enqueue(battle::Move::Attack(1, 0))
.expect("failed to kill"); .expect("failed to kill");

View File

@@ -1 +0,0 @@
pub mod src;

View File

@@ -1,9 +0,0 @@
use godot::prelude::*;
struct MyExtension;
#[gdextension]
unsafe impl ExtensionLibrary for MyExtension {
}
pub mod src;