Skip to content

Commit

Permalink
Merge branch 'master' into feature/guilds
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanmoffat committed Oct 27, 2024
2 parents efde12a + cdffe68 commit c8c6879
Show file tree
Hide file tree
Showing 43 changed files with 401 additions and 160 deletions.
2 changes: 1 addition & 1 deletion EOBot/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public void JunkItem(int id, int amountRemoved)
ConsoleHelper.WriteMessage(ConsoleHelper.Type.JunkItem, $"{weight,3}/{maxWeight,3} - weight - {inventoryCount?.Amount ?? 0} in inventory");
}

public void MakeDrunk() { }
public void NotifyFrozen() { }
}

[AutoMappedType]
Expand Down
2 changes: 1 addition & 1 deletion EOBot/TrainerBot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ private async Task Walk()
{
var renderProps = _characterRepository.MainCharacter.RenderProperties;
ConsoleHelper.WriteMessage(ConsoleHelper.Type.Walk, $"{renderProps.GetDestinationX(),3},{renderProps.GetDestinationY(),3}");
await TrySend(_characterActions.Walk);
await TrySend(() => _characterActions.Walk(false));
await Delay(WALK_BACKOFF_MS);
}

Expand Down
2 changes: 1 addition & 1 deletion EOLib.IO/EOLib.IO.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AutomaticTypeMapper" Version="1.4.1" />
<PackageReference Include="Moffat.EndlessOnline.SDK" Version="1.0.0-rc2" />
<PackageReference Include="Moffat.EndlessOnline.SDK" Version="1.0.0-rc3" />
<PackageReference Include="System.Memory" Version="4.5.5" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion EOLib.Localization/EOLib.Localization.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="AutomaticTypeMapper" Version="1.4.1" />
<PackageReference Include="Moffat.EndlessOnline.SDK" Version="1.0.0-rc2" />
<PackageReference Include="Moffat.EndlessOnline.SDK" Version="1.0.0-rc3" />
</ItemGroup>
</Project>
7 changes: 6 additions & 1 deletion EOLib/Domain/Character/AttackValidationActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@ public AttackValidationActions(ICharacterProvider characterProvider,

public AttackValidationError ValidateCharacterStateBeforeAttacking()
{
if (_characterProvider.MainCharacter.Frozen)
return AttackValidationError.Frozen;

if (_characterProvider.MainCharacter.Stats[CharacterStat.Weight] >
_characterProvider.MainCharacter.Stats[CharacterStat.MaxWeight])
return AttackValidationError.Overweight;

if (_characterProvider.MainCharacter.Stats[CharacterStat.SP] <= 0)
return AttackValidationError.Exhausted;

Expand Down Expand Up @@ -73,6 +77,7 @@ public enum AttackValidationError
Overweight,
Exhausted,
NotYourBattle,
MissingArrows
MissingArrows,
Frozen,
}
}
2 changes: 2 additions & 0 deletions EOLib/Domain/Character/Character.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public sealed partial class Character : ISpellTargetable

public bool NoWall { get; }

public bool Frozen { get; }

public static Character FromCharacterSelectionListEntry(CharacterSelectionListEntry selectionListEntry)
{
return new Builder
Expand Down
5 changes: 3 additions & 2 deletions EOLib/Domain/Character/CharacterActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void Face(EODirection direction)
_packetSendService.SendPacket(packet);
}

public void Walk()
public void Walk(bool ghosted)
{
var admin = _characterRepository.MainCharacter.NoWall &&
_characterRepository.MainCharacter.AdminLevel != AdminLevel.Player;
Expand All @@ -56,6 +56,7 @@ public void Walk()

var packet = admin
? (IPacket)new WalkAdminClientPacket { WalkAction = walkAction }
: ghosted ? (IPacket)new WalkSpecClientPacket { WalkAction = walkAction }
: (IPacket)new WalkPlayerClientPacket { WalkAction = walkAction };
_packetSendService.SendPacket(packet);
}
Expand Down Expand Up @@ -169,7 +170,7 @@ public interface ICharacterActions
{
void Face(EODirection direction);

void Walk();
void Walk(bool ghosted);

void Attack();

Expand Down
7 changes: 6 additions & 1 deletion EOLib/Domain/Character/WalkValidationActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ public enum WalkValidationResult
NotWalkable,
Walkable,
BlockedByCharacter,
GhostComplete
GhostComplete,
Frozen
}

[AutoMappedType]
Expand All @@ -36,6 +37,7 @@ public WalkValidationActions(IMapCellStateProvider mapCellStateProvider,
_currentMapStateProvider = currentMapStateProvider;
_unlockDoorValidator = unlockDoorValidator;
_ghostingRepository = ghostingRepository;

}

