spelltest 0.2.0

SPELL TEST Mechanics
Documentation
  • Coverage
  • 0%
    0 out of 8 items documented0 out of 4 items with examples
  • Size
  • Source code size: 17.79 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.44 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 13s Average build duration of successful builds.
  • all releases: 13s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • bidipeppercrap/spelltest.rs
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • bidipeppercrap

Quick Example

use spelltest::*;

fn main() {
    // --- Create a player character ---
    // Creature::new(name, health, energy, damage, defense)
    // Set mutable variable because we expect a change to health and energy
    let mut player = Creature::new("Pel Nervil", 100, 20, 5, 0);

    // --- Create a dummy enemy ---
    let mut dummy_enemy = Creature::new("Player killer", 200, 50, 10, 5);

    // Let's print their attributes
    player.print();
    dummy_enemy.print();

    // Let's do a turn-based combat
    // First, the player attack the enemy
    player.attack(&mut dummy_enemy); // Borrow and use as mutable to apply a change to enemy health

    // Let's print enemy attributes again, we expect the enemy health is reduced by the attack from the player
    dummy_enemy.print();

    // It's the enemy turn to attack
    dummy_enemy.attack(&mut player); // Like before, borrow and use as mutable

    // Expecting reduced player health
    player.print();
}

See examples for more!

To run the official example, simply clone this repo and run it by using cargo run --example <folder-name> (Replace <folder-name> with the example folder name).

To run basic example in the examples folder, type cargo run --example basic