Skip to content
This repository has been archived by the owner on Jul 11, 2020. It is now read-only.

Added Drop Packet Handler #20

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

arvylagunamayor
Copy link

Had issue with packet drop handler, it seems it wasnt' yet implemented. I saw that the GroundItem packets is currently beig handled in InPacketHandler.cs but its current header is "in" while the drop packet header is "drop".

This is my first time contributing in an opensource project. Sorry if codes wasn't that good.

@arvylagunamayor
Copy link
Author

Fixed param of create ground item factory and added brackets ah code quality checker suggested.

Copy link
Owner

@Roxeez Roxeez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your PR, when you have fixed existing problems, could be cool if you create unit test for this packet handler.

return;
}

Entity entity = _entityFactory.CreateGroundItem(packet.DropId, packet.VNum, packet.Amount);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set variable type as GroundItem instead of Entity since CreateGroundItem will always return a GroundItem

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, ill will try to fix this and the rest of the issue maybe later this week. Thank you for your keen eye.

Entity entity = _entityFactory.CreateGroundItem(packet.DropId, packet.VNum, packet.Amount);
entity.Position = new Position(packet.PositionX, packet.PositionY);

if (entity is GroundItem drop)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By fixing previous problem, you can also remove this type check/cast.


if (map == null)
{
_logger.Warn("Handling InPacket but character map is null");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change warning message to Handling DropPacket instead of Handling InPacket

}

map.AddEntity(entity);
_logger.Info($"Entity {entity.EntityType} {entity.Id} joined map");
Copy link
Owner

@Roxeez Roxeez Apr 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change info message to Drop with id {entity.Id} added to map instead or something like this

map.AddEntity(entity);
_logger.Info($"Entity {entity.EntityType} {entity.Id} joined map");

_eventManager.Emit(new EntityJoinEvent(client)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you can also create a DropEvent or something with GroundItem & Map as property

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants