nanoMMO 0.97.8
Building an MMO: The Engineering Series
Loading...
Searching...
No Matches
nanommo::Duels Class Reference

#include <duels.h>

Classes

struct  Duel

Public Types

enum class  State { kAsked , kCountdown , kFighting }

Public Member Functions

void Ask (uint32_t id, uint32_t other)
 The player asks the other to duel. Neither may be in a duel already.
uint32_t Accept (uint32_t id, Place flag)
const Duel * Of (uint32_t id) const
 The player's duel, from the ask to the end, or nullptr.
uint32_t Opponent (uint32_t id) const
 Who the player's duelling, by their id, once the countdown's over, or 0.
uint32_t End (uint32_t id)
std::vector< Duel > Step (std::chrono::nanoseconds time)
const std::map< uint32_t, Duel > & all () const
 Each duel, by its challenger's id.
std::set< uint32_t > TakeNews ()

Static Public Attributes

static constexpr float kReach = 10.0f
 A player asks another within this many metres of them.
static constexpr std::chrono::seconds kAskTime {30}
 An ask waits this long for a yes.
static constexpr std::chrono::seconds kCountdown {3}
 From the yes to the duel, so that both sides are ready for it.
static constexpr float kFlagReach = 25.0f

Detailed Description

The duels between the players in one copy of a land, which its World keeps, as it does their trades, so that both players are always in it. A player asks another to duel, and once the other says yes, a countdown starts, and then the duel. A player is in one duel at a time, from the ask to the end.

Definition at line 19 of file duels.h.

Member Enumeration Documentation

◆ State

enum class nanommo::Duels::State
strong
Enumerator
kAsked 
kCountdown 
kFighting 

Definition at line 34 of file duels.h.

Member Function Documentation

◆ Accept()

uint32_t nanommo::Duels::Accept ( uint32_t id,
Place flag )

The player says yes to whoever asked them, which puts the flag down and starts the countdown. Returns who asked, or 0 if nobody did.

Definition at line 18 of file duels.cc.

◆ all()

const std::map< uint32_t, Duel > & nanommo::Duels::all ( ) const
inline

Each duel, by its challenger's id.

Definition at line 73 of file duels.h.

◆ Ask()

void nanommo::Duels::Ask ( uint32_t id,
uint32_t other )

The player asks the other to duel. Neither may be in a duel already.

Definition at line 11 of file duels.cc.

◆ End()

uint32_t nanommo::Duels::End ( uint32_t id)

Ends the player's duel, however far it's got. Returns who it was with, or 0.

Definition at line 45 of file duels.cc.

◆ Of()

const Duels::Duel * nanommo::Duels::Of ( uint32_t id) const

The player's duel, from the ask to the end, or nullptr.

Definition at line 34 of file duels.cc.

◆ Opponent()

uint32_t nanommo::Duels::Opponent ( uint32_t id) const

Who the player's duelling, by their id, once the countdown's over, or 0.

Definition at line 39 of file duels.cc.

◆ Step()

std::vector< Duels::Duel > nanommo::Duels::Step ( std::chrono::nanoseconds time)

Runs the asks and the countdowns down, and starts the duels whose countdowns are over. Returns the asks that ran out, which are over.

Definition at line 59 of file duels.cc.

◆ TakeNews()

std::set< uint32_t > nanommo::Duels::TakeNews ( )

The players whose duel has been asked for, counted down, started or ended since the last time, which it hands over.

Definition at line 90 of file duels.cc.

Member Data Documentation

◆ kAskTime

std::chrono::seconds nanommo::Duels::kAskTime {30}
staticconstexpr

An ask waits this long for a yes.

Definition at line 25 of file duels.h.

◆ kCountdown

std::chrono::seconds nanommo::Duels::kCountdown {3}
staticconstexpr

From the yes to the duel, so that both sides are ready for it.

Definition at line 28 of file duels.h.

◆ kFlagReach

float nanommo::Duels::kFlagReach = 25.0f
staticconstexpr

The flag goes down where the one who asked stands as the other says yes, and a duellist who goes further from it than this loses.

Definition at line 32 of file duels.h.

◆ kReach

float nanommo::Duels::kReach = 10.0f
staticconstexpr

A player asks another within this many metres of them.

Definition at line 22 of file duels.h.


The documentation for this class was generated from the following files: