-
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 #655 from alborrajo/feature/lostpawn
Lost Pawns
- Loading branch information
Showing
38 changed files
with
1,052 additions
and
51 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
2 changes: 2 additions & 0 deletions
2
Arrowgene.Ddon.Database/Files/Database/Script/migration_pawn_state.sql
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,2 @@ | ||
ALTER TABLE "ddon_pawn" | ||
ADD COLUMN "pawn_state" SMALLINT NOT NULL DEFAULT 0; |
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
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
24 changes: 24 additions & 0 deletions
24
Arrowgene.Ddon.Database/Sql/Core/Migration/00000026_PawnStateMigration.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,24 @@ | ||
using System.Data.Common; | ||
|
||
namespace Arrowgene.Ddon.Database.Sql.Core.Migration | ||
{ | ||
public class PawnStateMigration : IMigrationStrategy | ||
{ | ||
public uint From => 25; | ||
public uint To => 26; | ||
|
||
private readonly DatabaseSetting DatabaseSetting; | ||
|
||
public PawnStateMigration(DatabaseSetting databaseSetting) | ||
{ | ||
DatabaseSetting = databaseSetting; | ||
} | ||
|
||
public bool Migrate(IDatabase db, DbConnection conn) | ||
{ | ||
string adaptedSchema = DdonDatabaseBuilder.GetAdaptedSchema(DatabaseSetting, "Script/migration_pawn_state.sql"); | ||
db.Execute(conn, adaptedSchema); | ||
return true; | ||
} | ||
} | ||
} |
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
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
37 changes: 29 additions & 8 deletions
37
Arrowgene.Ddon.GameServer/Handler/PawnGetLostPawnListHandler.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 |
---|---|---|
@@ -1,26 +1,47 @@ | ||
using Arrowgene.Ddon.Server; | ||
using Arrowgene.Ddon.Server.Network; | ||
using Arrowgene.Ddon.Shared.Network; | ||
using Arrowgene.Logging; | ||
using Arrowgene.Ddon.Shared.Entity.PacketStructure; | ||
using Arrowgene.Ddon.Shared.Model.Quest; | ||
using Arrowgene.Ddon.Shared.Entity.Structure; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Arrowgene.Ddon.Shared.Model; | ||
|
||
namespace Arrowgene.Ddon.GameServer.Handler | ||
{ | ||
public class PawnGetLostPawnListHandler : StructurePacketHandler<GameClient, C2SPawnGetLostPawnListReq> | ||
public class PawnGetLostPawnListHandler : GameRequestPacketHandler<C2SPawnGetLostPawnListReq, S2CPawnGetLostPawnListRes> | ||
{ | ||
private static readonly ServerLogger Logger = LogProvider.Logger<ServerLogger>(typeof(PawnGetLostPawnListHandler)); | ||
|
||
public PawnGetLostPawnListHandler(DdonGameServer server) : base(server) | ||
{ | ||
} | ||
|
||
public override void Handle(GameClient client, StructurePacket<C2SPawnGetLostPawnListReq> req) | ||
public override S2CPawnGetLostPawnListRes Handle(GameClient client, C2SPawnGetLostPawnListReq request) | ||
{ | ||
var res = new S2CPawnGetLostPawnListRes(); | ||
client.Send(res); | ||
return new S2CPawnGetLostPawnListRes() | ||
{ | ||
LostPawnList = client.Character.Pawns | ||
.Select((pawn, index) => new { pawn, slot = index+1 }) | ||
.Where(tuple => tuple.pawn.PawnState == PawnState.Lost) | ||
.Select(tuple => new CDataLostPawnList() | ||
{ | ||
PawnId = (int) tuple.pawn.PawnId, | ||
SlotNo = (uint) tuple.slot, | ||
Name = tuple.pawn.Name, | ||
Sex = tuple.pawn.EditInfo.Sex, | ||
PawnState = tuple.pawn.PawnState, | ||
// TODO: ShareRange | ||
ReviveCost = 1, // TODO: Make it configurable | ||
PawnListData = new CDataPawnListData() | ||
{ | ||
Job = tuple.pawn.Job, | ||
Level = tuple.pawn.ActiveCharacterJobData.Lv, | ||
CraftRank = tuple.pawn.CraftData.CraftRank, | ||
PawnCraftSkillList = tuple.pawn.CraftData.PawnCraftSkillList, | ||
// TODO: CommentSize, LatestReturnDate | ||
} | ||
}) | ||
.ToList() | ||
}; | ||
} | ||
} | ||
} |
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
40 changes: 40 additions & 0 deletions
40
Arrowgene.Ddon.GameServer/Handler/PawnLostPawnGoldenReviveHandler.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,40 @@ | ||
using System.Linq; | ||
using Arrowgene.Ddon.Server; | ||
using Arrowgene.Ddon.Server.Network; | ||
using Arrowgene.Ddon.Shared.Entity.PacketStructure; | ||
using Arrowgene.Ddon.Shared.Entity.Structure; | ||
using Arrowgene.Ddon.Shared.Model; | ||
using Arrowgene.Ddon.Shared.Network; | ||
using Arrowgene.Logging; | ||
|
||
namespace Arrowgene.Ddon.GameServer.Handler | ||
{ | ||
public class PawnLostPawnGoldenReviveHandler : GameRequestPacketHandler<C2SPawnLostPawnGoldenReviveReq, S2CPawnLostPawnGoldenReviveRes> | ||
{ | ||
private static readonly ServerLogger Logger = LogProvider.Logger<ServerLogger>(typeof(PawnLostPawnGoldenReviveHandler)); | ||
|
||
public PawnLostPawnGoldenReviveHandler(DdonGameServer server) : base(server) | ||
{ | ||
} | ||
|
||
public override S2CPawnLostPawnGoldenReviveRes Handle(GameClient client, C2SPawnLostPawnGoldenReviveReq request) | ||
{ | ||
Pawn pawn = client.Character.Pawns.Where(pawn => pawn.PawnId == request.PawnId).Single(); | ||
pawn.PawnState = PawnState.Wait; | ||
Server.Database.UpdatePawnBaseInfo(pawn); | ||
|
||
bool walletUpdate = Server.WalletManager.RemoveFromWalletNtc(client, client.Character, WalletType.GoldenGemstones, 1); // TODO: Get price from settings. | ||
if (!walletUpdate) | ||
{ | ||
throw new ResponseErrorException(ErrorCode.ERROR_CODE_GP_LACK_GP); | ||
} | ||
byte updatedGP = (byte) Server.WalletManager.GetWalletAmount(client.Character, WalletType.GoldenGemstones); | ||
|
||
return new S2CPawnLostPawnGoldenReviveRes() | ||
{ | ||
PawnId = request.PawnId, | ||
GP = updatedGP | ||
}; | ||
} | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
Arrowgene.Ddon.GameServer/Handler/PawnLostPawnPointReviveHandler.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,41 @@ | ||
using System; | ||
using System.Linq; | ||
using Arrowgene.Ddon.Server; | ||
using Arrowgene.Ddon.Shared.Entity.PacketStructure; | ||
using Arrowgene.Ddon.Shared.Model; | ||
using Arrowgene.Logging; | ||
|
||
namespace Arrowgene.Ddon.GameServer.Handler | ||
{ | ||
public class PawnLostPawnPointReviveHandler : GameRequestPacketHandler<C2SPawnLostPawnPointReviveReq, S2CPawnLostPawnPointReviveRes> | ||
{ | ||
private static readonly ServerLogger Logger = LogProvider.Logger<ServerLogger>(typeof(PawnLostPawnPointReviveHandler)); | ||
|
||
public PawnLostPawnPointReviveHandler(DdonGameServer server) : base(server) | ||
{ | ||
} | ||
|
||
public override S2CPawnLostPawnPointReviveRes Handle(GameClient client, C2SPawnLostPawnPointReviveReq request) | ||
{ | ||
Pawn pawn = client.Character.Pawns.Where(pawn => pawn.PawnId == request.PawnId).Single(); | ||
pawn.PawnState = PawnState.Wait; | ||
Server.Database.UpdatePawnBaseInfo(pawn); | ||
|
||
client.Character.StatusInfo.RevivePoint = (byte) Math.Max(0, client.Character.StatusInfo.RevivePoint-1); | ||
Database.UpdateStatusInfo(client.Character); | ||
|
||
S2CCharacterUpdateRevivePointNtc ntc = new S2CCharacterUpdateRevivePointNtc() | ||
{ | ||
CharacterId = client.Character.CharacterId, | ||
RevivePoint = client.Character.StatusInfo.RevivePoint | ||
}; | ||
client.Party.SendToAllExcept(ntc, client); | ||
|
||
return new S2CPawnLostPawnPointReviveRes() | ||
{ | ||
PawnId = request.PawnId, | ||
RevivePoint = client.Character.StatusInfo.RevivePoint | ||
}; | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
Arrowgene.Ddon.GameServer/Handler/PawnLostPawnReviveHandler.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,29 @@ | ||
using System.Linq; | ||
using Arrowgene.Ddon.Server; | ||
using Arrowgene.Ddon.Shared.Entity.PacketStructure; | ||
using Arrowgene.Ddon.Shared.Model; | ||
using Arrowgene.Logging; | ||
|
||
namespace Arrowgene.Ddon.GameServer.Handler | ||
{ | ||
public class PawnLostPawnReviveHandler : GameRequestPacketHandler<C2SPawnLostPawnReviveReq, S2CPawnLostPawnReviveRes> | ||
{ | ||
private static readonly ServerLogger Logger = LogProvider.Logger<ServerLogger>(typeof(PawnLostPawnReviveHandler)); | ||
|
||
public PawnLostPawnReviveHandler(DdonGameServer server) : base(server) | ||
{ | ||
} | ||
|
||
public override S2CPawnLostPawnReviveRes Handle(GameClient client, C2SPawnLostPawnReviveReq request) | ||
{ | ||
Pawn pawn = client.Character.Pawns.Where(pawn => pawn.PawnId == request.PawnId).Single(); | ||
pawn.PawnState = PawnState.Wait; | ||
Server.Database.UpdatePawnBaseInfo(pawn); | ||
|
||
return new S2CPawnLostPawnReviveRes() | ||
{ | ||
PawnId = request.PawnId | ||
}; | ||
} | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
Arrowgene.Ddon.GameServer/Handler/PawnLostPawnWalletReviveHandler.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,50 @@ | ||
using System; | ||
using System.Linq; | ||
using Arrowgene.Ddon.Server; | ||
using Arrowgene.Ddon.Server.Network; | ||
using Arrowgene.Ddon.Shared.Entity.PacketStructure; | ||
using Arrowgene.Ddon.Shared.Entity.Structure; | ||
using Arrowgene.Ddon.Shared.Model; | ||
using Arrowgene.Ddon.Shared.Network; | ||
using Arrowgene.Logging; | ||
|
||
namespace Arrowgene.Ddon.GameServer.Handler | ||
{ | ||
public class PawnLostPawnWalletReviveHandler : GameRequestPacketHandler<C2SPawnLostPawnWalletReviveReq, S2CPawnLostPawnWalletReviveRes> | ||
{ | ||
private static readonly ServerLogger Logger = LogProvider.Logger<ServerLogger>(typeof(PawnLostPawnWalletReviveHandler)); | ||
|
||
public PawnLostPawnWalletReviveHandler(DdonGameServer server) : base(server) | ||
{ | ||
} | ||
|
||
public override S2CPawnLostPawnWalletReviveRes Handle(GameClient client, C2SPawnLostPawnWalletReviveReq request) | ||
{ | ||
Pawn pawn = client.Character.Pawns.Where(pawn => pawn.PawnId == request.PawnId).Single(); | ||
pawn.PawnState = PawnState.Wait; | ||
Server.Database.UpdatePawnBaseInfo(pawn); | ||
|
||
if (request.Type != WalletType.RiftPoints) | ||
{ | ||
// As far as im aware it can only be paid with RP | ||
throw new ResponseErrorException(ErrorCode.ERROR_CODE_CLIENT_REQ_ERROR); | ||
} | ||
|
||
// TODO: Validate ReviveCost value, validate that the player has the appropriate passport course effect active | ||
|
||
bool walletUpdate = Server.WalletManager.RemoveFromWalletNtc(client, client.Character, request.Type, request.ReviveCost); | ||
if (!walletUpdate) | ||
{ | ||
throw new ResponseErrorException(ErrorCode.ERROR_CODE_WARP_LACK_RIM); | ||
} | ||
uint updatedValue = Server.WalletManager.GetWalletAmount(client.Character, request.Type); | ||
|
||
return new S2CPawnLostPawnWalletReviveRes() | ||
{ | ||
PawnId = request.PawnId, | ||
Type = request.Type, | ||
Value = updatedValue | ||
}; | ||
} | ||
} | ||
} |
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
Oops, something went wrong.