public WalkValidationResult CanMoveToDestinationCoordinates()
Expand Down Expand Up @@ -65,6 +67,9 @@ public WalkValidationResult IsCellStateWalkable(IMapCellState cellState)
{
ClearGhostCache();

if (_characterProvider.MainCharacter.Frozen)
return WalkValidationResult.Frozen;

var mc = _characterProvider.MainCharacter;

var cellChar = cellState.Character.FlatMap(c => c.SomeWhen(cc => cc != mc));
Expand Down
2 changes: 1 addition & 1 deletion EOLib/Domain/Login/LoginActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public async Task<int> RequestCharacterLogin(Character.Character character)
.WithAdminLevel(data.Admin)
.WithStats(CharacterStats.FromSelectCharacterData(data));

_playerInfoRepository.IsFirstTimePlayer = data.LoginMessageCode == LoginMessageCode.Yes;
_playerInfoRepository.IsFirstTimePlayer = data.LoginMessageCode != LoginMessageCode.No;
_playerInfoRepository.PlayerHasAdminCharacter = _characterSelectorRepository.Characters.Any(x => x.AdminLevel > 0);

_currentMapStateRepository.CurrentMapID = data.MapId;
Expand Down
4 changes: 4 additions & 0 deletions EOLib/Domain/Notifiers/IEffectNotifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public interface IEffectNotifier
void NotifyMapEffect(IO.Map.MapEffect effect, int strength = 0);

void NotifyEffectAtLocation(MapCoordinate location, int effectId);

void NotifyAdminHideEffect(int playerId);
}

[AutoMappedType]
Expand All @@ -29,5 +31,7 @@ public void NotifyPotionEffect(int playerId, int effectId) { }
public void NotifyMapEffect(IO.Map.MapEffect effect, int strength = 0) { }

public void NotifyEffectAtLocation(MapCoordinate location, int effectId) { }

public void NotifyAdminHideEffect(int playerId) { }
}
}
4 changes: 4 additions & 0 deletions EOLib/Domain/Notifiers/IMainCharacterEventNotifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public interface IMainCharacterEventNotifier
void DropItem(int id, int amountDropped);

void JunkItem(int id, int amountRemoved);

void NotifyFrozen();
}

[AutoMappedType]
Expand All @@ -28,5 +30,7 @@ public void TakeItemFromMap(int id, int amountTaken) { }
public void DropItem(int id, int amountDropped) { }

public void JunkItem(int id, int amountTaken) { }

public void NotifyFrozen() { }
}
}
19 changes: 18 additions & 1 deletion EOLib/Domain/Spells/SpellCastValidationActions.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
using System.Linq;

using AutomaticTypeMapper;

using EOLib.Domain.Character;
using EOLib.Domain.Map;
using EOLib.Domain.Party;
using EOLib.IO;
using EOLib.IO.Repositories;

Expand All @@ -13,31 +16,42 @@ public class SpellCastValidationActions : ISpellCastValidationActions
private readonly IPubFileProvider _pubFileProvider;
private readonly ICurrentMapProvider _currentMapProvider;
private readonly ICharacterProvider _characterProvider;
private readonly IPartyDataProvider _partyDataProvider;

public SpellCastValidationActions(IPubFileProvider pubFileProvider,
ICurrentMapProvider currentMapProvider,
ICharacterProvider characterProvider)
ICharacterProvider characterProvider,
IPartyDataProvider partyDataProvider)
{
_pubFileProvider = pubFileProvider;
_currentMapProvider = currentMapProvider;
_characterProvider = characterProvider;
_partyDataProvider = partyDataProvider;
}

public SpellCastValidationResult ValidateSpellCast(int spellId)
{
if (_characterProvider.MainCharacter.Frozen)
return SpellCastValidationResult.Frozen;

var spellData = _pubFileProvider.ESFFile[spellId];

var stats = _characterProvider.MainCharacter.Stats;
if (stats[CharacterStat.SP] - spellData.SP < 0)
return SpellCastValidationResult.ExhaustedNoSp;
if (stats[CharacterStat.TP] - spellData.TP < 0)
return SpellCastValidationResult.ExhaustedNoTp;
if (spellData.Target == SpellTarget.Group && !_partyDataProvider.Members.Any())
return SpellCastValidationResult.NotMemberOfGroup;

return SpellCastValidationResult.Ok;
}

