-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #241 from alborrajo/feature/repop
Help and Repop chat commands
- Loading branch information
Showing
4 changed files
with
104 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 0 additions & 89 deletions
89
Arrowgene.Ddon.GameServer/Chat/Command/Commands/EnemyCommand.cs
This file was deleted.
Oops, something went wrong.
28 changes: 28 additions & 0 deletions
28
Arrowgene.Ddon.GameServer/Chat/Command/Commands/HelpCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System.Linq; | ||
using System.Collections.Generic; | ||
using Arrowgene.Ddon.Database.Model; | ||
|
||
namespace Arrowgene.Ddon.GameServer.Chat.Command.Commands | ||
{ | ||
public class HelpCommand : ChatCommand | ||
{ | ||
public override AccountStateType AccountState => AccountStateType.User; | ||
public override string Key => "help"; | ||
public override string HelpText => "usage: `/help` - Shows this text"; | ||
|
||
private Dictionary<string, ChatCommand> ChatCommands; | ||
|
||
public HelpCommand(Dictionary<string, ChatCommand> chatCommands) | ||
{ | ||
ChatCommands = chatCommands; | ||
} | ||
|
||
public override void Execute(string[] command, GameClient client, ChatMessage message, List<ChatResponse> responses) | ||
{ | ||
this.ChatCommands.Values | ||
.Select(cmd => new ChatResponse() {Message = cmd.HelpText}) | ||
.ToList() | ||
.ForEach(response => responses.Add(response)); | ||
} | ||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
Arrowgene.Ddon.GameServer/Chat/Command/Commands/RepopCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Arrowgene.Ddon.Database.Model; | ||
using Arrowgene.Ddon.Shared.Entity.PacketStructure; | ||
using Arrowgene.Ddon.Shared.Entity.Structure; | ||
using Arrowgene.Ddon.Shared.Model; | ||
|
||
namespace Arrowgene.Ddon.GameServer.Chat.Command.Commands | ||
{ | ||
public class RepopCommand : ChatCommand | ||
{ | ||
public override AccountStateType AccountState => AccountStateType.User; | ||
public override string Key => "repop"; | ||
public override string HelpText => "usage: `/repop StageId LayerNo GroupId SubGroupId PositionIndex (WaitSeconds)` - The enemy in the CSV should have RepopCount > 0`"; | ||
|
||
private DdonGameServer Server; | ||
|
||
public RepopCommand(DdonGameServer server) { | ||
Server = server; | ||
} | ||
|
||
public override void Execute(string[] command, GameClient client, ChatMessage message, List<ChatResponse> responses) | ||
{ | ||
if (command.Length < 5) | ||
{ | ||
responses.Add(ChatResponse.CommandError(client, "no arguments provided")); | ||
return; | ||
} | ||
|
||
try | ||
{ | ||
uint stageNo = uint.Parse(command[0]); | ||
byte layerNo = byte.Parse(command[1]); | ||
uint groupId = uint.Parse(command[2]); | ||
byte subGroupId = byte.Parse(command[3]); | ||
byte positionIndex = byte.Parse(command[4]); | ||
uint waitSeconds = 0; | ||
|
||
if (command.Length > 5) | ||
{ | ||
waitSeconds = uint.Parse(command[5]); | ||
} | ||
|
||
|
||
CDataStageLayoutId enemyGroup = new CDataStageLayoutId() //client.Character.EnemyGroupsEntered.First(); | ||
{ | ||
StageId = stageNo, | ||
LayerNo = layerNo, | ||
GroupId = groupId | ||
}; | ||
List<EnemySpawn> enemySpawns = Server.EnemyManager.GetAssets(enemyGroup, subGroupId); | ||
|
||
if (enemySpawns.Count <= positionIndex) | ||
{ | ||
responses.Add(ChatResponse.CommandError(client, "no enemies to repopulate in this enemy group and position index")); | ||
return; | ||
} | ||
|
||
S2CInstanceEnemyRepopNtc ntc = new S2CInstanceEnemyRepopNtc(); | ||
ntc.LayoutId = enemyGroup; | ||
ntc.EnemyData.PositionIndex = positionIndex; | ||
ntc.EnemyData.EnemyInfo = enemySpawns[positionIndex].Enemy; | ||
ntc.WaitSecond = waitSeconds; | ||
client.Party.SendToAll(ntc); | ||
|
||
responses.Add(ChatResponse.ServerMessage(client, "Command Executed")); | ||
} | ||
catch(Exception) | ||
{ | ||
responses.Add(ChatResponse.CommandError(client, "invalid arguments")); | ||
} | ||
} | ||
} | ||
} |