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

#include <guilds.h>

Public Member Functions

 Guilds (Database &database, Redis &redis)
absl::StatusOr< Membership > Of (uint32_t player)
 The guild the character is in, or a NotFound error for none.
absl::StatusOr< Membership > Create (const std::string &world, uint32_t player, const std::string &name)
absl::StatusOr< Membership > Invite (uint32_t from, uint32_t player)
absl::StatusOr< Membership > Accept (uint32_t player)
absl::Status Decline (uint32_t player)
 The player says no to the guild that asked, so that another can ask.
absl::StatusOr< Left > Leave (uint32_t player)
 The player leaves their guild, as LeaveGuild says, in a transaction.
absl::StatusOr< Changed > SetRank (uint32_t from, uint32_t player, protocol::Rank rank)
absl::StatusOr< Changed > Kick (uint32_t from, uint32_t player)
absl::StatusOr< Membership > Disband (uint32_t from)
absl::StatusOr< std::vector< protocol::GuildMember > > Roster (uint32_t guild)
absl::StatusOr< War > AskToWar (const std::string &world, uint32_t from, const std::string &name)
absl::StatusOr< std::vector< War > > Wars (const std::string &world)

Static Public Attributes

static constexpr int kMostMembers = 100
 How many characters a guild can have.
static constexpr std::chrono::seconds kInvitationLife {60}
 How long an invitation waits for an answer.
static constexpr std::chrono::seconds kWarAskLife {60}
 How long a guild's ask to war waits for the other's yes.
static constexpr std::chrono::minutes kWarLength {30}
 How long a war lasts, from the yes.

Detailed Description

Guilds and who's in them, in MySQL. A guild is in one world, as its characters are, and a character is in one guild at most. Unlike a player, whose own world saves them, a guild changes for players other than the one who acts, so it isn't in Redis: each change is a transaction. Only the invitations and the asks to war, which run out, are in Redis.

Definition at line 64 of file guilds.h.

Constructor & Destructor Documentation

◆ Guilds()

nanommo::Guilds::Guilds ( Database & database,
Redis & redis )
inline

Definition at line 75 of file guilds.h.

Member Function Documentation

◆ Accept()

absl::StatusOr< Membership > nanommo::Guilds::Accept ( uint32_t player)

The player joins the guild that asked them, as a member. A NotFound error says nobody asked, or that it's run out, or the guild is gone, AlreadyExists that they're in a guild, and ResourceExhausted that the guild is full.

Definition at line 243 of file guilds.cc.

◆ AskToWar()

absl::StatusOr< War > nanommo::Guilds::AskToWar ( const std::string & world,
uint32_t from,
const std::string & name )

The leader asks the guild of that name in the world, whatever its case, to war, and it returns the two, with no id, as the war hasn't started. Or when that guild asked theirs first, a minute ago at most, it's a yes, and it returns the war, which starts now. A NotFound error says there's no guild of that name, or the one who asks is in none, PermissionDenied that they don't lead it, InvalidArgument that it's their own, AlreadyExists that they've asked it already, and FailedPrecondition that either guild is at war.

Definition at line 457 of file guilds.cc.

◆ Create()

absl::StatusOr< Membership > nanommo::Guilds::Create ( const std::string & world,
uint32_t player,
const std::string & name )

A new guild in the world, which the character founds and leads. An InvalidArgument error says what's wrong with the name, and an AlreadyExists error that the name is taken in the world, or that the character is in a guild already.

Definition at line 182 of file guilds.cc.

◆ Decline()

absl::Status nanommo::Guilds::Decline ( uint32_t player)

The player says no to the guild that asked, so that another can ask.

Definition at line 618 of file guilds.cc.

◆ Disband()

absl::StatusOr< Membership > nanommo::Guilds::Disband ( uint32_t from)

The leader ends their guild, for everyone in it, and its name is free again. A PermissionDenied error says the one who asks doesn't lead it, and FailedPrecondition that it's at war. Returns the guild that ended.

Definition at line 395 of file guilds.cc.

◆ Invite()

absl::StatusOr< Membership > nanommo::Guilds::Invite ( uint32_t from,
uint32_t player )

Asks the player to join the guild of the one who asks, which an officer or the leader can do. A NotFound error says the one who asks is in no guild, a PermissionDenied one that they're a member, and AlreadyExists that a guild has asked the player, a minute ago at most, and they haven't answered. Returns the guild asked to join.

Definition at line 219 of file guilds.cc.

◆ Kick()

absl::StatusOr< Changed > nanommo::Guilds::Kick ( uint32_t from,
uint32_t player )

Takes a player out of the guild of the one who asks, whose rank has to be above theirs: the leader removes officers and members, and officers members. A PermissionDenied error says it isn't, NotFound that the player isn't in their guild, and FailedPrecondition that it's at war.

Definition at line 349 of file guilds.cc.

◆ Leave()

absl::StatusOr< Left > nanommo::Guilds::Leave ( uint32_t player)

The player leaves their guild, as LeaveGuild says, in a transaction.

Definition at line 622 of file guilds.cc.

◆ Of()

absl::StatusOr< Membership > nanommo::Guilds::Of ( uint32_t player)

The guild the character is in, or a NotFound error for none.

Definition at line 158 of file guilds.cc.

◆ Roster()

absl::StatusOr< std::vector< protocol::GuildMember > > nanommo::Guilds::Roster ( uint32_t guild)

Who's in the guild, the highest rank first, and by name, as MySQL has them: their levels are a few seconds behind a world's, and none of them online, which only a world knows.

Definition at line 425 of file guilds.cc.

◆ SetRank()

absl::StatusOr< Changed > nanommo::Guilds::SetRank ( uint32_t from,
uint32_t player,
protocol::Rank rank )

The leader makes a member an officer, or an officer a member again. A PermissionDenied error says the one who asks doesn't lead, NotFound that the player isn't in their guild, and InvalidArgument that the rank isn't one they can give.

Definition at line 308 of file guilds.cc.

◆ Wars()

absl::StatusOr< std::vector< War > > nanommo::Guilds::Wars ( const std::string & world)

The world's wars that haven't ended, with each side's kills, as MySQL has them.

Definition at line 581 of file guilds.cc.

Member Data Documentation

◆ kInvitationLife

std::chrono::seconds nanommo::Guilds::kInvitationLife {60}
staticconstexpr

How long an invitation waits for an answer.

Definition at line 69 of file guilds.h.

◆ kMostMembers

int nanommo::Guilds::kMostMembers = 100
staticconstexpr

How many characters a guild can have.

Definition at line 67 of file guilds.h.

◆ kWarAskLife

std::chrono::seconds nanommo::Guilds::kWarAskLife {60}
staticconstexpr

How long a guild's ask to war waits for the other's yes.

Definition at line 71 of file guilds.h.

◆ kWarLength

std::chrono::minutes nanommo::Guilds::kWarLength {30}
staticconstexpr

How long a war lasts, from the yes.

Definition at line 73 of file guilds.h.


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