Package moe.maika.ygofm.gamedata
Class FMDB
java.lang.Object
moe.maika.ygofm.gamedata.FMDB
The entry point for querying FM game data. This class is a singleton and
should be accessed via the
Use this class to instantiate Card and Duelist objects.
This class is thread-safe. All classes in this library are thread-safe unless otherwise noted, even if they do not explicitly state they are thread-safe.
getInstance()
method.
Use this class to instantiate Card and Duelist objects.
This class is thread-safe. All classes in this library are thread-safe unless otherwise noted, even if they do not explicitly state they are thread-safe.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionPerforms a fusion or returns the second card if no fusion is possible.fuseOrNull
(Card firstCard, Card secondCard) Performs a fusion or returns null if no fusion is possible.Gets all FM cards.Gets all FM duelists.Returns all rituals in the game.getCard
(int id) Gets a card by its id.getDuelist
(int id) Gets a duelist by id.getDuelist
(Duelist.Name name) Gets a duelist by name.static FMDB
Gets the singleton instance of FMDB.getRitual
(int ritualCardId) Returns theRitual
that is activated by the given ritual card id.Returns theRitual
that is activated by the given ritual card.boolean
isEquippable
(Card monster, Card equip) Determines whether a monster can be equipped with an equip card.
-
Field Details
-
RITUAL_TYPE
- See Also:
-
TRAP_TYPE
- See Also:
-
MAGIC_TYPE
- See Also:
-
EQUIP_TYPE
- See Also:
-
NON_MONSTER_TYPES
-
-
Method Details
-
getCard
Gets a card by its id.- Parameters:
id
- a card id- Returns:
- the card with the given id, or null if no such card exists
-
getAllCards
Gets all FM cards.- Returns:
- all cards in the game
-
getDuelist
Gets a duelist by name.- Parameters:
name
- a duelist name- Returns:
- the duelist with the given name, never null
- Throws:
IllegalArgumentException
- if name is null
-
getDuelist
Gets a duelist by id. Consider usinggetDuelist(Duelist.Name)
instead.- Parameters:
id
- the id of a duelist as specified by the FM database- Returns:
- the duelist with the given id, or null if no such duelist exists
-
getAllDuelists
Gets all FM duelists.- Returns:
- all duelists in the game
-
fuse
Performs a fusion or returns the second card if no fusion is possible. This behavior mirrors the in-game mechanic when selecting two cards to fuse.- Parameters:
firstCard
- the first card of the fusionsecondCard
- the second card of the fusion- Returns:
- the result of fusing the two cards, or the second card if no fusion is possible, never null
- Throws:
IllegalArgumentException
- if either card is null
-
fuseOrNull
Performs a fusion or returns null if no fusion is possible.- Parameters:
firstCard
- the first card of the fusionsecondCard
- the second card of the fusion- Returns:
- the result of fusing the two cards, or null if no fusion is possible
-
isEquippable
Determines whether a monster can be equipped with an equip card. Consider usingCard.equips(Card)
orCard.canBeEquippedWith(Card)
instead to avoid parameter-ordering errors.- Parameters:
monster
- the monster to equipequip
- the equip card- Returns:
- true if the monster can be equipped with the equip
- Throws:
IllegalArgumentException
- the first card is not a monster card, or the second card is not an equip card, or either card is null
-
getRitual
Returns theRitual
that is activated by the given ritual card id.- Parameters:
ritualCardId
- the id of the ritual card- Returns:
- the ritual, or null if
ritualCardId
is not a ritual card id
-
getRitual
Returns theRitual
that is activated by the given ritual card.- Parameters:
ritualCard
- the ritual card- Returns:
- the ritual, or null if
ritualCard
is not a ritual card - Throws:
IllegalArgumentException
- ifritualCard
is null
-
getAllRituals
Returns all rituals in the game.- Returns:
- all rituals in the game
-
getInstance
Gets the singleton instance of FMDB. If the database has not been loaded yet, this method will load it.This method can safely be called from any thread; initialization is synchronized and will only occur once. Access after initialization does not incur any synchronization overhead since the double-checked locking optimization idiom is used internally.
- Returns:
- the singleton instance of FMDB
-