1.0.0 • Published 5 years ago

adventure-land-test-helpers v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

adventure-land-test-helpers

Adventure Land MMORPG test stubs and mock data for unit testing player scripts. For a linting tool, see the ESLint plugin.

Installation

$ npm install adventure-land-test-helpers --save-dev

Usage

All test helpers work with standard JavaScript object access syntax.

const AdventureLandTestHelpers = require('adventure-land-test-helpers');
const { mocks, stubs } = AdventureLandTestHelpers;

let monster = mocks.data.MockMonster;
stubs.classic.is_monster(monster); // The "classic" stub will always return true.

Alternately, stubs may be injected into the global scope to mimic the game environment.

const AdventureLandTestHelpers = require('adventure-land-test-helpers');
const { injectIntoScope, stubs } = AdventureLandTestHelpers;

injectIntoScope(stubs.random, this);
is_monster(); // The "random" stub will return true or false.

API

Inject into Scope

  • Path: AdventureLandTestHelpers.injectIntoScope
  • Description: Inject functions into the desired scope, useful for creating global stubs.
// Inject stubs into the global scope...
const AdventureLandTestHelpers = require('adventure-land-test-helpers');
const { injectIntoScope, stubs } = AdventureLandTestHelpers;
injectIntoScope(stubs.random, this);

// ...then call one of the Adventure Land game functions.
is_monster();

Mock Data

  • Path: AdventureLandTestHelpers.mocks.data
  • Description: Mock game data that can be useful when testing scripts.
TypePath
Charactermocks.data.MockCharacter
Circlemocks.data.MockCircle
ItemStatsmocks.data.MockItemStats
Linemocks.data.MockLine
Mapmocks.data.MockMap
Monstermocks.data.MockMonster
Playermocks.data.MockPlayer
Socketmocks.data.MockSocket

Classic Stubs

  • Path: AdventureLandTestHelpers.stubs.classic
  • Description: Stubbed game runner functions that return the same value every time when called.
Return TypeReturn Value
*true
Character, Monster, PlayerMockCharacter
{ string: string }{ abc: 'xyz' }
Booleantrue
CharacterMockCharacter
CircleMockCircle
ItemStatsMockItemStats
LineMockLine
MapMockMap
MonsterMockMonster
Number42
PlayerMockPlayer
SocketMockSocket
undefinedundefined

Random Stubs

  • Path: AdventureLandTestHelpers.stubs.classic
  • Description: Stubbed game runner functions that return a random possible value when called.
Return TypeReturn Value
**
Character, Monster, PlayerMockCharacter, MockMonster, MockPlayer, null, undefined
{ string: string }{ abc: 'xyz' }, null, undefined
Booleantrue, false
CharacterMockCharacter, null, undefined
CircleMockCircle, null, undefined
ItemStatsMockItemStats, null, undefined
LineMockLine, null, undefined
MapMockMap, null, undefined
MonsterMockMonster, null, undefined
Number1, 1000
PlayerMockPlayer, null, undefined
SocketMockSocket, null, undefined
undefinedundefined

Stubbed Functions

  • Path: AdventureLandTestHelpers.stubs.classic, AdventureLandTestHelpers.stubs.random
  • Description: Stubbed game runner functions.
Function NameReturn Type
accept_party_inviteundefined
accept_party_requestundefined
activateundefined
add_bottom_buttonundefined
add_top_buttonundefined
attackundefined
auto_reloadundefined
bank_depositundefined
bank_storeundefined
bank_withdrawundefined
bfsundefined
buy_with_goldundefined
buy_with_shellsundefined
buyundefined
can_attackBoolean
can_healBoolean
can_move_toBoolean
can_useBoolean
change_serverundefined
change_targetundefined
clear_buttonsundefined
clear_drawingsundefined
code_drawundefined
command_characterundefined
compoundundefined
continue_pathfindingundefined
craftundefined
cruiseundefined
destroy_itemundefined
draw_circleCircle
draw_lineLine
equipundefined
eval_sundefined
exchangeundefined
game_logundefined
get_active_characters{ string, string }
get_mapMap
get_nearest_hostileCharacter
get_nearest_monsterMonster
get_playerPlayer
get_socketSocket
get_target_ofCharacterMonsterPlayer
get_targetCharacterMonsterPlayer
get_targeted_monsterMonster
handle_commandundefined
handle_deathundefined
healundefined
in_attack_rangeBoolean
is_characterBoolean
is_monsterBoolean
is_movingBoolean
is_npcBoolean
is_pausedBoolean
is_playerBoolean
is_pvpBoolean
is_transportingBoolean
item_gradeNumber
item_propertiesItemStats
item_valueNumber
load_codeundefined
lootundefined
map_keyundefined
moveundefined
on_cmundefined
on_combined_damageundefined
on_destroyundefined
on_disappearundefined
on_drawundefined
on_game_eventundefined
on_party_inviteundefined
on_party_requestundefined
pauseundefined
performance_trickundefined
pget*
plotundefined
pmundefined
preview_itemundefined
proxyundefined
psetundefined
qpushNumber
quantityNumber
reset_mappingsundefined
respawnundefined
sayundefined
sellundefined
send_cmundefined
send_goldundefined
send_itemundefined
send_party_inviteundefined
send_party_requestundefined
set_button_colorundefined
set_button_onclickundefined
set_button_valueundefined
set_keymapundefined
set_messageundefined
set_skillbarundefined
shiftundefined
show_jsonundefined
smart_move_logicundefined
smart_moveundefined
smooth_pathundefined
start_characterundefined
start_pathfindingundefined
stop_characterundefined
stopundefined
swapundefined
trade_buyundefined
tradeundefined
transportundefined
trigger_eventundefined
unequipundefined
unfriendundefined
unmap_keyundefined
upgradeundefined
use_hp_or_mpundefined
use_skillundefined
useundefined
xmoveundefined

Sources

  1. Official Adventure Land MMORPG source code by Kaan Soral.
  2. Unofficial Adventure Land MMORPG code documentation by NexusNull.