Skip to main content

TypeChart

Trait TypeChart 

Source
pub trait TypeChart {
    type Type: PartialEq + Debug;

    // Required method
    fn effectiveness(attacking: &Self::Type, defending: &[Self::Type]) -> f32;
}
Expand description

N×N type effectiveness matrix.

Returns a multiplier for an attacking type against a set of defending types. The implementation can be a lookup table, a procedural rule, or any combination thereof.

Required Associated Types§

Source

type Type: PartialEq + Debug

The elemental type identifier.

Required Methods§

Source

fn effectiveness(attacking: &Self::Type, defending: &[Self::Type]) -> f32

Compute the effectiveness of an attacking type against one or more defending types.

The result is a multiplier: 1.0 = neutral, 2.0 = super effective, 0.5 = not very effective, 0.0 = immune.

For dual-type defenders, the caller passes both types in the defending slice and the chart computes the combined multiplier.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§