A card game engine for TCGs, primarily Magic: The Gathering but with support for others
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Adding some basic data structures

+583 -3
+502
Cargo.lock
··· 1 + # This file is automatically @generated by Cargo. 2 + # It is not intended for manual editing. 3 + version = 4 4 + 5 + [[package]] 6 + name = "anyhow" 7 + version = "1.0.102" 8 + source = "registry+https://github.com/rust-lang/crates.io-index" 9 + checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" 10 + 11 + [[package]] 12 + name = "bitflags" 13 + version = "2.11.1" 14 + source = "registry+https://github.com/rust-lang/crates.io-index" 15 + checksum = "c4512299f36f043ab09a583e57bceb5a5aab7a73db1805848e8fef3c9e8c78b3" 16 + 17 + [[package]] 18 + name = "bumpalo" 19 + version = "3.20.2" 20 + source = "registry+https://github.com/rust-lang/crates.io-index" 21 + checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb" 22 + 23 + [[package]] 24 + name = "cfg-if" 25 + version = "1.0.4" 26 + source = "registry+https://github.com/rust-lang/crates.io-index" 27 + checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" 28 + 29 + [[package]] 30 + name = "chacha20" 31 + version = "0.10.0" 32 + source = "registry+https://github.com/rust-lang/crates.io-index" 33 + checksum = "6f8d983286843e49675a4b7a2d174efe136dc93a18d69130dd18198a6c167601" 34 + dependencies = [ 35 + "cfg-if", 36 + "cpufeatures", 37 + "rand_core", 38 + ] 39 + 40 + [[package]] 41 + name = "cpufeatures" 42 + version = "0.3.0" 43 + source = "registry+https://github.com/rust-lang/crates.io-index" 44 + checksum = "8b2a41393f66f16b0823bb79094d54ac5fbd34ab292ddafb9a0456ac9f87d201" 45 + dependencies = [ 46 + "libc", 47 + ] 48 + 49 + [[package]] 50 + name = "equivalent" 51 + version = "1.0.2" 52 + source = "registry+https://github.com/rust-lang/crates.io-index" 53 + checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" 54 + 55 + [[package]] 56 + name = "foldhash" 57 + version = "0.1.5" 58 + source = "registry+https://github.com/rust-lang/crates.io-index" 59 + checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" 60 + 61 + [[package]] 62 + name = "getrandom" 63 + version = "0.4.2" 64 + source = "registry+https://github.com/rust-lang/crates.io-index" 65 + checksum = "0de51e6874e94e7bf76d726fc5d13ba782deca734ff60d5bb2fb2607c7406555" 66 + dependencies = [ 67 + "cfg-if", 68 + "libc", 69 + "r-efi", 70 + "rand_core", 71 + "wasip2", 72 + "wasip3", 73 + ] 74 + 75 + [[package]] 76 + name = "hashbrown" 77 + version = "0.15.5" 78 + source = "registry+https://github.com/rust-lang/crates.io-index" 79 + checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" 80 + dependencies = [ 81 + "foldhash", 82 + ] 83 + 84 + [[package]] 85 + name = "hashbrown" 86 + version = "0.17.0" 87 + source = "registry+https://github.com/rust-lang/crates.io-index" 88 + checksum = "4f467dd6dccf739c208452f8014c75c18bb8301b050ad1cfb27153803edb0f51" 89 + 90 + [[package]] 91 + name = "heck" 92 + version = "0.5.0" 93 + source = "registry+https://github.com/rust-lang/crates.io-index" 94 + checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" 95 + 96 + [[package]] 97 + name = "id-arena" 98 + version = "2.3.0" 99 + source = "registry+https://github.com/rust-lang/crates.io-index" 100 + checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954" 101 + 102 + [[package]] 103 + name = "indexmap" 104 + version = "2.14.0" 105 + source = "registry+https://github.com/rust-lang/crates.io-index" 106 + checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9" 107 + dependencies = [ 108 + "equivalent", 109 + "hashbrown 0.17.0", 110 + "serde", 111 + "serde_core", 112 + ] 113 + 114 + [[package]] 115 + name = "itoa" 116 + version = "1.0.18" 117 + source = "registry+https://github.com/rust-lang/crates.io-index" 118 + checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" 119 + 120 + [[package]] 121 + name = "js-sys" 122 + version = "0.3.95" 123 + source = "registry+https://github.com/rust-lang/crates.io-index" 124 + checksum = "2964e92d1d9dc3364cae4d718d93f227e3abb088e747d92e0395bfdedf1c12ca" 125 + dependencies = [ 126 + "once_cell", 127 + "wasm-bindgen", 128 + ] 129 + 130 + [[package]] 131 + name = "leb128fmt" 132 + version = "0.1.0" 133 + source = "registry+https://github.com/rust-lang/crates.io-index" 134 + checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" 135 + 136 + [[package]] 137 + name = "libc" 138 + version = "0.2.185" 139 + source = "registry+https://github.com/rust-lang/crates.io-index" 140 + checksum = "52ff2c0fe9bc6cb6b14a0592c2ff4fa9ceb83eea9db979b0487cd054946a2b8f" 141 + 142 + [[package]] 143 + name = "log" 144 + version = "0.4.29" 145 + source = "registry+https://github.com/rust-lang/crates.io-index" 146 + checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" 147 + 148 + [[package]] 149 + name = "managrove" 150 + version = "0.1.0" 151 + dependencies = [ 152 + "rand", 153 + "uuid", 154 + ] 155 + 156 + [[package]] 157 + name = "memchr" 158 + version = "2.8.0" 159 + source = "registry+https://github.com/rust-lang/crates.io-index" 160 + checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" 161 + 162 + [[package]] 163 + name = "once_cell" 164 + version = "1.21.4" 165 + source = "registry+https://github.com/rust-lang/crates.io-index" 166 + checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" 167 + 168 + [[package]] 169 + name = "prettyplease" 170 + version = "0.2.37" 171 + source = "registry+https://github.com/rust-lang/crates.io-index" 172 + checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" 173 + dependencies = [ 174 + "proc-macro2", 175 + "syn", 176 + ] 177 + 178 + [[package]] 179 + name = "proc-macro2" 180 + version = "1.0.106" 181 + source = "registry+https://github.com/rust-lang/crates.io-index" 182 + checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" 183 + dependencies = [ 184 + "unicode-ident", 185 + ] 186 + 187 + [[package]] 188 + name = "quote" 189 + version = "1.0.45" 190 + source = "registry+https://github.com/rust-lang/crates.io-index" 191 + checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924" 192 + dependencies = [ 193 + "proc-macro2", 194 + ] 195 + 196 + [[package]] 197 + name = "r-efi" 198 + version = "6.0.0" 199 + source = "registry+https://github.com/rust-lang/crates.io-index" 200 + checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" 201 + 202 + [[package]] 203 + name = "rand" 204 + version = "0.10.1" 205 + source = "registry+https://github.com/rust-lang/crates.io-index" 206 + checksum = "d2e8e8bcc7961af1fdac401278c6a831614941f6164ee3bf4ce61b7edb162207" 207 + dependencies = [ 208 + "chacha20", 209 + "getrandom", 210 + "rand_core", 211 + ] 212 + 213 + [[package]] 214 + name = "rand_core" 215 + version = "0.10.1" 216 + source = "registry+https://github.com/rust-lang/crates.io-index" 217 + checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69" 218 + 219 + [[package]] 220 + name = "rustversion" 221 + version = "1.0.22" 222 + source = "registry+https://github.com/rust-lang/crates.io-index" 223 + checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" 224 + 225 + [[package]] 226 + name = "semver" 227 + version = "1.0.28" 228 + source = "registry+https://github.com/rust-lang/crates.io-index" 229 + checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" 230 + 231 + [[package]] 232 + name = "serde" 233 + version = "1.0.228" 234 + source = "registry+https://github.com/rust-lang/crates.io-index" 235 + checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" 236 + dependencies = [ 237 + "serde_core", 238 + ] 239 + 240 + [[package]] 241 + name = "serde_core" 242 + version = "1.0.228" 243 + source = "registry+https://github.com/rust-lang/crates.io-index" 244 + checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" 245 + dependencies = [ 246 + "serde_derive", 247 + ] 248 + 249 + [[package]] 250 + name = "serde_derive" 251 + version = "1.0.228" 252 + source = "registry+https://github.com/rust-lang/crates.io-index" 253 + checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" 254 + dependencies = [ 255 + "proc-macro2", 256 + "quote", 257 + "syn", 258 + ] 259 + 260 + [[package]] 261 + name = "serde_json" 262 + version = "1.0.149" 263 + source = "registry+https://github.com/rust-lang/crates.io-index" 264 + checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" 265 + dependencies = [ 266 + "itoa", 267 + "memchr", 268 + "serde", 269 + "serde_core", 270 + "zmij", 271 + ] 272 + 273 + [[package]] 274 + name = "syn" 275 + version = "2.0.117" 276 + source = "registry+https://github.com/rust-lang/crates.io-index" 277 + checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" 278 + dependencies = [ 279 + "proc-macro2", 280 + "quote", 281 + "unicode-ident", 282 + ] 283 + 284 + [[package]] 285 + name = "unicode-ident" 286 + version = "1.0.24" 287 + source = "registry+https://github.com/rust-lang/crates.io-index" 288 + checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" 289 + 290 + [[package]] 291 + name = "unicode-xid" 292 + version = "0.2.6" 293 + source = "registry+https://github.com/rust-lang/crates.io-index" 294 + checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" 295 + 296 + [[package]] 297 + name = "uuid" 298 + version = "1.23.1" 299 + source = "registry+https://github.com/rust-lang/crates.io-index" 300 + checksum = "ddd74a9687298c6858e9b88ec8935ec45d22e8fd5e6394fa1bd4e99a87789c76" 301 + dependencies = [ 302 + "getrandom", 303 + "js-sys", 304 + "wasm-bindgen", 305 + ] 306 + 307 + [[package]] 308 + name = "wasip2" 309 + version = "1.0.3+wasi-0.2.9" 310 + source = "registry+https://github.com/rust-lang/crates.io-index" 311 + checksum = "20064672db26d7cdc89c7798c48a0fdfac8213434a1186e5ef29fd560ae223d6" 312 + dependencies = [ 313 + "wit-bindgen 0.57.1", 314 + ] 315 + 316 + [[package]] 317 + name = "wasip3" 318 + version = "0.4.0+wasi-0.3.0-rc-2026-01-06" 319 + source = "registry+https://github.com/rust-lang/crates.io-index" 320 + checksum = "5428f8bf88ea5ddc08faddef2ac4a67e390b88186c703ce6dbd955e1c145aca5" 321 + dependencies = [ 322 + "wit-bindgen 0.51.0", 323 + ] 324 + 325 + [[package]] 326 + name = "wasm-bindgen" 327 + version = "0.2.118" 328 + source = "registry+https://github.com/rust-lang/crates.io-index" 329 + checksum = "0bf938a0bacb0469e83c1e148908bd7d5a6010354cf4fb73279b7447422e3a89" 330 + dependencies = [ 331 + "cfg-if", 332 + "once_cell", 333 + "rustversion", 334 + "wasm-bindgen-macro", 335 + "wasm-bindgen-shared", 336 + ] 337 + 338 + [[package]] 339 + name = "wasm-bindgen-macro" 340 + version = "0.2.118" 341 + source = "registry+https://github.com/rust-lang/crates.io-index" 342 + checksum = "eeff24f84126c0ec2db7a449f0c2ec963c6a49efe0698c4242929da037ca28ed" 343 + dependencies = [ 344 + "quote", 345 + "wasm-bindgen-macro-support", 346 + ] 347 + 348 + [[package]] 349 + name = "wasm-bindgen-macro-support" 350 + version = "0.2.118" 351 + source = "registry+https://github.com/rust-lang/crates.io-index" 352 + checksum = "9d08065faf983b2b80a79fd87d8254c409281cf7de75fc4b773019824196c904" 353 + dependencies = [ 354 + "bumpalo", 355 + "proc-macro2", 356 + "quote", 357 + "syn", 358 + "wasm-bindgen-shared", 359 + ] 360 + 361 + [[package]] 362 + name = "wasm-bindgen-shared" 363 + version = "0.2.118" 364 + source = "registry+https://github.com/rust-lang/crates.io-index" 365 + checksum = "5fd04d9e306f1907bd13c6361b5c6bfc7b3b3c095ed3f8a9246390f8dbdee129" 366 + dependencies = [ 367 + "unicode-ident", 368 + ] 369 + 370 + [[package]] 371 + name = "wasm-encoder" 372 + version = "0.244.0" 373 + source = "registry+https://github.com/rust-lang/crates.io-index" 374 + checksum = "990065f2fe63003fe337b932cfb5e3b80e0b4d0f5ff650e6985b1048f62c8319" 375 + dependencies = [ 376 + "leb128fmt", 377 + "wasmparser", 378 + ] 379 + 380 + [[package]] 381 + name = "wasm-metadata" 382 + version = "0.244.0" 383 + source = "registry+https://github.com/rust-lang/crates.io-index" 384 + checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909" 385 + dependencies = [ 386 + "anyhow", 387 + "indexmap", 388 + "wasm-encoder", 389 + "wasmparser", 390 + ] 391 + 392 + [[package]] 393 + name = "wasmparser" 394 + version = "0.244.0" 395 + source = "registry+https://github.com/rust-lang/crates.io-index" 396 + checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe" 397 + dependencies = [ 398 + "bitflags", 399 + "hashbrown 0.15.5", 400 + "indexmap", 401 + "semver", 402 + ] 403 + 404 + [[package]] 405 + name = "wit-bindgen" 406 + version = "0.51.0" 407 + source = "registry+https://github.com/rust-lang/crates.io-index" 408 + checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" 409 + dependencies = [ 410 + "wit-bindgen-rust-macro", 411 + ] 412 + 413 + [[package]] 414 + name = "wit-bindgen" 415 + version = "0.57.1" 416 + source = "registry+https://github.com/rust-lang/crates.io-index" 417 + checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e" 418 + 419 + [[package]] 420 + name = "wit-bindgen-core" 421 + version = "0.51.0" 422 + source = "registry+https://github.com/rust-lang/crates.io-index" 423 + checksum = "ea61de684c3ea68cb082b7a88508a8b27fcc8b797d738bfc99a82facf1d752dc" 424 + dependencies = [ 425 + "anyhow", 426 + "heck", 427 + "wit-parser", 428 + ] 429 + 430 + [[package]] 431 + name = "wit-bindgen-rust" 432 + version = "0.51.0" 433 + source = "registry+https://github.com/rust-lang/crates.io-index" 434 + checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21" 435 + dependencies = [ 436 + "anyhow", 437 + "heck", 438 + "indexmap", 439 + "prettyplease", 440 + "syn", 441 + "wasm-metadata", 442 + "wit-bindgen-core", 443 + "wit-component", 444 + ] 445 + 446 + [[package]] 447 + name = "wit-bindgen-rust-macro" 448 + version = "0.51.0" 449 + source = "registry+https://github.com/rust-lang/crates.io-index" 450 + checksum = "0c0f9bfd77e6a48eccf51359e3ae77140a7f50b1e2ebfe62422d8afdaffab17a" 451 + dependencies = [ 452 + "anyhow", 453 + "prettyplease", 454 + "proc-macro2", 455 + "quote", 456 + "syn", 457 + "wit-bindgen-core", 458 + "wit-bindgen-rust", 459 + ] 460 + 461 + [[package]] 462 + name = "wit-component" 463 + version = "0.244.0" 464 + source = "registry+https://github.com/rust-lang/crates.io-index" 465 + checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2" 466 + dependencies = [ 467 + "anyhow", 468 + "bitflags", 469 + "indexmap", 470 + "log", 471 + "serde", 472 + "serde_derive", 473 + "serde_json", 474 + "wasm-encoder", 475 + "wasm-metadata", 476 + "wasmparser", 477 + "wit-parser", 478 + ] 479 + 480 + [[package]] 481 + name = "wit-parser" 482 + version = "0.244.0" 483 + source = "registry+https://github.com/rust-lang/crates.io-index" 484 + checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736" 485 + dependencies = [ 486 + "anyhow", 487 + "id-arena", 488 + "indexmap", 489 + "log", 490 + "semver", 491 + "serde", 492 + "serde_derive", 493 + "serde_json", 494 + "unicode-xid", 495 + "wasmparser", 496 + ] 497 + 498 + [[package]] 499 + name = "zmij" 500 + version = "1.0.21" 501 + source = "registry+https://github.com/rust-lang/crates.io-index" 502 + checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa"
+5
Cargo.toml
··· 4 4 edition = "2024" 5 5 6 6 [dependencies] 7 + rand = "0.10.1" 8 + 9 + [dependencies.uuid] 10 + version = "1.23.1" 11 + features = ["v4"]
+3 -3
src/main.rs
··· 1 - fn main() { 2 - println!("Hello, world!"); 3 - } 1 + mod state; 2 + 3 + fn main() {}
+73
src/state.rs
··· 1 + use std::collections::HashMap; 2 + use uuid::Uuid; 3 + 4 + pub struct PlayerId(Uuid); 5 + pub struct CardId(Uuid); 6 + pub struct ZoneId(Uuid); 7 + pub struct CardDefId(Uuid); 8 + 9 + pub struct GameState { 10 + players: HashMap<PlayerId, Player>, 11 + cards: HashMap<CardId, CardInstance>, 12 + zones: HashMap<ZoneId, Zone> 13 + } 14 + 15 + pub struct CardInstance { 16 + id: CardId, 17 + definition_id: CardDefId, 18 + owner: PlayerId, 19 + zone: ZoneId, 20 + tapped: bool 21 + } 22 + 23 + pub struct Zone { 24 + id: ZoneId, 25 + owner: PlayerId, 26 + cards: Vec<CardId>, 27 + zone_type: ZoneType, 28 + visibility: ZoneVisibility 29 + } 30 + 31 + pub enum ZoneType { 32 + Hand, 33 + Library, 34 + Graveyard, 35 + Battlefield, 36 + Exile, 37 + Stack 38 + } 39 + 40 + pub enum ZoneVisibility { 41 + Public, 42 + HiddenToOpponent, 43 + HiddenToAll 44 + } 45 + 46 + pub struct Player { 47 + id: PlayerId, 48 + life: i32, 49 + // Zones owned by this player 50 + hand: ZoneId, 51 + library: ZoneId, 52 + graveyard: ZoneId, 53 + battlefield: ZoneId, 54 + exile: ZoneId, 55 + // Gameplay state 56 + mana_pool: ManaPool, 57 + // Status effects 58 + poison_counters: u32, 59 + energy_counters: u32, 60 + rad_counters: u32, 61 + ticket_counters: u32, 62 + experience_counters: u32, 63 + commander_damage: HashMap<PlayerId, u32> 64 + } 65 + 66 + pub struct ManaPool { 67 + red: u32, 68 + blue: u32, 69 + green: u32, 70 + white: u32, 71 + black: u32, 72 + colorless: u32 73 + }