evennia / ainneve

A full example game created in Evennia (under development, anyone can help!)
77 stars 52 forks source link

Add a map object #97

Closed j-f1 closed 4 years ago

j-f1 commented 7 years ago

The map will automatically fill in as you explore Ainneve. Each time you enter a room, the map will look through all of the exits representing a compass direction and store information about the rooms on the other side. The map command (or look map) will show you your map. By default, the map is also printed every time you move to a new room. The webclient has the option to show the map in a popup window, kind of like the help command. In addition, I’ve:

The map command also includes a map/reset command, which erases all of the data on the map, which is useful when testing the map.

Here’s the current world map:

┌───── MAP ────┐
│  . ~↟~ .     │
│     . .↟. .  │
│     .  .  .  │
│  ══─*─────╴  │
│     \        │
│       \^_    │
└──────────────┘
j-f1 commented 7 years ago

Should I contribute this instead to the Evennia contrib? It seems like it isn’t specific to Ainneve.

aliceafterall commented 7 years ago

I agree - it's really quite useful for most any game. If you try it on Ainneve and it works well, perhaps a contrib for Evennia?

j-f1 commented 7 years ago

Can I get some 👀 on this @chainsol?

aliceafterall commented 7 years ago

Let me try it on my little test server, just to make sure it runs on 0.7.

aliceafterall commented 7 years ago

Actually, I already have some concerns - I don't like the idea of modifying the webclient like this, and it already breaks the webclient.

Edit: To be clear to anyone reading this later - it's because Evennia 0.7 loads jQuery from the CDN, not the static folder.

j-f1 commented 7 years ago

How does this break the webclient?

aliceafterall commented 7 years ago

It's because Evennia core, at least in 0.7, doesn't store jQuery, it's loaded from the CDN. Changing that line of course fixes it.

j-f1 commented 7 years ago

I’m wondering if it’s possible to install the map logic by overwriting the onText function in a separate script. I’ll try to move the other (notification-related) change to a PR on evennia/evennia this weekend.

aliceafterall commented 7 years ago

Nice. I'm going to wait for @Griatch or @feend78 to chime in before I approve just because I want some feedback from others about the webclient thing. I'm just wary of it...

Edit: Thinking about this, it would actually be good to be able to add "plugins" like this to the webclient anyway. Perhaps the core Evennia could support something like that...

aliceafterall commented 7 years ago

@j-f1 I just noticed - line 70 in typeclasses/maps.py, you check the character.player, but we'll have renamed that to character.account.

aliceafterall commented 7 years ago

@j-f1 I'd like to merge this into Develop, is it possible to fix any references to the player to match Develop, as well as to update the dictionary we talked about, of alternate characters for non-unicode clients?

j-f1 commented 7 years ago

I’m hoping to get to it this weekend, although I might have a chance sooner than that.

aliceafterall commented 7 years ago

Of course, no rush! I just wanted you to know I hadn't forgotten!

aliceafterall commented 6 years ago

@j-f1 Would you say you're ready with this? The change to a separate file for the webclient changes eases my qualms with this, and I can't see anything wrong!

j-f1 commented 6 years ago

@chainsol I’m good to go if you’re ready. Should I worry about support for non-Unicode clients?

aliceafterall commented 6 years ago

Yes, if you're able to, I think that would be important - sounds like Griatch suggested character.sessions.get()[0].protocol_flags['ENCODING'] as a way to check for UTF-8/Unicode support.

aliceafterall commented 6 years ago

@j-f1 Would it be doable to just change the map tiles to a tuple, with the unicode character and a fallback character, and then check if the session supports Unicode in the Map object itself?

j-f1 commented 6 years ago

That’s a good idea! I’ll take a look at that this afternoon. (~5-6 hours from now)

aliceafterall commented 6 years ago

No rush! When you get to it, great, and we'll merge this in to the develop branch.

j-f1 commented 6 years ago

I’ve looked at this a few times, but I’m not sure how I should thread the result down to the map_tile methods.

aliceafterall commented 6 years ago

Hmm, I've been going crazy moving, but I see your troubles there. Could the map_tile functions be passed the player trying to look at them?

Edit: Oh goodness, did you mean the @map_tile command? Or the map_tile method on the rooms?

j-f1 commented 6 years ago

Oh goodness, did you mean the @map_tile command? Or the map_tile method on the rooms?

I meant the map_tile method on rooms.

aliceafterall commented 6 years ago

So would that work? Pass down from the commands the session of the player looking at the map, and default to showing UTF-8/Unicode characters, fall-back to ASCII if the session doesn't support UTF-8?

aliceafterall commented 6 years ago
Œâ”€â”€â”€â”€ MAP ─────┐
│  . ~↟~ .     │
│     . .↟. .  │
│     *  .  .  │
│  ══─┬─────╴  │
│     \        │
│       \^_    │
└──────────────┘

Without having fallback characters, that's what the map looks like. I think we need to figure this out before merging it in. With a utf-8 encoding, it looks great, though!

I took a look at it and if we changed the character dicts to be storing tuples of the "nice" character and a fallback, that might be best? That way we can check if a character is holding the map and if so, use the fallback character if the session doesn't support utf-8.