Giter Club home page Giter Club logo

cactus's People

Contributors

ethan-bierlein avatar sanketdg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

iambibhas

cactus's Issues

Rename `CactusSource` to `cactus`; remove prefix (sorry!)

This would allow the user, once they set the PYTHONPATH, to do this:

import cactus.game
import cactus.map
import cactus.position

my_game = cactus.Game(data)

Then, we could also do stuff like this later:

import cactus.color

print(cactus.color.red + "This is red!")

Validate class_data

We need to validate class_data in all three classes:

  • During __init__
  • Every time it's changed

We need to make sure:

  • Everything that's required is there
  • Nothing extra is there
  • All of the items are of the correct types (key and value)

The first one is easy to do, but how do we do the second one, especially when data could change mid-function? Too bad we couldn't "watch" the dictionary for any changes.

This is the reason why I wanted the __init__ argument to be a dictionary, but it actually stored as the actual variables

Implement colorama

https://pypi.python.org/pypi/colorama

To make everything streamlined for the user, we should also define all of the colors ourself... somehow. Whoever can find a way to do a syntax like Backgroud_Color.Red please take this issue.

I don't want the user to have to deal with colorama itself because it's not as streamlined. I want everything the user needs to be in Cactus itself

How should we handle exceptions?

Exceptions happen in code. Often.

We don't want to spew this data at the user's face, so exceptions would be a good idea.

Having a unified exception "type" would be good for this so the user can catch these (I'm not sure much about Python exceptions)

Should we also log exceptions to a file? Tell the user that something bad happened internally? What?

Game map validator

We need to make sure that the links between the rooms are valid.

We should validate the user's input in MainGame.__init__().

Make external syntax easier to read

We currently require a ton of nesting to make stuff somewhat readable

Even a simple "map" is really hard to read:

GAME_MAP = GameMap([
    MapPosition(
        "Start",
        "Welcome to the start!",
        "Now leaving the start.",
        {
            "left": 1,
            "right": 2,
        },
    ),
    MapPosition(
        "Left",
        "You took the left path and died.",
        "",
        {},
        function=exit,
    ),
    MapPosition(
        "Right",
        "You took the right path and lived!",
        "",
        {},
        function=exit,
    ),
])

How can we fix this? I was thinking about making everything more paramaterized. i.e. we would do this:

game_map = GameMap("someBasicStuff")

game_map.add_location("Left", "You took the left path and died", "", {}, otherData)

Any other suggestions to make it easier to use?

Global commands

We should have the option for a user to add global commands, like quit.

We should have them integrated into the "fabric mesh," so a user can have one for going to a saved home, or to an inventory/other menu.

As usual, they should be able to bind to these commands.

When do we make the equals signs line up?

I've noticed that most of the time, they are like this:

self.map_start         = self.class_data["map"].find_start()
self.map_position      = self.map_start
self.last_map_position = None
          # Lined up --^

But, sometimes they don't. When do we want them lined up?

`blankline_between_content` bool

From

You have reached a blank room.
>> eat taco
Yum.
You are now in the dining hall.
You have reached a blank room.

>> eat taco

Yum.

You are now in the dining hall.

Might also want an option for just around the prompt.

Event handling doesn't use _conditional_lower

(This assumes that lower_text has been enabled)

Suppose I have a MapPosition instance with the name "My Position". If I try to assign a function to it using an event handler, and it's actual, capitalized name, it doesn't work. Here's an example.

"map_position.My Position.enter.after": func # <-- This doesn't work.

In order to get this to work, I have to type the following instead.

"map_position.my position.enter.after": func # <-- This works, but it's still a bug.

Event handler

I think the best way to make this flexible is to add an event handler (like JavaScript's onLoad type thing).

To do this, we need to:

  • Remove any redundant copies of variables (lazy eval, extra functions will help us maintain readability)
  • Add an event handler system

To do this:

Have user pass a dictionary of string: function, where string is something like onEnterRoom and function with the MainGame is the only argument (so they can modify the game). We will need to add enough functionality that they can completely manipulate the game without borking something.

License

We should all accept the same licence before proceeding.

I suggest the MIT. Is that ok?

Ensure that external code can edit dictionary

Test on a string, as they cannot be mutated! Test on an int, also, to be sure.

Worry: Python's pass-by-object will not allow external code to edit the dictionary. I want to be sure

Coding Convention

Can we please establish a coding convention?

PEP 8 seems to be the prevalent style in the Python ecosystem, but we don't seem to conform with class definitions.

All established open source projects have a coding convention, so we should also.

Rename classes

MainGameCactusGame
MapPositionCactusPosition
GameMapCactusMap

Is this okay @ShearOfDoom?

Use functions rather than Strings for enter and exit events

This lets rooms be dynamic -- for example, you could enter a room, knock a torch down, and the room catches on fire. If you try to enter the room again, it could deduct (for example) four health and tell you:

HOLY CRAP YOU'RE ON FIRE AAGAHGASKGHASG

add setup.py

and probably upload to pypi so that users can pip install it.

I could take this up and submit a pull request.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.