跳到主要内容

IMonsterDatabase

Read-only contract for querying the Monster Database. This is the public API surface for all database queries.

Namespace: OpenMon.MCE.SDK

定义​

public interface IMonsterDatabase
{
MonsterEntry GetMonster(uint dexNumber);
MonsterEntry GetMonster(string name);
IReadOnlyList<MonsterEntry> GetAllMonsters();

Move GetMove(string name);
IReadOnlyList<Move> GetAllMoves();

Ability GetAbility(string name);
IReadOnlyList<Ability> GetAllAbilities();

Item GetItem(string name);
IReadOnlyList<Item> GetAllItems();

IReadOnlyList<MonsterType> GetAllTypes();
float GetTypeEffectiveness(MonsterType attackingType, MonsterType defendingType);

IReadOnlyList<Form> GetAllForms();

int MonsterCount { get; }
}

方法​

GetMonster(uint dexNumber)​

Get a monster entry by its national dex number.

参数类型描述
dexNumberuintThe unique dex number

Returns: MonsterEntry or null if not found.

GetMonster(string name)​

Get a monster entry by its species name.

参数类型描述
namestringThe species name (case-sensitive)

Returns: MonsterEntry or null if not found.

GetAllMonsters()​

Get all registered monster entries in the database.

Returns: IReadOnlyList<MonsterEntry> -- all species, ordered by dex number.

GetMove(string name)​

Get a move by its name.

Returns: Move or null if not found.

GetAllMoves()​

Get all registered moves.

Returns: IReadOnlyList<Move> -- all 668+ moves.

GetAbility(string name)​

Get an ability by its name.

Returns: Ability or null if not found.

GetAllAbilities()​

Get all registered abilities.

Returns: IReadOnlyList<Ability>.

GetItem(string name)​

Get an item by its name.

Returns: Item or null if not found.

GetAllItems()​

Get all registered items.

Returns: IReadOnlyList<Item>.

GetAllTypes()​

Get all registered monster types.

Returns: IReadOnlyList<MonsterType> -- the 18 standard types (or custom types if modified).

GetTypeEffectiveness(MonsterType, MonsterType)​

Get the type effectiveness multiplier for one type attacking another.

参数类型描述
attackingTypeMonsterTypeThe move's type
defendingTypeMonsterTypeThe target's type (single type)

Returns: float -- 0.0 (immune), 0.5 (not very effective), 1.0 (neutral), or 2.0 (super effective).

Dual Types

This method checks one attacking type against one defending type. For dual-typed defenders, call it twice and multiply the results:

float effectiveness = db.GetTypeEffectiveness(moveType, defenderType1)
* db.GetTypeEffectiveness(moveType, defenderType2);

GetAllForms()​

Get all registered forms.

Returns: IReadOnlyList<Form>.

属性​

MonsterCount​

Total number of monster entries in the database.

Type: int

用法示例​

[Inject] private IMonsterDatabase db;

// Find a specific monster
MonsterEntry sparkbit = db.GetMonster("Sparkbit");
MonsterEntry starter = db.GetMonster(1);

// Check type matchup
float eff = db.GetTypeEffectiveness(MonsterType.Water, MonsterType.Fire);
Debug.Log($"Water vs Fire: {eff}x"); // 2.0x

// Count all Fire-type monsters
int fireCount = db.GetAllMonsters()
.Count(m => m.Type1 == MonsterType.Fire || m.Type2 == MonsterType.Fire);