KPlayerFaction.cpp
上传用户:dzyhzl
上传日期:2019-04-29
资源大小:56270k
文件大小:5k
源码类别:

模拟服务器

开发平台:

C/C++

  1. //---------------------------------------------------------------------------
  2. // Sword3 Engine (c) 2002 by Kingsoft
  3. //
  4. // File: KPlayerFaction.cpp
  5. // Date: 2002.09.26
  6. // Code: 边城浪子
  7. // Desc: PlayerFaction Class
  8. //---------------------------------------------------------------------------
  9. #include "KCore.h"
  10. #include "MyAssert.H"
  11. #include "GameDataDef.h"
  12. #include "KFaction.h"
  13. #include "KPlayerFaction.h"
  14. #define FACTION_NEW "初入江湖"
  15. #define FACTION_OLD "江湖游侠"
  16. //---------------------------------------------------------------------------
  17. // 功能:构造函数
  18. //---------------------------------------------------------------------------
  19. KPlayerFaction::KPlayerFaction()
  20. {
  21. Release();
  22. }
  23. //---------------------------------------------------------------------------
  24. // 功能:清空
  25. //---------------------------------------------------------------------------
  26. void KPlayerFaction::Release()
  27. {
  28. m_nCurFaction = -1;
  29. m_nFirstAddFaction = -1;
  30. m_nAddTimes = 0;
  31. }
  32. //---------------------------------------------------------------------------
  33. // 功能:根据玩家的五行属性确定玩家门派数据
  34. //---------------------------------------------------------------------------
  35. void KPlayerFaction::SetSeries(int nSeries)
  36. {
  37. return;
  38. /*
  39. if (nSeries < series_metal || nSeries >= series_num)
  40. return;
  41. int nID;
  42. for (int i = 0; i < FACTIONS_PRR_SERIES; i++)
  43. {
  44. nID = g_Faction.GetID(nSeries, i);
  45. _ASSERT(nID >= 0);
  46. if (m_sSkillOpen[i].m_nID != nID)
  47. {
  48. m_sSkillOpen[i].m_nID = nID;
  49. m_sSkillOpen[i].m_nOpenLevel = 0;
  50. }
  51. }
  52. */
  53. }
  54. //---------------------------------------------------------------------------
  55. // 功能:加入门派
  56. //---------------------------------------------------------------------------
  57. BOOL KPlayerFaction::AddFaction(int nSeries, char *lpszFactionName)
  58. {
  59. int nID;
  60. nID = g_Faction.GetID(nSeries, lpszFactionName);
  61. if (nID < 0)
  62. return FALSE;
  63. return AddFaction(nSeries, nID);
  64. }
  65. //---------------------------------------------------------------------------
  66. // 功能:加入门派
  67. //---------------------------------------------------------------------------
  68. BOOL KPlayerFaction::AddFaction(int nSeries, int nFactionID)
  69. {
  70. if (nSeries < series_metal || nSeries >= series_num)
  71. return FALSE;
  72. if (nFactionID < nSeries * FACTIONS_PRR_SERIES || nFactionID >= (nSeries + 1) * FACTIONS_PRR_SERIES)
  73. return FALSE;
  74. SetSeries(nSeries);
  75. m_nCurFaction = nFactionID;
  76. m_nAddTimes++;
  77. if (m_nAddTimes == 1)
  78. m_nFirstAddFaction = nFactionID;
  79. return TRUE;
  80. }
  81. //---------------------------------------------------------------------------
  82. // 功能:离开当前门派
  83. //---------------------------------------------------------------------------
  84. void KPlayerFaction::LeaveFaction()
  85. {
  86. m_nCurFaction = -1;
  87. }
  88. //---------------------------------------------------------------------------
  89. // 功能:开放当前门派某个等级的技能
  90. //---------------------------------------------------------------------------
  91. BOOL KPlayerFaction::OpenCurSkillLevel(int nLevel, KSkillList *pSkillList)
  92. {
  93. return TRUE;
  94. /*
  95. if (nLevel < 0 || nLevel >= FACTION_SKILL_LEVEL || !pSkillList)
  96. return FALSE;
  97. if (m_nCurFaction < 0)
  98. return FALSE;
  99. int i, j;
  100. // 设定当前开放等级
  101. for (i = 0; i < FACTIONS_PRR_SERIES; i++)
  102. {
  103. if (m_nCurFaction == m_sSkillOpen[i].m_nID)
  104. {
  105. m_sSkillOpen[i].m_nOpenLevel = nLevel;
  106. break;
  107. }
  108. }
  109. // 设定玩家技能
  110. for (i = 0; i <= nLevel; i++)
  111. {
  112. for (j = 0; j < FACTION_SKILLS_PER_LEVEL; j++)
  113. {
  114. if (g_Faction.m_sAttribute[m_nCurFaction].m_nSkill[i][j] <= 0)
  115. continue;
  116. pSkillList->Add(g_Faction.m_sAttribute[m_nCurFaction].m_nSkill[i][j], 0);
  117. }
  118. }
  119. return TRUE;
  120. */
  121. }
  122. //---------------------------------------------------------------------------
  123. // 功能:获得当前门派阵营
  124. //---------------------------------------------------------------------------
  125. int KPlayerFaction::GetGurFactionCamp()
  126. {
  127. if (m_nCurFaction < 0)
  128. {
  129. if (m_nAddTimes == 0)
  130. return camp_begin;
  131. else
  132. return camp_free;
  133. }
  134. else
  135. {
  136. if (g_Faction.GetCamp(m_nCurFaction) >= 0)
  137. return g_Faction.GetCamp(m_nCurFaction);
  138. else
  139. return camp_begin;
  140. }
  141. }
  142. //---------------------------------------------------------------------------
  143. // 功能:获得当前门派
  144. //---------------------------------------------------------------------------
  145. int KPlayerFaction::GetCurFactionNo()
  146. {
  147. return m_nCurFaction;
  148. }
  149. //---------------------------------------------------------------------------
  150. // 功能:获得当前门派
  151. //---------------------------------------------------------------------------
  152. void KPlayerFaction::GetCurFactionName(char *lpszGetName)
  153. {
  154. if (!lpszGetName)
  155. return;
  156. if (this->m_nCurFaction == -1)
  157. {
  158. if (this->m_nAddTimes == 0)
  159. {
  160. lpszGetName[0] = 0;
  161. }
  162. else
  163. {
  164. strcpy(lpszGetName, FACTION_NEW);
  165. }
  166. }
  167. else
  168. {
  169. strcpy(lpszGetName, g_Faction.m_sAttribute[m_nCurFaction].m_szName);
  170. }
  171. return;
  172. }