Closed swooboo closed 7 years ago
An OO rewrite sounds like quite a good idea, HERITAGE could really use a rewrite, although I'm not quite sure about the best structure.
On the high level, HERITAGE has the following types:
It is important to note that items and actions are basically disconnected objects and items can be assigned to several rooms, so there is a lot of complicated referencing to do.
There are two other types, called import and info. Info would obviously be part of Game, and import should just call a function and is not an object on its own.
Currently, I'd think the following structure is best:
And last, but not least,
Player plays a pretty big role and we probably want to make the player part of Game (as in, make Game contain a player), so that through Game we can also control the player's position more easily.
How does that sound to you?
Sounds good. Note that I've never done JS in an OO way. (Actually a teacher of mine always insists that it's not OO.) But this seems nice. But shouldn't the rooms contain 'pointers' to other rooms for easier access, and also the player?
@TheLastProject, check out full-rewrite branch - didn't add some entities yet, like Exit or Action, because I can't yet fully understand what they are. But I think I am in the right direction. What do you think?
It's been a while since I did anything with HERITAGE, so it's a bit of guesswork, but it does seem right.
Exits would contain a list of conditions to check (is an item at a specific location, is an item in the player inventory, etc.) before it activates and the x, y and z coordinates to teleport the player to once activated, see https://github.com/TheLastProject/HERITAGE/blob/master/example/exits.heritage.
Actions are basically full sentences like "write note" or "put note on table", see https://github.com/TheLastProject/HERITAGE/blob/master/example/actions.heritage.
I did, however, notice a small bug in Room (should obviously be !this.visited
):
this.enter = function() {
if (this.visited)
this.first_enter();
};
if
.Exits indeed are basically teleports. They're placed in a room with a certain name so you can call them go north
, then the conditions are checked and if they are all satisfied you get moved to the x, y and z coordinates given in the "exit".
Originally, actions are implemented as a separate entity, because they could refer to multiple items for example (write with pen on paper
). As far as I know, nobody ever really made HERITAGE levels so if you feel it is sane to change it a bit I'd say go ahead.
Check this out - 0bb2c7de0cd0d9b3f51b4b6b3fd9a4b1b8875360, you can expand to view everything. I added the Action and the Exit classes, somewhat as you instructed, and in compliance with the examples you provided. Am I missing anything? Also note how clean the code looks...
@TheLastProject
It's starting to look rather nice and I can't think of anything wrong with it. One thing though, seeing how this is all your code, you probably want to update the copyright header.
Hmm good point. But I don't understand licenses at all, what do you mean? Should I just add my name/email to it alongside yours?
Seeing how you literally threw all engine code away, it's most logical to just replace my name and email with yours, as you created this.
Well, I completely disagree. The idea and initial execution was yours, I'm re-writing, but not creating anything new (yet). It usually is a lot easier to rewrite someone's code, make it work better and such, just because one can learn from the mistakes the original author made. And even now, I'm using your guidance actively, so you well deserve the credit. I just don't know how to correctly add this.
Now it's:
Copyright (C) 2014 - 2015 SylvieLorxu <sylvie@contracode.nl>
Should it be something like this?
Copyright (C) 2014 - 2015
SylvieLorxu <sylvie@contracode.nl>
swooboo <swooboo@mail.ru>
Fair enough, but in that case, please do me a favour and change it to Sylvia van Os <iamsylvie@openmailbox.org>
:)
Edit: Also, 2014 - 2016 as some pretty significant changes by you were made in 2016
Done - 318f760, closing this issue.
c2c3a3b477b46b2a1aff0354348708686d5cc0a6 - started from scratch. I need your help @TheLastProject. What we want to achieve in the end is a rewrite using OO principles. I've read a JS Prototype Tutorial, which might help.
I'm thinking of the following objects:
What do you think?