Skip to content

JGTools/MatchMaking

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MatchMaking

npm npm GitHub

MatchMaking system for online games

Installation

Using npm

npm i @jgtools/matchmaking
import MatchMaking from "@jgtools/matchmaking";
// ...

Using cdn

<script type="module">
    import MatchMaking from "https://cdn.jsdelivr.net/npm/@jgtools/[email protected]/dist/index.min.js";
    // ...
</script>

Usage

import MatchMaking, { Lobby, Match } from "@jgtools/matchmaking";

const config = {
  TEAM_SIZE: 5,
  TEAMS_PER_MATCH: 2,
  MM_INTERVAL: 1000,
  MAX_DIFF_START: 0.02,
  INCREASE_DIFF_TIME: 60000,
  CLEAR_INTERVAL: 3600000,
  CLEAR_AFTER_QUE_TIME: 7200000,
};
const onMatchesFound = (matches: Match[]) => {
  // do something with matches that were created
};
const mm = new MatchMaking(onMatchesFound, config);

// add lobby to matchmaking
const lobby: Lobby = {
  id: "123",
  rank: 0.7,
  members: 3,
};
mm.addToQue(lobby);

License

MIT

Releases

No releases published

Packages

No packages published