public SpellCastValidationResult ValidateSpellCast(int spellId, ISpellTargetable spellTarget)
{
if (_characterProvider.MainCharacter.Frozen)
return SpellCastValidationResult.Frozen;

var res = ValidateSpellCast(spellId);
if (res != SpellCastValidationResult.Ok)
return res;
Expand Down Expand Up @@ -75,6 +89,9 @@ public SpellCastValidationResult ValidateSpellCast(int spellId, ISpellTargetable

public bool ValidateBard()
{
if (_characterProvider.MainCharacter.Frozen)
return false;

var weapon = _characterProvider.MainCharacter.RenderProperties.WeaponGraphic;
return Constants.Instruments.Any(x => x == weapon);
}
Expand Down
2 changes: 2 additions & 0 deletions EOLib/Domain/Spells/SpellCastValidationResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@ public enum SpellCastValidationResult
WrongTargetType,
ExhaustedNoSp,
ExhaustedNoTp,
NotMemberOfGroup,
Frozen,
}
}
2 changes: 1 addition & 1 deletion EOLib/EOLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<ItemGroup>
<PackageReference Include="Amadevus.RecordGenerator" Version="0.6.0" />
<PackageReference Include="AutomaticTypeMapper" Version="1.4.1" />
<PackageReference Include="Moffat.EndlessOnline.SDK" Version="1.0.0-rc2" />
<PackageReference Include="Moffat.EndlessOnline.SDK" Version="1.0.0-rc3" />
<PackageReference Include="Optional" Version="4.0.0" />
</ItemGroup>
</Project>
10 changes: 9 additions & 1 deletion EOLib/PacketHandlers/AdminInteract/AdminInteractAgree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using EOLib.Domain.Character;
using EOLib.Domain.Login;
using EOLib.Domain.Map;
using EOLib.Domain.Notifiers;
using EOLib.Net.Handlers;
using Moffat.EndlessOnline.SDK.Protocol.Net;
using Moffat.EndlessOnline.SDK.Protocol.Net.Server;
Expand All @@ -17,17 +18,20 @@ public class AdminInteractAgree : InGameOnlyPacketHandler<AdminInteractAgreeServ
{
private readonly ICharacterRepository _characterRepository;
private readonly ICurrentMapStateRepository _currentMapStateRepository;
private readonly IEnumerable<IEffectNotifier> _effectNotifiers;

public override PacketFamily Family => PacketFamily.AdminInteract;
public override PacketAction Action => PacketAction.Agree;

public AdminInteractAgree(IPlayerInfoProvider playerInfoProvider,
ICharacterRepository characterRepository,
ICurrentMapStateRepository currentMapStateRepository)
ICurrentMapStateRepository currentMapStateRepository,
IEnumerable<IEffectNotifier> effectNotifiers)
: base(playerInfoProvider)
{
_characterRepository = characterRepository;
_currentMapStateRepository = currentMapStateRepository;
_effectNotifiers = effectNotifiers;
}

public override bool HandlePacket(AdminInteractAgreeServerPacket packet)
Expand All @@ -46,9 +50,13 @@ public override bool HandlePacket(AdminInteractAgreeServerPacket packet)
else
{
_currentMapStateRepository.UnknownPlayerIDs.Add(packet.PlayerId);
return true;
}
}

foreach (var notifier in _effectNotifiers)
notifier.NotifyAdminHideEffect(packet.PlayerId);

return true;
}

Expand Down
10 changes: 9 additions & 1 deletion EOLib/PacketHandlers/AdminInteract/AdminInteractRemove.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using EOLib.Domain.Character;
using EOLib.Domain.Login;
using EOLib.Domain.Map;
using EOLib.Domain.Notifiers;
using EOLib.Net.Handlers;
using Moffat.EndlessOnline.SDK.Protocol.Net;
using Moffat.EndlessOnline.SDK.Protocol.Net.Server;
Expand All @@ -17,17 +18,20 @@ public class AdminInteractRemove : InGameOnlyPacketHandler<AdminInteractRemoveSe
{
private readonly ICharacterRepository _characterRepository;
private readonly ICurrentMapStateRepository _currentMapStateRepository;
private readonly IEnumerable<IEffectNotifier> _effectNotifiers;

public override PacketFamily Family => PacketFamily.AdminInteract;
public override PacketAction Action => PacketAction.Remove;

public AdminInteractRemove(IPlayerInfoProvider playerInfoProvider,
ICharacterRepository characterRepository,
ICurrentMapStateRepository currentMapStateRepository)
ICurrentMapStateRepository currentMapStateRepository,
IEnumerable<IEffectNotifier> effectNotifiers)
: base(playerInfoProvider)
{
_characterRepository = characterRepository;
_currentMapStateRepository = currentMapStateRepository;
_effectNotifiers = effectNotifiers;
}

public override bool HandlePacket(AdminInteractRemoveServerPacket packet)
Expand All @@ -46,9 +50,13 @@ public override bool HandlePacket(AdminInteractRemoveServerPacket packet)
else
{
_currentMapStateRepository.UnknownPlayerIDs.Add(packet.PlayerId);
return true;
}
}

foreach (var notifier in _effectNotifiers)
notifier.NotifyAdminHideEffect(packet.PlayerId);

return true;
}

Expand Down
Loading

0 comments on commit c8c6879

Please sign in to comment.