Comments (17)
I proposed to use an equip handler to administrate character equipment. Something like this:
https://github.com/Nadorrano/ainneve/blob/master/world/equip.py
it's completely modulare and is attached to the main Character typeclass as a property. More info in the doc in the module.
related commands:
https://github.com/Nadorrano/ainneve/blob/master/commands/equip_commands.py
If you folks like this approach I can adapt it a little bit more
from ainneve.
Nadorrano,
I think this looks great. There is a little bit of refactoring that will probably be done, but overall this would be very useful and a good addition.
For this to be implemented we need:
- Item typeclass
- Weapon typeclass skeleton
- Armor typeclass skeleton
On Item, lets have an on_hold method, and then we can save on_equip for a typeclass higher up that Weapon, Armor, Shield will receive. We could also have an on_wear. I would have to think about the hierarchy here a little bit. If you would like to make a proposal for the Typeclass hierarchy going from Object to Weapon/Armor/Shield, that would be good as well.
from ainneve.
The hierarchy is a delicate thing. Don't ask me, I like multiple inheritance and I have a tendency to overcomplicate things.
But why so many hooks are needed? Is not enough to have a single on_equip on the base Item typeclass that can be redefined appropriately on each child?
from ainneve.
An "Item" does not need an on_equip, because most of the things that will come from Item cannot be equipped (for example, a book or a potion). They likely can be held, however, which is a different event than equipping something. on_equip and on_wear could potentially be the same.
Also, yes, multiple inheritance is usually a bad practice. However, I think Shield may require multiple inheritance. When I wrote Shield before in my own module, it inherited both Weapon and Armor.
I will think over the hierarchy later today.
from ainneve.
My proposal:
to have on_hold and on_equip (maybe on_wield too) on the parent Item typeclass, both: pass.
Every child typeclass will overload needed methods and can be controlled by lock checks. Every hook is called by a different command hence they will strike independently. So you will get your hooks called correctly, if defined, when you wield your sword, or when you hold it in your hand, to be enchanted or something.
I thinked that a strict adhesion to classes is going to kill duck typing at some point, but I'm not an expert and I will wait for some better advice.
from ainneve.
Then we can simply derive Weapon and Shield from Item. And from these, more specific subclasses.
from ainneve.
on_wield
and on_hold
seem the same to me from a world model point of view; of course the player interface may be hold, wield, etcetera but is there a use case for different game effects when wielding vs. holding something?
I think on_equip
is OK on Item because a character conceivably can hold just about anything they can put in their inventory (a book, potion, etc.).
from ainneve.
Ok, I will put something together in the next hours.
from ainneve.
Base item skeleton
https://github.com/Nadorrano/ainneve/blob/master/typeclasses/items.py
Equip Handler
https://github.com/Nadorrano/ainneve/blob/master/world/equip.py
Equip Commands
https://github.com/Nadorrano/ainneve/blob/master/commands/equip_commands.py
from ainneve.
At the moment I put the hooks on the base Item, waiting for a better solution.
We have three hooks, at_hold, at_equip, at_remove. It should be enough, since every hook can access the character equip to check the state of the object and knows who is the character.
Slots, as a list, are loaded by the init function, not linked to the race yet, but some default slots are present.
At the moment three slots are hardcoded: 'left hand', 'right hand', 'holds', this is important since they are used by methods.
I made just one module for item, armor and weapons but it should be splitted, I think.
To equip an object:
- obj must inherit from Item
- obj must have db.slot == string or list of strings
- character's equip and obj must have a slot in common
- the slot must be empty (of course)
- character access the equip lock check
- character access the hold lock check to hold the object
To test:
@create a sword:items.Sword
wield sword
eq
remove sword
from ainneve.
Sounds good.
Rereading @whitenoiseoss earlier comment about on_equip on item I realize I didn't see that he distinguished between equip and hold, which makes perfect sense. However I don't think we lose much by putting on_equip on Item.
from ainneve.
If @whitenoiseoss has no more review for this PR I'd like to merge; I'll wait until tomorrow.
from ainneve.
Yep, I'm waiting for feedbacks. My pull request is #13 let's move there to comment the code.
from ainneve.
Thanks for waiting @Nadorrano, I'm starting review myself and will comment on the PR.
edit: I've finished my comments, thanks Nadorrano! Let me know what you think about my suggestions.
from ainneve.
@Nadorrano I should add that you may want to create a separate branch for this PR and resubmit; I'm not sure but I think Github will automatically add any future commits on your master branch to this PR, which you probably don't want. See http://codeinthehole.com/writing/pull-requests-and-other-good-practices-for-teams-using-github/
It allows you to submit multiple pull requests without confusion. The classical Github gotcha is to continue committing to a pull request branch after making the initial request. When these commits are pushed to the remote, they will become part of the original pull request which often ends up conflating unrelated functionality.
from ainneve.
@ergodicbreak Nice, I replied to comments. It is not clear to me if I have to create a branch from my fork or I have to fork a branch created by you... I'm a github newb so I'll read that article, thanks!
from ainneve.
@Nadorrano I'm a beginner to Github too but I think you create a branch, and then make a PR against the main Ainneve master.
from ainneve.
Related Issues (20)
- Evennia Master @ 0.7 HOT 3
- Characters can Attack Themselves HOT 1
- Development branch for Ainneve HOT 1
- Improve Testing HOT 1
- Lockfuncs based on traits HOT 1
- doc inconsistancies in traits.py for gauge traits HOT 2
- Attempting to use @py to view traits crashes server HOT 12
- Ainneve fails to start under Evennia Dev 0.8 HOT 4
- Rework Prototypes for Evennia 0.8 HOT 1
- Remove Ainneve's custom combat system and make use of Evennia's TurnBattle contrib HOT 4
- traits.clear() fix HOT 1
- Ainneve revival HOT 6
- Overhaul Combat System HOT 5
- Integrating the EvAdventure tutorial code into Ainneve HOT 1
- Build Zodiac Square HOT 8
- Bug: Traceback on Combat
- Customize combat messaging for weapons HOT 2
- Ever Expanding Linebreaks in Chargen HOT 1
- settings secret key has been publicized HOT 2
- Magic HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ainneve.