model

package
v0.0.0-...-fa8f6e1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 30, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WORLD_ID = 1022
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Match

type Match struct {
	TotalKills   int
	Players      map[int]*Player
	MeansOfDeath map[MeanOfDeath]int
}

func NewMatch

func NewMatch() *Match

Creates a new instance of Match

func (*Match) AddPlayer

func (m *Match) AddPlayer(playerID int) error

Add a player to the current Match

func (*Match) DisconnectPlayer

func (m *Match) DisconnectPlayer(playerID int) error

Disconnect a player for the current match Generate a hash based on player name to allow kill count restore if user reconnects

func (*Match) ProcessKill

func (m *Match) ProcessKill(killerID, victimID, meanID int) error

Process a kill event If the killer is World, decrement the victim kill count Update the match kill count and the deaths by weapon count

func (*Match) ToMatchJSON

func (m *Match) ToMatchJSON() MatchJSON

Transform the Match model to the desired output format

func (*Match) UpdateUserInfo

func (m *Match) UpdateUserInfo(playerID int, playerName string) error

Update nickname of a player on the current match Check if the name hash of the user is the same as a user that has disconnected before. If so, restore the kill count

type MatchJSON

type MatchJSON struct {
	TotalKills   int            `json:"total_kills"`
	Players      []string       `json:"players"`
	Kills        map[string]int `json:"kills"`
	Leaderboard  []string       `json:"leaderboard"`
	MeansOfDeath map[string]int `json:"kills_by_means"`
}

type MeanOfDeath

type MeanOfDeath int
const (
	MOD_UNKNOWN MeanOfDeath = iota
	MOD_SHOTGUN
	MOD_GAUNTLET
	MOD_MACHINEGUN
	MOD_GRENADE
	MOD_GRENADE_SPLASH
	MOD_ROCKET
	MOD_ROCKET_SPLASH
	MOD_PLASMA
	MOD_PLASMA_SPLASH
	MOD_RAILGUN
	MOD_LIGHTNING
	MOD_BFG
	MOD_BFG_SPLASH
	MOD_WATER
	MOD_SLIME
	MOD_LAVA
	MOD_CRUSH
	MOD_TELEFRAG
	MOD_FALLING
	MOD_SUICIDE
	MOD_TARGET_LASER
	MOD_TRIGGER_HURT
)

func (MeanOfDeath) String

func (m MeanOfDeath) String() string

type Player

type Player struct {
	Name  string
	Kills int
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL