SEGS  0.6.1-develop [d2cac982]
Super Entity Game Server
Team.h
Go to the documentation of this file.
1 /*
2  * SEGS - Super Entity Game Server
3  * http://www.segs.io/
4  * Copyright (c) 2006 - 2019 SEGS Team (see AUTHORS.md)
5  * This software is licensed under the terms of the 3-clause BSD License. See LICENSE.md for details.
6  */
7 
8 #pragma once
9 #include "CommonNetStructures.h"
10 
11 class Entity;
12 
13 class Team
14 {
15 public:
16  Team()
17  : m_team_idx( ++m_team_idx_counter )
18  { }
19  ~Team();
20 
21  struct TeamMember {
22  uint32_t tm_idx = 0;
23  QString tm_name; // stored here for quick lookup.
24  QString tm_map; // stored here for quick lookup.
25  // this value is transient, and should be updated by TeamingService
26  uint32_t tm_map_idx = 0;
27  };
28 
29  // Member Vars
30  std::vector<TeamMember> m_team_members;
31 
32 const uint32_t m_team_idx = 0;
33  uint32_t m_max_team_size = 8; // max is always 8
34  uint32_t m_team_leader_idx = 0;
35  bool m_has_taskforce = false; // it's possible that this belongs to entity or char instead
36 
37  // Methods
38  void dump();
39  void dumpAllTeamMembers();
40  void addTeamMember(Entity *e, uint32_t teammate_map_idx);
41  bool isTeamLeader(Entity *e);
42 
43 private:
44 static uint32_t m_team_idx_counter;
45 };
46 
47 
48 /*
49  * Team Methods
50  */
51 bool sameTeam(Entity &src, Entity &tgt);
52 bool makeTeamLeader(Entity &src, Entity &tgt);
53 bool inviteTeam(Entity &src, Entity &tgt);
54 bool kickTeam(Entity &tgt);
55 void leaveTeam(Entity &e);
56 void removeTeamMember(Team &self,Entity *e);
58 {
59  SUCCESS,
62  MENTOR_LEVEL_TOO_LOW, // player level is not high enough
63  CANNOT_MENTOR_YET, // player level must be higher to have a sidekick
68 };
69 
70 /*
71  * Sidekick Methods -- Sidekick system requires teaming.
72  */
73 
74 uint32_t getSidekickId(const class Character &src);
75 bool isSidekickMentor(const Entity &e);
77 void addSidekick(Entity &tgt, Entity &src);
78 SidekickChangeStatus removeSidekick(Entity &src, uint32_t sidekick_id);
void addTeamMember(Entity *e, uint32_t teammate_map_idx)
Definition: Team.cpp:26
std::vector< TeamMember > m_team_members
Definition: Team.h:30
uint32_t getSidekickId(const class Character &src)
Definition: Character.h:47
const uint32_t m_team_idx
Definition: Team.h:32
Definition: Team.h:13
void removeTeamMember(Team &self, Entity *e)
Definition: Team.cpp:145
bool isTeamLeader(Entity *e)
Definition: Team.cpp:73
uint32_t m_max_team_size
Definition: Team.h:33
Definition: Team.h:21
bool kickTeam(Entity &tgt)
Definition: Team.cpp:125
SidekickChangeStatus inviteSidekick(Entity &src, Entity &tgt)
Definition: Team.cpp:209
void dump()
Definition: Team.cpp:51
SidekickChangeStatus
Definition: Team.h:57
bool isSidekickMentor(const Entity &e)
Definition: Team.cpp:204
void addSidekick(Entity &tgt, Entity &src)
Definition: Team.cpp:239
uint32_t tm_map_idx
Definition: Team.h:26
bool inviteTeam(Entity &src, Entity &tgt)
Definition: Team.cpp:98
uint32_t m_team_leader_idx
Definition: Team.h:34
bool sameTeam(Entity &src, Entity &tgt)
Definition: Team.cpp:82
QString tm_map
Definition: Team.h:24
Definition: Entity.h:134
bool makeTeamLeader(Entity &src, Entity &tgt)
Definition: Team.cpp:87
SidekickChangeStatus removeSidekick(Entity &src, uint32_t sidekick_id)
Definition: Team.cpp:270
QString tm_name
Definition: Team.h:23
bool m_has_taskforce
Definition: Team.h:35
Team()
Definition: Team.h:16
uint32_t tm_idx
Definition: Team.h:22
void leaveTeam(Entity &e)
Definition: Team.cpp:134
void dumpAllTeamMembers()
Definition: Team.cpp:63