Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Laurent V.
    @monsieurluge
    And what about using decorators ? For example new DamagedWeapon(new Weapon(...), amount), or something like that
    The behaviour is still the same, but the decorator changes the behaviour according to the amount
    (we really need to join the Slack board ^^)
    Joshua Light
    @JoshuaLight

    This is ok. But what about rendering? How ItemDescription will know, whether it's weapon or not, what it's durability, critical chance and etc.? Do Item create ItemDescription or ItemDescription is created from Item? This dependency flow, actually, can be or from one side to other or vice versa.

    The main problem in first direction is GETTERS.
    In second — generalization (I cannot abstract rendering and representation, only with some hacks and simplifications).

    Laurent V.
    @monsieurluge
    From the game engine point of view, i know, the getters are mandatory
    Laurent V.
    @monsieurluge
    What about a PrintableItemwhich can respond to the print(to) message ?
    The PrintableItem sends only raw informations to the output (maybe through the with(name, data) message), and these informations may be critical chances or anything else. The Item does not need to know what kind of object will receive these informations
    These informations does not have behaviour attached to them. They are pure raw informations.
    Joshua Light
    @JoshuaLight

    Well, this can be good for generic engines like serialization: serializer doesn't care about anything and can work with property-value pairs. But more specific engines cannot.

    So the problem with with( name, data ) is that as RENDERER how do I know, which kinds of names are available and which one is related to durability, damage and etc.? Even if I know, how can I be sure that contract is not changed? Oh, I mentioned word contract because, as you can see, this will be just another way to implement... getters!

    It seems like the whole problem to render an item leads us to some kind of getters in one way or another.

    VytasGit
    @VytasGit

    @JoshuaLight You don't need ItemType. Just have interfaces such as Weapon, Armour, Bag, etc. If you need properties like "durability" for rendering, ask yourself - why? If it's to determine whether it's broken or not, just give it a method isBroken(). So your Renderable could encapsulate (not decorate) Item it's supposed to render and just ask it item.isBroken() ?.

    Rareness may be more tricky. Perhaps your game World should have the responsibility of tracking which items are rare and which aren't?

    And to display its stats in inventory, how about a printer? Item could have a method display(InventorySpecs), where InventorySpecs could have methods such as withWeight(int), withDamage(int), etc.
    Joshua Light
    @JoshuaLight

    Just have interfaces such as Weapon, Armour, Bag, etc.

    So you think I should use type-casting? Because only with type-casting I can check whether Item is weapon or not. Also, there are a lot of weapons here: swords, axes, maces etc. How can I determine which texture to use to render specified Weapon? With IsAxe()? This approach conceptually is almost like getters, no encapsulation at all.

    I think rareness was a bad example, because this is really a property of item, which is needed only to show player that his weapon differs from others on a quality level.

    @VytasGit

    This printers idea with InventorySpecs is a good one. As I said earlier, it looks like this is a acceptable compromise, if InventorySpecs is driven by domain model, but related only for InventoryRepresentation. Then I can create ConsoleInventorySpecs, Direct3DInventorySpecs and so on. We conceptually separated rendering from behaviour. This is still looks isomorphic to getters, but in more elegant and objective way, as for me. Will try it soon on my game, where I test such things.

    Thanks a lot for discussion and help, guys!
    VytasGit
    @VytasGit
    Why do you need to know if it's a weapon? To equip it? How about Character interface with a method equip(Weapon)?
    Laurent V.
    @monsieurluge
    Avoid type casting. Think "interface".
    Yep, the InventorySpecs is a good solution.
    Silas Reinagel
    @SilasReinagel
    @JoshuaLight There are some other flaws with this code, but here is an example: https://github.com/EnigmaDragons/MegaBuy/blob/master/MegaBuy/Pads/Pad.cs
    We composed our object graph, beginning with a parent graph who is a Scene, and then the Scene might encapsulate other Objects, each of whom is told to render themselves Draw based on a Parent Position. The calls propagate downwards until every object in the graph (each encapsulated in a specific group or container) has been told to draw himself.
    One the the flaws is that we used a Static Class that we called to do our rendered, rather than passing the SpritesBatch like we did in later projects.
    In the example code, we have a simulated Tablet Computer in the game who can switch between various In-Game Apps. Each App would do composed of it's own encapsulated objects (buttons, images, icons, text, characters... and so forth)
    Joshua Light
    @JoshuaLight

    @SilasReinagel

    I like such approach and seen it in many places, actually. But, as for me, it can be used only for UI things in UI domain. Yes, we can abstract rendering for visual things, as it has done in, for example, Avalonia UI, where guys just created something like SpriteBatch that is used in many OS and contexts.

    But when we're talking about separation of domain model from UI (I think this is obvious, why we're doing that), then all become more complicated. I think this is just theoretically impossible without getters.

    Joshua Light
    @JoshuaLight
    But what I think is that such "getters" are not even getters, because they're queries. Getters are all about direct field encapsulation.
    Silas Reinagel
    @SilasReinagel
    I also agree
    Naked data manipulation is dangerous
    But there is nothing wrong with being able to ask an object for a piece of information and receive back a message with that information
    It has to do more with the general design of the Object, and not whether it uses "getter" syntax or not.
    Joshua Light
    @JoshuaLight

    @SilasReinagel
    Agreed!

    Can you give me a link to OOP slack channel? I mailed goqp, but he is silent. ))

    Victor Noël
    @victornoel
    @JoshuaLight @goqp didn't seem to want to make it public, but anyway you need an invite to get on it, so you will have to wait for @goqp (as I am ^^).
    Joshua Light
    @JoshuaLight
    Let's wait together! ))
    Zsolt Sandor
    @sz332
    guys, give me some email address, and I try to send an invitation.
    @JoshuaLight @victornoel give me your email address and i will try to send you an invitation.
    Victor Noël
    @victornoel
    thx
    JP
    @nqafield
    @/all Do you think there's any chance of convincing Yegor to abandon Telegram and move to something that doesn't (entirely unnecessarily) require your phone number...?
    Luca Guadagnini
    @tryIO
    I don't think so :smile: but I agree there's no sense to give our phone numbers just for chatting, I suppose Slack would be another valid and better solution (as much as Discord in my opinion)
    Zsolt Sandor
    @sz332
    @tryIO a couple of us moves already to slack, ask @goqp for access
    JP
    @nqafield
    Thanks. I'll give Slack a go I think.
    Zsolt Sandor
    @sz332
    welcome. Just write me a private message with your email address, and i will try to send you an invitation.
    @nqafield ^^^^
    JP
    @nqafield
    Thanks @sz332!
    Meerow
    @Meerownymous
    Does anyone of you know examples for object oriented approaches in Angular2-5?
    Services as well as dealing with Views.. There is so much data leaking all over the application
    Victor Noël
    @victornoel
    good question…
    Renato Marinho
    @renatomarinho
    This message was deleted
    Kapralov Sergey
    @skapral
    A bit of marketing: for those who like puzzle-driven development, there is a tool https://github.com/skapral/puzzlerbot, which makes possible to manage puzzles outside of the source code.
    Renato Marinho
    @renatomarinho
    This message was deleted
    AbrisM
    @AbrisM
    Hi all
    AbrisM
    @AbrisM
    Anyone know how to get the java.lang library to recongnize newly created type Objects?
    Like if I make a custom object like Squid fish = new Squid(); how do I have Java recongnize this custom besides default type Objects?
    Zsolt Sandor
    @sz332
    cglib or similar?
    Augustas
    @AugustasV
    Maybe someone can explain me, how I should write PHP code, and output everything as string? Something like that? I need to input some data, but output only in console or something