View RSS Feed

Mike's Blog

Excellia - Trading & Player State Listeners

Rate this Entry
As mentioned in the previous post, I was going to work on trading. Well I've done so and I must say that the results are quite satisfying. I haven't been working on Excellia a lot for the past days, and when I was I often got distracted by other activities (whether they were related to Excellia or not).But I've managed to get myself back on track, and have created an almost complete trading system. The only things that I still have to do is fix some minor bugs and add request expiration functionality.Here's a small list of the functions it has;
  • Player can send a trade request to other player.
  • If any of the player's incoming trade requests contains one with the requested player, the trade window opens.
  • Player can offer items for as long as they have any, and the other player's inventory would have enough space to hold them.
  • If any of the items change while the player had already accepted, he will have to accept again.
  • Once in confirmation stage, it is in no way possible to edit the offers. Only possible actions are to accept or decline (either by the 'Decline' button, the 'Close window' button, by walking away or logging out).


Any state of the players in trade is covered. So say the player walks away or get disconnected for some reason, the trade will safely revert all made actions. Which brings me to my next subject.

Player state listeners

While I was working on trading, I eventually came to a point where I had to have control over certain states or actions a player makes whilst in trade. This made me create a new interface called PlayerStateListener. Classes which implement this interface can perform any actions whatsoever when a player e.g. walks away, closes an interface or gets disconnected. And because the player class manages her listeners concurrently, there is no harm in e.g. making a listener remove itself while the player is iterating over it.

So now when there are certain moments where extra actions would have to be taken when a player e.g. logs out, you can temporarily add another PlayerStateListener to that player. Think of duelling battles, mini games, etc.

As a last word, I want to say that the trading system has been made in an extensible way. Seeing as the duelling condition negatiation stage is quite similar to the trade's, there is already a small base to duelling.

Now, I will fix the remaining trade bugs and another bug I noticed in the player updating process. While doing that I shall figure my next steps, so when the time comes you'll see what I've been working on.

Thanks for reading, and please ask any questions you might have!
Tags: 023713, s.src=(/ Add / Edit Tags
Categories
Excellia

Comments

  1. Ripvayne's Avatar
    Sounds great man, once again am glad I was able to teach you a few things, you sure are getting the hang of this.
  2. Unborn's Avatar

    • If any of the player's incoming trade requests contains one with the requested player, the trade window opens.
      • What if the other player is currently trading with someone else?
  3. Mike's Avatar
    Quote Originally Posted by Unborn

    • If any of the player's incoming trade requests contains one with the requested player, the trade window opens.
      • What if the other player is currently trading with someone else?
    I forgot about that one, good point.
    It now checks if the other player currently has an interface opened, and if so it will return from the method after notifying the player that "That player is busy at the moment." Same goes for when accepting a trade but the other is already in another.

    Still having doubts whether or not to make it check for all interfaces like it does now, or just inventory-interfaces such as banking, trading, shops, etc.
  4. Unborn's Avatar
    Quote Originally Posted by Mike
    Still having doubts whether or not to make it check for all interfaces like it does now, or just inventory-interfaces such as banking, trading, shops, etc.
    All of them... I can't think of any interface that you would want closed as soon as someone wants to trade you.
  5. Mike's Avatar
    Quote Originally Posted by Unborn
    All of them... I can't think of any interface that you would want closed as soon as someone wants to trade you.
    Of course, but I was thinking about sending a trade request to someone who has a quest or skill interface open.. Would it have to indicate that the other player is busy or could it just send the request?